-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
52 lines (37 loc) · 1.17 KB
/
Dockerfile
File metadata and controls
52 lines (37 loc) · 1.17 KB
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
49
50
51
52
# Build stage for CSS
FROM node:18-alpine AS css-builder
WORKDIR /app
COPY package.json package-lock.json tailwind.config.js ./
COPY app/static/input.css ./app/static/
COPY app/templates ./app/templates
RUN npm ci
RUN npm run build:css
# Final stage
FROM python:3.10-slim-bookworm
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
FLASK_APP=app \
PATH="/app/.venv/bin:$PATH"
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
# Copy Python dependencies
COPY pyproject.toml uv.lock ./
# Sync dependencies
# We use --frozen to ensure strict consistency with the lockfile
RUN uv sync --frozen --no-dev
# Copy application code
COPY . .
# Copy built CSS from css-builder
COPY --from=css-builder /app/app/static/css/style.css ./app/static/css/style.css
# Create necessary directories
RUN mkdir -p data app/static/uploads
# Create a non-root user
RUN useradd -m appuser && chown -R appuser:appuser /app
USER appuser
EXPOSE 8000
CMD ["gunicorn", "--workers", "4", "--bind", "0.0.0.0:8000", "run:app"]