Repository navigation
Expand file tree
/
Copy pathDockerfile.static
More file actions
47 lines (45 loc) · 2.04 KB
/
Copy pathDockerfile.static
File metadata and controls
47 lines (45 loc) · 2.04 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
# syntax=docker/dockerfile:1
# Dockerfile.static - Lightweight container for static PWA version
#
# This container packages the static/offline version of eXeLearning (PWA)
# using nginx:alpine (~8MB) to facilitate deployment without a backend.
#
# Features:
# - No database, no backend, no real-time collaboration
# - Works fully offline after initial load
# - Ideal for demos, quick deployments, or CDN distribution
#
# Usage:
# docker build -f Dockerfile.static -t exelearning:static --build-arg VERSION=v3.0.0 .
# docker run -p 8080:80 exelearning:static
FROM oven/bun:alpine AS builder
WORKDIR /app
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile
COPY . .
ARG VERSION=latest
RUN bun run build:static -- --version=${VERSION}
FROM nginx:alpine
# nginx has the gzip module built in but leaves it off, so dist/static's
# JavaScript, CSS, JSON and SVG assets are served uncompressed. Both JavaScript
# types are listed on purpose: nginx's own mime.types maps .js to
# application/javascript, while mime-extra.conf below maps .mjs to
# text/javascript. text/html is always compressed and needs no entry.
COPY <<'EOF' /etc/nginx/conf.d/gzip.conf
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/javascript application/javascript application/json text/css image/svg+xml text/xml application/xml text/plain;
EOF
# nginx's bundled mime.types has no entry for several extensions we serve and
# falls back to application/octet-stream, which browsers reject for ES modules.
COPY docker/nginx/mime-extra.conf /etc/nginx/conf.d/mime-extra.conf
COPY --from=builder /app/dist/static /usr/share/nginx/html
LABEL org.opencontainers.image.title="eXeLearning Static" \
org.opencontainers.image.description="eXeLearning PWA - Static version" \
org.opencontainers.image.vendor="eXeLearning" \
org.opencontainers.image.licenses="AGPL-3.0" \
org.opencontainers.image.source="https://github.com/exelearning/exelearning"
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -qO- http://localhost/ || exit 1