-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerFile
More file actions
33 lines (25 loc) · 1.03 KB
/
DockerFile
File metadata and controls
33 lines (25 loc) · 1.03 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
# Multi-stage Dockerfile for building an Astro project and serving with nginx
FROM node:20-bullseye AS builder
WORKDIR /app
# Install Python and PHP interpreters for build-time component execution
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
php \
&& ln -s /usr/bin/python3 /usr/bin/python \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Use Corepack to enable pnpm (bundled with Node 20+)
RUN corepack enable && corepack prepare pnpm@latest --activate
# Install dependencies (use lockfile if present)
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --offline || pnpm install --frozen-lockfile
# Copy the rest of the source and build
COPY . .
RUN pnpm run build
FROM nginx:1.26-alpine AS runner
# Copy built static site from builder
COPY --from=builder /app/dist /usr/share/nginx/html
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 CMD wget -qO- http://localhost/ || exit 1
CMD ["nginx", "-g", "daemon off;"]