-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
45 lines (33 loc) · 932 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
##### Base Stage #####
FROM python:3.12-slim-bookworm AS base
# Set default path
ENV PATH="/app/.venv/bin:${PATH}"
##### Builder Stage #####
FROM base AS builder
# Set default workdir
WORKDIR /app
# Create virtualenv and install Python packages
RUN pip install --no-cache-dir pip -U && \
pip install --no-cache-dir uv
COPY ./uv.lock uv.lock
COPY ./pyproject.toml pyproject.toml
RUN uv sync --no-dev --frozen
# Copy app files to workdir
COPY secure_qrcode ./secure_qrcode
COPY templates ./templates
COPY static ./static
##### Final Stage #####
FROM base
# Copy content from builder stage
COPY --from=builder /app /app
# Add qrcode user and create directories
RUN useradd -m qrcode
# Set permissions
RUN chown -R qrcode:qrcode /app
# Set workdir and user
WORKDIR /app
USER qrcode
# Expose port
EXPOSE 8000
# Set entrypoint and cmd
ENTRYPOINT ["uvicorn", "--host", "0.0.0.0", "--port", "8000", "secure_qrcode.api:app"]