Merge pull request 'refactor: Standardize user creation in Dockerfile and improve multi-stage build syntax' (#11) from ph4 into prod
Reviewed-on: #11
This commit is contained in:
commit
c90ee6b73f
@ -1,5 +1,5 @@
|
|||||||
# Multi-stage build for production
|
# Multi-stage build for production
|
||||||
FROM python:alpine as base
|
FROM python:alpine AS base
|
||||||
|
|
||||||
# Set environment variables
|
# Set environment variables
|
||||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||||
@ -16,11 +16,12 @@ RUN apk add --no-cache \
|
|||||||
postgresql-dev \
|
postgresql-dev \
|
||||||
curl
|
curl
|
||||||
|
|
||||||
# Create non-root user
|
# Create non-root user (Alpine Linux style)
|
||||||
RUN groupadd -r appuser && useradd -r -g appuser appuser
|
RUN addgroup -g 1001 -S appuser && \
|
||||||
|
adduser -u 1001 -S appuser -G appuser
|
||||||
|
|
||||||
# Development stage
|
# Development stage
|
||||||
FROM base as development
|
FROM base AS development
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY requirements.txt .
|
COPY requirements.txt .
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
@ -30,7 +31,7 @@ USER appuser
|
|||||||
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
|
||||||
|
|
||||||
# Production stage
|
# Production stage
|
||||||
FROM base as production
|
FROM base AS production
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install production dependencies
|
# Install production dependencies
|
||||||
|
Loading…
Reference in New Issue
Block a user