-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (35 loc) · 1002 Bytes
/
Dockerfile
File metadata and controls
48 lines (35 loc) · 1002 Bytes
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
46
47
48
##### Base Stage #####
FROM ubuntu:24.04 AS base
# Set default path
ENV PATH="/app/.venv/bin:${PATH}"
ENV UV_PYTHON_INSTALL_DIR="/app/"
##### Builder Stage #####
FROM base AS builder
# Set default workdir
WORKDIR /app
# Create virtualenv and install Python packages
COPY --from=docker.io/astral/uv:latest /uv /bin/
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
# Compile all Python source files to bytecode
RUN python -m compileall -f .
##### 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"]