Skip to content

Commit

Permalink
run as non root user
Browse files Browse the repository at this point in the history
  • Loading branch information
lfunderburk authored May 18, 2023
1 parent 8a356dd commit 726aed1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use the official Python image as the base image
FROM python:3.10
FROM python:3.10 as builder

# Set the working directory
WORKDIR /app
Expand All @@ -8,8 +8,18 @@ WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# --- Runtime Stage ---
FROM python:3.10-slim

# Set the working directory
WORKDIR /app

# Add a non-root user
RUN useradd appuser && chown -R appuser /app
USER appuser

# Copy the rest of the application code
COPY . .
COPY --from=builder /app .

# Expose the port that the app runs on
EXPOSE 8000
Expand All @@ -24,4 +34,3 @@ RUN ploomber build

# Execute the script when the container starts
CMD ["uvicorn", "src.app.app:app", "--host", "0.0.0.0"]

0 comments on commit 726aed1

Please sign in to comment.