-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile-api
More file actions
48 lines (34 loc) · 1.21 KB
/
Dockerfile-api
File metadata and controls
48 lines (34 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Use the official Python image from the Docker Hub
FROM python:3.13.2-slim-bookworm AS base
ARG APP_GID=10000
ARG APP_UID=16997
RUN apt-get update && \
apt-get install -y --no-install-recommends \
openssh-client libexpat1 && \
rm -rf /var/lib/apt/lists/*
# Set environment variables
ENV PYTHONUNBUFFERED=1
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
# create user/group
RUN groupadd -g $APP_GID appgroup && \
useradd -m -u $APP_UID -g $APP_GID appuser
USER appuser
# Change the working directory to the `app` directory
WORKDIR /app
# Copy the lockfile and `pyproject.toml` into the image
COPY --chown=appuser:appgroup uv.lock /app/uv.lock
COPY --chown=appuser:appgroup pyproject.toml /app/pyproject.toml
# Install dependencies
RUN uv sync --frozen --no-install-project
# Copy the project into the image
COPY --chown=appuser:appgroup . /app
# Sync the project
RUN uv sync --frozen
# Declare the volume for local cache storage
VOLUME ["/app/scratch"]
# Expose the port FastAPI will run on
EXPOSE 8000
ENV APP_DIR=/app/app
ENV ASSETS_DIR=/app/assets
# Command to run the application
CMD ["/bin/bash", "-c", "source .venv/bin/activate && uvicorn compose_api.api.main:app --host 0.0.0.0 --port 8000"]