fix(docker): run as non-root user (appuser:1000), use requirements.txt

This commit is contained in:
2026-04-13 17:59:08 +00:00
parent 79230d62a2
commit b34d4062a4

View File

@@ -2,19 +2,17 @@ FROM python:3.12-slim
WORKDIR /app WORKDIR /app
RUN apt-get update \ RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg && rm -rf /var/lib/apt/lists/*
&& apt-get install -y --no-install-recommends ffmpeg \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --no-cache-dir \ COPY requirements.txt .
fastapi \ RUN pip install --no-cache-dir -r requirements.txt
uvicorn \
myjdapi \
paramiko \
python-multipart
COPY app.py /app/app.py RUN useradd -m -u 1000 appuser && chown appuser:appuser /app
COPY static /app/static
USER appuser
COPY --chown=appuser:appuser app.py .
COPY --chown=appuser:appuser static ./static
EXPOSE 8080 EXPOSE 8080
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080"] CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080"]