forked from fengyuanluo/firemail
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
76 lines (59 loc) · 1.9 KB
/
Dockerfile
File metadata and controls
76 lines (59 loc) · 1.9 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# --- Frontend Builder Stage ---
FROM node:22-alpine AS frontend-builder
# Copy frontend files
COPY frontend /app/frontend
# Build frontend
WORKDIR /app/frontend
RUN corepack enable pnpm && \
pnpm install && \
pnpm install dayjs && \
pnpm build
# --- Python Dependencies Stage ---
FROM python:3.10.17-slim-bullseye AS python-deps
# Install build dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements file
COPY backend/requirements.txt /requirements.txt
# Install Python dependencies
RUN pip install --no-cache-dir -r /requirements.txt
# --- Final Stage ---
FROM python:3.10.17-slim-bullseye
# Environment variables
ENV HOST=0.0.0.0 \
FLASK_PORT=5000 \
WS_PORT=8765 \
FRONTEND_PORT=3000 \
TZ=Asia/Shanghai \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
curl \
bash \
&& rm -rf /var/lib/apt/lists/*
# Install Caddy using binary download
RUN curl -L "https://github.com/caddyserver/caddy/releases/download/v2.7.6/caddy_2.7.6_linux_amd64.tar.gz" -o caddy.tar.gz \
&& tar -xzf caddy.tar.gz \
&& mv caddy /usr/local/bin/ \
&& chmod +x /usr/local/bin/caddy \
&& rm caddy.tar.gz
# Copy Python packages from python-deps stage
COPY --from=python-deps /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
COPY --from=python-deps /usr/local/bin /usr/local/bin
# Copy frontend build from frontend-builder stage
COPY --from=frontend-builder /app/frontend/dist /app/frontend/dist
# Copy backend files
COPY backend /app/backend
COPY Caddyfile /app/
# Copy and set permissions for startup script
COPY docker-entrypoint.sh /app/
RUN chmod +x /app/docker-entrypoint.sh
# Set working directory
WORKDIR /app
# Expose port
EXPOSE 80
# Startup command
ENTRYPOINT ["/bin/bash", "/app/docker-entrypoint.sh"]