-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (37 loc) · 1.52 KB
/
Dockerfile
File metadata and controls
54 lines (37 loc) · 1.52 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
# syntax=docker/dockerfile:1.7
ARG HUGO_VERSION=v0.161.1
ARG UV_VERSION=0.11.16
# Stage 1: preprocess BibTeX into Hugo data.
FROM ghcr.io/astral-sh/uv:${UV_VERSION} AS uv
FROM python:3.12-alpine AS bibtex-builder
COPY --from=uv /uv /uvx /bin/
WORKDIR /work
# Only copy what the preprocessing step needs.
COPY assets/bibliographies/publications.bib ./publications.bib
COPY .github/scripts/bibtex_to_json.py ./scripts/bibtex_to_json.py
RUN --mount=type=cache,target=/root/.cache/uv \
mkdir -p ./data && \
uv run ./scripts/bibtex_to_json.py \
--input ./publications.bib \
--output ./data/publications.json
# Stage 2: local dev Hugo server.
FROM ghcr.io/gohugoio/hugo:${HUGO_VERSION}
COPY --from=uv /uv /uvx /bin/
LABEL maintainer="CoMSES Net <support@comses.net>"
USER root
RUN git config --global --add safe.directory /src
# Install Node.js/npm for PostCSS, Go, and Python for repo maintenance scripts.
# python3 is required for uv to create a venv when running scripts with inline metadata.
RUN apk add --no-cache nodejs npm go python3
# Install front-end tooling.
COPY package.json package-lock.json /tmp/
RUN --mount=type=cache,target=/root/.npm \
cd /tmp && npm ci
ENV PATH="/tmp/node_modules/.bin:${PATH}"
WORKDIR /src
# Copy the site source after dependency installation for better layer reuse.
COPY . .
# Overwrite any checked-in data file with the generated one.
RUN mkdir -p /src/data
COPY --from=bibtex-builder /work/data/publications.json /src/data/publications.json
CMD ["server", "--bind", "0.0.0.0"]