-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dockerfile
73 lines (58 loc) · 1.86 KB
/
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
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
# Build stage
FROM node:20-slim AS builder
# Set environment variables for build
ENV NODE_ENV=production \
NPM_CONFIG_UPDATE_NOTIFIER=false \
NPM_CONFIG_FUND=false \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
WORKDIR /app
# Install Python and build dependencies
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
python3-setuptools \
python3-wheel \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Copy only the files needed for installation
COPY package*.json tsconfig*.json ./
# Install dependencies
RUN npm ci --include=dev
# Copy source code and configs
COPY src ./src
COPY Caddyfile ./Caddyfile
COPY postcss.config.js ./postcss.config.js
COPY tailwind.config.js ./tailwind.config.js
COPY vite.config.ts ./vite.config.ts
COPY index.html ./index.html
# Build the application
RUN npm run build
# Production stage
FROM node:20-slim AS runner
# Set environment variables
ENV NODE_ENV=production \
NPM_CONFIG_UPDATE_NOTIFIER=false \
NPM_CONFIG_FUND=false
# Install Caddy
RUN apt-get update && apt-get install -y \
curl \
debian-keyring \
debian-archive-keyring \
apt-transport-https \
&& curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg \
&& curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list \
&& apt-get update \
&& apt-get install -y caddy \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy only the built files and Caddyfile from builder
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/Caddyfile ./Caddyfile
# Format Caddyfile
RUN caddy fmt --overwrite Caddyfile
# Expose ports
EXPOSE 80 443
# Start Caddy
CMD ["caddy", "run", "--config", "Caddyfile", "--adapter", "caddyfile"]