Repository navigation
Expand file tree
/
Copy pathContainerfile
More file actions
68 lines (61 loc) · 3.7 KB
/
Copy pathContainerfile
File metadata and controls
68 lines (61 loc) · 3.7 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# --------------------------------------------------------------------------
# THIS FILE IS AUTOGENERATED - DO NOT EDIT MANUALLY
#
# Source: Containerfile.j2
# --------------------------------------------------------------------------
ARG NGINX_TAG=pkg-latest
FROM ghcr.io/daemonless/nginx:${NGINX_TAG}
ARG FREEBSD_ARCH=amd64
ARG PACKAGES="ca_root_nss"
ARG UPSTREAM_URL="https://api.github.com/repos/storytold/gridcraft/releases/latest"
ARG UPSTREAM_JQ=".tag_name"
ARG FONTS_URL="https://github.com/storytold/craft-fonts/archive/refs/heads/main.tar.gz"
LABEL org.opencontainers.image.title="GridCraft" \
org.opencontainers.image.description="Open-source, clean-room spreadsheet in Rust, served as a WebAssembly web app on FreeBSD." \
org.opencontainers.image.source="https://github.com/daemonless/gridcraft" \
org.opencontainers.image.url="https://getartcraft.com/apps/gridcraft" \
org.opencontainers.image.documentation="https://github.com/storytold/gridcraft" \
org.opencontainers.image.licenses="MIT OR Apache-2.0" \
org.opencontainers.image.vendor="daemonless" \
org.opencontainers.image.authors="daemonless" \
io.daemonless.category="Productivity" \
io.daemonless.port="80" \
io.daemonless.arch="${FREEBSD_ARCH}" \
io.daemonless.base="nginx" \
io.daemonless.upstream-url="${UPSTREAM_URL}" \
io.daemonless.upstream-jq="${UPSTREAM_JQ}" \
io.daemonless.packages="${PACKAGES}"
# The web release is a static WebAssembly site (index.html + .js/.wasm), no server code.
# Some releases ship cargo build leftovers (.fingerprint, build, deps) and .br files nginx
# cannot serve; drop them. Precompress the rest so nginx gzip_static sends ~40% of the raw wasm.
# craft-fonts (Japanese, Chinese, Arabic; each OFL-1.1) are served next to the app: it reads
# fonts/manifest.txt and fetches a family the first time it is picked or a document needs it.
# The API is rate-limited on shared CI runners (403, empty version); fall back to the
# tag that github.com/.../releases/latest redirects to.
RUN pkg update && pkg install -y ${PACKAGES} && \
VERSION=$(fetch -qo - "${UPSTREAM_URL}" | jq -r "${UPSTREAM_JQ}" | sed 's/^v//') && \
if [ -z "${VERSION}" ] || [ "${VERSION}" = "null" ]; then \
VERSION=$(fetch -v -o /dev/null "https://github.com/storytold/gridcraft/releases/latest" 2>&1 | sed -n 's|^.*redirect to .*/releases/tag/v\{0,1\}||p' | head -1); \
fi && \
if [ -z "${VERSION}" ]; then echo "ERROR: could not resolve the release version" >&2; exit 1; fi && \
echo "Installing GridCraft web ${VERSION}" && \
fetch -qo /tmp/gridcraft-web.zip "https://github.com/storytold/gridcraft/releases/download/v${VERSION}/gridcraft-web-${VERSION}.zip" && \
unzip -q /tmp/gridcraft-web.zip -d /tmp/gridcraft-web && \
mkdir -p /usr/local/www/app /app && \
mv /tmp/gridcraft-web/gridcraft-web-${VERSION}/* /usr/local/www/app/ && \
rm -rf /tmp/gridcraft-web /tmp/gridcraft-web.zip && \
cd /usr/local/www/app && \
rm -rf _headers build deps examples incremental *.br *.gz && \
fetch -qo /tmp/craft-fonts.tar.gz "${FONTS_URL}" && \
mkdir -p /usr/local/www/app/fonts && \
tar -xzf /tmp/craft-fonts.tar.gz --strip-components=2 -C /usr/local/www/app/fonts '*/fonts/*' && \
rm /tmp/craft-fonts.tar.gz && \
find /usr/local/www/app -type f \( -name '*.wasm' -o -name '*.js' -o -name '*.html' -o -name '*.ttf' -o -name '*.otf' \) -exec gzip -9 -k {} \; && \
echo "${VERSION}" > /app/version && chmod a+r /app/version && \
chown -R bsd:bsd /usr/local/www/app && \
pkg clean -ay && \
rm -rf /var/cache/pkg/* /var/db/pkg/repos/*
COPY root/ /
# nginx -t leaves its pid and temp dirs, root-owned, in /tmp.
RUN nginx -t && rm -rf /tmp/*
EXPOSE 80