Skip to content

Commit d80ead8

Browse files
feature: seed default index page on empty volume
Adds an init container that writes a minimal landing page with the GEWIS logo on first deploy. The PVC is now organised with served content under site/ and a .initialized sentinel at the volume root; caddy and code-server mount via subPath: site so they cannot see or overwrite the sentinel. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 102e9df commit d80ead8

5 files changed

Lines changed: 55 additions & 1 deletion

File tree

Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.1.1
18+
version: 0.1.2
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to

templates/caddy-deployment.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,25 @@ spec:
1515
labels:
1616
{{- include "static-webhost.componentSelectorLabels" (dict "Context" . "Component" "caddy") | nindent 8 }}
1717
spec:
18+
initContainers:
19+
- name: seed-default-index
20+
image: "{{ .Values.caddy.image.repository }}:{{ .Values.caddy.image.tag }}"
21+
imagePullPolicy: {{ .Values.caddy.image.pullPolicy }}
22+
command:
23+
- sh
24+
- -c
25+
- |
26+
if [ ! -f /data/.initialized ]; then
27+
mkdir -p /data/site
28+
cp /defaults/index.html /data/site/index.html
29+
touch /data/.initialized
30+
fi
31+
volumeMounts:
32+
- name: data
33+
mountPath: /data
34+
- name: default-index
35+
mountPath: /defaults
36+
readOnly: true
1837
containers:
1938
- name: caddy
2039
image: "{{ .Values.caddy.image.repository }}:{{ .Values.caddy.image.tag }}"
@@ -26,6 +45,7 @@ spec:
2645
volumeMounts:
2746
- name: data
2847
mountPath: /srv
48+
subPath: site
2949
readOnly: true
3050
- name: caddyfile
3151
mountPath: /etc/caddy/Caddyfile
@@ -41,3 +61,6 @@ spec:
4161
- name: caddyfile
4262
configMap:
4363
name: {{ include "static-webhost.fullname" . }}-caddy
64+
- name: default-index
65+
configMap:
66+
name: {{ include "static-webhost.fullname" . }}-default-index

templates/code-server-deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ spec:
3232
volumeMounts:
3333
- name: data
3434
mountPath: /srv
35+
subPath: site
3536
{{- with .Values.codeServer.resources }}
3637
resources:
3738
{{- toYaml . | nindent 12 }}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "static-webhost.fullname" . }}-default-index
5+
labels:
6+
{{- include "static-webhost.labels" . | nindent 4 }}
7+
data:
8+
index.html: |
9+
<!doctype html>
10+
<html lang="en">
11+
<head>
12+
<meta charset="utf-8">
13+
<title>{{ index .Values.domains 0 }}</title>
14+
<style>
15+
html, body { margin: 0; height: 100%; }
16+
body { display: grid; place-items: center; background: #fff; font-family: system-ui, sans-serif; }
17+
img { width: 160px; height: 160px; }
18+
</style>
19+
</head>
20+
<body>
21+
<img src="{{ .Values.defaultPage.logoUrl }}" alt="GEWIS">
22+
</body>
23+
</html>

values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ oidc:
3333
# by emberstack reflector; this chart only mirrors the empty Secret shell.
3434
secretReflectsFrom: shared-secrets/oidc-auth
3535

36+
# Default landing page seeded into an empty volume on first deploy.
37+
# The seed init container writes index.html and a .initialized sentinel; once
38+
# the sentinel exists it's a no-op, so user edits via code-server survive
39+
# subsequent rollouts.
40+
defaultPage:
41+
logoUrl: https://github.com/GEWIS.png
42+
3643
# code-server (VS Code in the browser) — edits the shared volume.
3744
codeServer:
3845
image:

0 commit comments

Comments
 (0)