daelon-docs/Dockerfile

26 lines
1.1 KiB
Docker

FROM python:3.12-slim AS builder
RUN apt-get update \
&& apt-get install -y --no-install-recommends git ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
ARG FORGEJO_TOKEN=""
RUN if [ -n "$FORGEJO_TOKEN" ]; then \
git config --global url."https://x-access-token:${FORGEJO_TOKEN}@git.daelon.cloud/".insteadOf "https://git.daelon.cloud/"; \
fi \
&& mkdocs build --site-dir /site
FROM nginx:1.27-alpine
COPY --from=builder /site /usr/share/nginx/html
RUN printf 'server {\n listen 80 default_server;\n listen [::]:80 default_server;\n root /usr/share/nginx/html;\n index index.html;\n location / { try_files $uri $uri/ $uri.html =404; }\n location ~* \\.(js|css|woff2?|svg|png|jpg|jpeg|gif|ico)$ { expires 7d; access_log off; }\n gzip on;\n gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;\n gzip_min_length 1024;\n}\n' > /etc/nginx/conf.d/default.conf
EXPOSE 80