-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerfile.j2
More file actions
93 lines (80 loc) · 4.27 KB
/
Copy pathContainerfile.j2
File metadata and controls
93 lines (80 loc) · 4.27 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
ARG BASE_VERSION=15
FROM ghcr.io/daemonless/base:${BASE_VERSION}
ARG FREEBSD_ARCH=amd64
ARG SYLVE_RELEASE=tip
ARG PACKAGES="sysutils/smartmontools sysutils/tmux ca_root_nss FreeBSD-zfs FreeBSD-ssh FreeBSD-pf FreeBSD-jail FreeBSD-ctl FreeBSD-dhclient FreeBSD-bhyve FreeBSD-acpi bhyve-firmware swtpm libvirt qemu-tools samba423 FreeBSD-iscsi FreeBSD-xz"
{%- if ports %}
ARG HEALTHCHECK_ENDPOINT="https://localhost:{{ ports[0].port }}/"
{%- else %}
ARG HEALTHCHECK_ENDPOINT="https://localhost:8181/"
{%- endif %}
ENV HEALTHCHECK_URL="${HEALTHCHECK_ENDPOINT}"
# --- Metadata (Injected by Generator) ---
LABEL org.opencontainers.image.title="{{ title }}" \
org.opencontainers.image.description="{{ description }}" \
org.opencontainers.image.source="{{ repo_url }}" \
org.opencontainers.image.url="{{ web_url }}" \
org.opencontainers.image.documentation="https://sylve.io/docs" \
org.opencontainers.image.licenses="AGPL-3.0-only" \
org.opencontainers.image.vendor="daemonless" \
org.opencontainers.image.authors="daemonless" \
io.daemonless.category="{{ category }}" \
{%- if ports %}
io.daemonless.port="{{ ports[0].port }}" \
{%- endif %}
{%- if volumes %}
io.daemonless.volumes="{{ volumes | map(attribute='path') | join(',') }}" \
{%- endif %}
io.daemonless.arch="${FREEBSD_ARCH}" \
io.daemonless.pkg-source="github" \
io.daemonless.upstream-mode="github" \
io.daemonless.upstream-url="https://github.com/AlchemillaHQ/Sylve" \
io.daemonless.healthcheck-url="${HEALTHCHECK_ENDPOINT}" \
io.daemonless.packages="${PACKAGES}"
# Install runtime packages
RUN pkg update && \
pkg install -y ${PACKAGES} && \
pkg clean -ay && \
rm -rf /var/cache/pkg/* /var/db/pkg/repos/*
# Fetch the upstream prebuilt binary instead of building from source. Sylve
# publishes native FreeBSD per-arch binaries (sylve-amd64 / sylve-arm64) on its
# rolling `tip` release, with the SvelteKit frontend already go:embed'd. This
# avoids the Go+npm build entirely -- notably the frontend, whose lightningcss
# dependency has no freebsd-arm64 package, so a source build can't produce arm64.
RUN fetch -o /usr/local/sbin/sylve \
"https://github.com/AlchemillaHQ/Sylve/releases/download/${SYLVE_RELEASE}/sylve-${FREEBSD_ARCH}" && \
chmod 0755 /usr/local/sbin/sylve
# Create version info and required runtime directories. The version is the one
# the binary itself reports (const Version in internal/cmd/root.go, e.g. 0.3.0),
# parsed out of `sylve --version`; falls back to "nightly" if that ever fails.
RUN SYLVE_VERSION="$(/usr/local/sbin/sylve --version 2>&1 | grep -oE 'v?[0-9]+\.[0-9]+\.[0-9]+' | tail -1 | tr -d v)" && \
: "${SYLVE_VERSION:=nightly}" && \
mkdir -p /usr/local/share/sylve && \
printf "Version: %s\nPackageAuthor: [daemonless](https://github.com/daemonless/daemonless)\n" "$SYLVE_VERSION" > /usr/local/share/sylve/version_info && \
mkdir -m 0755 -p /app /var/db/sylve /var/log/sylve && \
printf '%s\n' "$SYLVE_VERSION" > /app/version
# Copy service definition and init scripts
COPY root/ /
# Host-side setup materials. host-setup.sh is a self-contained host-prep script
# printed by `podman run <image> host-setup` (see the entrypoint wrapper below);
# the rest (hook, installer) support the extract-and-run flow.
COPY host/ /usr/local/share/sylve/host/
# Bake a runnable compose.yaml that `podman run <image> compose` prints. Strip
# the x-daemonless docs metadata so it's a clean deployment file, not the
# README source.
COPY compose.yaml /tmp/compose.yaml
RUN awk 'BEGIN{skip=0} /^x-daemonless:/{skip=1} /^services:/{skip=0} !skip' \
/tmp/compose.yaml > /usr/local/share/sylve/compose.yaml && rm /tmp/compose.yaml
# Make scripts executable
RUN chmod +x /etc/services.d/*/run /etc/cont-init.d/* /usr/local/share/sylve/host/*.sh 2>/dev/null || true
# Entrypoint wrapper: `podman run <image> host-setup` prints the host-prep
# script, `... compose` prints the compose.yaml; everything else boots Sylve.
ENTRYPOINT ["/usr/local/share/sylve/host/sylve-entrypoint.sh"]
# --- Expose (Injected by Generator) ---
{%- if ports %}
EXPOSE {{ ports | map(attribute='target') | join(' ') }}
{%- endif %}
# --- Volumes (Injected by Generator) ---
{%- if volumes %}
VOLUME {{ volumes | map(attribute='path') | join(' ') }}
{%- endif %}