-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
36 lines (33 loc) · 1.2 KB
/
Dockerfile
File metadata and controls
36 lines (33 loc) · 1.2 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
# syntax=docker/dockerfile:1.7
# 1. Build Tailwind CSS
FROM node:20-alpine AS css
WORKDIR /src
RUN corepack enable
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile
COPY tailwind.config.js postcss.config.js ./
COPY assets ./assets
COPY layouts ./layouts
COPY content ./content
RUN yarn build:tailwind
# 2. Build the Hugo site
FROM debian:12-slim AS hugo
ARG HUGO_VERSION=0.161.1
ENV HUGO_ENV=production
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl gzip \
&& rm -rf /var/lib/apt/lists/* \
&& curl -fsSL "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.tar.gz" \
| tar -xz -C /usr/local/bin hugo \
&& chmod +x /usr/local/bin/hugo
WORKDIR /src
COPY . .
COPY --from=css /src/assets/css/main.css ./assets/css/main.css
RUN hugo --minify \
&& find public -type f \( -name '*.css' -o -name '*.js' -o -name '*.svg' -o -name '*.html' -o -name '*.xml' \) \
-exec gzip -kf {} +
# 3. Serve via nginx (unprivileged, runs as uid 101, listens on 8080)
FROM nginxinc/nginx-unprivileged:1.27-alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=hugo /src/public /usr/share/nginx/html
EXPOSE 8080