-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
53 lines (40 loc) · 1.19 KB
/
Dockerfile
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
49
50
51
52
53
# Start from the base image
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim AS base
# Define build arguments and environment variables
ARG COMMIT_ID
ENV COMMIT_ID=${COMMIT_ID}
ARG BUILD_AT
ENV BUILD_AT=${BUILD_AT}
WORKDIR /app
# Create a non-privileged user for the app.
ARG UID=10001
RUN adduser \
--disabled-password \
--gecos "" \
--home "/home/appuser" \
--shell "/sbin/nologin" \
--uid "${UID}" \
appuser
# Install required packages
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
libmariadb-dev-compat \
libmariadb-dev \
curl \
pkg-config && \
rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Copy the source code into the container in the final stage
FROM base AS final
# Set working directory
WORKDIR /app
# Copy the source code into the container
COPY . .
RUN chown -R appuser:appuser /app
# Switch to the non-privileged user to run the application.
USER appuser
# Expose the port that the application listens on.
EXPOSE 8000
RUN uv sync
# Run the application
CMD ["uv", "run", "--with", "gunicorn", "gunicorn", "app:app", "--workers", "4", "--worker-class", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8000"]