Skip to content

Commit

Permalink
fix: fixed security concern
Browse files Browse the repository at this point in the history
  • Loading branch information
creyD committed Nov 24, 2024
1 parent 63abb64 commit 35040f3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM python:3.12-slim
ARG VERSION=unknown

# Create a non-root user
RUN useradd appuser

WORKDIR /app
COPY . .

Expand All @@ -14,11 +17,17 @@ RUN pip install --no-cache-dir --upgrade -r requirements.txt

ENV ENV=DEV

# Switch to non-root user
USER appuser

EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

# Install curl
USER root
RUN apt-get update && apt-get install --no-install-recommends -y curl && apt-get clean

# Switch back to non-root user for healthcheck
USER appuser
HEALTHCHECK --interval=30s --timeout=10s --retries=5 \
CMD curl --fail http://localhost:8000/openapi.json || exit 1

0 comments on commit 35040f3

Please sign in to comment.