update:
Some checks failed
Backend EC - Modal Deployment / notify-deploy (push) Has been cancelled
Backend EC - Modal Deployment / build-and-push (push) Has been cancelled
Deploy CD Server / deploy (push) Failing after 19s

This commit is contained in:
DatTT127
2026-07-19 18:01:48 +07:00
parent 15437a5f18
commit f84d30264f
2 changed files with 26 additions and 10 deletions

View File

@@ -1,17 +1,33 @@
FROM python:3.12-slim
# Stage 1: Builder
FROM python:3.12-slim AS builder
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY main.py config.py docker_ops.py schemas.py config.yaml ./
# Simply downloads the pre-compiled wheels from PyPI without needing a compiler
RUN pip wheel --no-cache-dir --wheel-dir=/app/wheels -r requirements.txt
RUN groupadd -g 998 docker || true
RUN useradd -m -u 998 -g docker appuser
# Stage 2: Final Runtime
FROM python:3.12-slim
WORKDIR /app
# 1. Setup system user first (Cached forever because it doesn't rely on files)
RUN groupadd -g 998 docker || true \
&& useradd -l -m -u 998 -g docker appuser
# 2. Bring in the wheels
COPY --from=builder /app/wheels /app/wheels
# 3. Install dependencies (Only runs if requirements.txt changed)
RUN pip install --no-cache-dir --no-index --find-links=/app/wheels /app/wheels/*.whl \
&& rm -rf /app/wheels
# 4. Copy code files
COPY --chown=appuser:docker main.py config.py docker_ops.py schemas.py config.yaml ./
USER appuser
EXPOSE 3333
CMD ["python", "main.py"]
CMD ["python", "main.py"]