Attempt at caddyfile/proxy, simplification

The idea of proxying in front of Garage may be warranted, to handle some
of the ways that it subdomains further. However, I'm not there yet.
This commit is contained in:
Matt Jadud
2025-12-07 07:56:09 -05:00
parent 42105c4f5c
commit 9f25c1cb09
9 changed files with 74 additions and 35 deletions

View File

@@ -5,18 +5,20 @@
"healthCheckPath": "/health", "healthCheckPath": "/health",
"multiDomain": true, "multiDomain": true,
"httpPort": 3900, "httpPort": 3900,
"httpPorts": { "tcpPorts": {
"GARAGE_WEB": { "GARAGE_WEB": {
"title": "Garage web server domain", "title": "Garage web server domain",
"description": "Buckets as static sites can be found here", "description": "Web port",
"defaultValue": 3902,
"containerPort": 3902, "containerPort": 3902,
"defaultValue": "web" "portCount": 1
}, },
"GARAGE_ADMIN": { "GARAGE_ADMIN": {
"title": "Garage Admin API Domain", "title": "Admin port",
"description": "For administering the Garage instance remotely", "description": "Admin port",
"defaultValue": 3903,
"containerPort": 3903, "containerPort": 3903,
"defaultValue": "admin" "portCount": 1
} }
}, },
"addons": { "addons": {

View File

@@ -1,5 +1,8 @@
FROM cloudron/base:5.0.0 FROM cloudron/base:5.0.0
RUN apt-get update ; apt-get install -y \
caddy
# Garage wants these directories for storing stuff. # Garage wants these directories for storing stuff.
# We want it here so that /app/data gets backed up. # We want it here so that /app/data gets backed up.
RUN mkdir -p /app/data/garage/data /app/data/garage/meta RUN mkdir -p /app/data/garage/data /app/data/garage/meta
@@ -8,6 +11,8 @@ ADD https://garagehq.deuxfleurs.fr/_releases/v2.1.0/x86_64-unknown-linux-musl/ga
RUN chmod 755 /usr/bin/garage RUN chmod 755 /usr/bin/garage
COPY garage.toml /garage/garage.toml COPY garage.toml /garage/garage.toml
COPY caddyfile /garage/caddyfile
# Create a symlink that will become dead; we'll fill it again # Create a symlink that will become dead; we'll fill it again
# with the startup script. # with the startup script.
RUN ln -s /app/data/garage.toml /etc/garage.toml RUN ln -s /app/data/garage.toml /etc/garage.toml

View File

@@ -1,19 +0,0 @@
FROM cloudron/base:5.0.0
# Garage wants these directories for storing stuff.
# We want it here so that /app/data gets backed up.
RUN mkdir -p /app/data/garage/data /app/data/garage/meta
ADD https://garagehq.deuxfleurs.fr/_releases/VERSION/x86_64-unknown-linux-musl/garage /usr/bin/garage
RUN chmod 755 /usr/bin/garage
COPY garage.toml /garage/garage.toml
# Create a symlink that will become dead; we'll fill it again
# with the startup script.
RUN ln -s /app/data/garage.toml /etc/garage.toml
COPY start.bash /garage/start.bash
RUN chmod 755 /garage/start.bash
CMD [ "/garage/start.bash" ]

View File

@@ -3,8 +3,8 @@ VERSION?=v2.1.0
IMAGE?=garage:latest IMAGE?=garage:latest
DOMAIN?=garage DOMAIN?=garage
templates: test-build:
VERSION="${VERSION}" DOMAIN="${DOMAIN}" ./process-templates.bash docker build -t garage:latest .
build: templates build: templates
cloudron build cloudron build
@@ -15,5 +15,8 @@ install: build uninstall
--secondary-domains \ --secondary-domains \
GARAGE_WEB="web.${DOMAIN}",GARAGE_ADMIN="admin.${DOMAIN}" GARAGE_WEB="web.${DOMAIN}",GARAGE_ADMIN="admin.${DOMAIN}"
update:
cloudron update
uninstall: uninstall:
cloudron uninstall --app "${DOMAIN}" cloudron uninstall --app "${DOMAIN}"

View File

@@ -123,6 +123,14 @@ make build DOMAIN=<domain>
This runs `cloudron build`, and may (on first run) request a path to a registry. You can configure a private registry on your own Cloudron for this purpose. You need to pass the Cloudron domain here, so that the manifest can be set up correctly. This runs `cloudron build`, and may (on first run) request a path to a registry. You can configure a private registry on your own Cloudron for this purpose. You need to pass the Cloudron domain here, so that the manifest can be set up correctly.
For extended iteration
```
export DOMAIN=<domain>
```
will allow `make build ; make update` as a repeated sequence.
``` ```
<registry-domain>/<username>/<package-name> <registry-domain>/<username>/<package-name>

38
caddyfile Normal file
View File

@@ -0,0 +1,38 @@
{
debug
}
# I feel like a proxy in front of Garage (within the container)
# would let me redirect `/health` from the TLD through to the admin API,
# which is the only place the healthcheck URL exists. But, Cloudron has no notion
# of the healthcheck being somewhere else.
# https://garagehq.deuxfleurs.fr/documentation/cookbook/reverse-proxy/
s3.garage.tld, *.s3.garage.tld {
reverse_proxy localhost:3900 {
health_uri /health
health_port 3903
#health_interval 15s
#health_timeout 5s
}
}
# These would need to be templated, I think, so they match the domain
# that is coming in to the container.
*.web.garage.tld {
reverse_proxy localhost:3902 {
health_uri /health
health_port 3903
#health_interval 15s
#health_timeout 5s
}
}
admin.garage.tld {
reverse_proxy localhost:3903 {
health_uri /health
health_port 3903
#health_interval 15s
#health_timeout 5s
}
}

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env bash
sed -e 's/VERSION/'"${VERSION}"'/g' Dockerfile.template > Dockerfile

View File

@@ -19,6 +19,9 @@ if [[ ! -f /app/data/.initialized ]]; then
# If the end-user moves the domain... this will break. # If the end-user moves the domain... this will break.
sed -e 's/CLOUDRON_APP_DOMAIN/'"${CLOUDRON_APP_DOMAIN}"'/g' /garage/garage.toml > /app/data/garage.toml sed -e 's/CLOUDRON_APP_DOMAIN/'"${CLOUDRON_APP_DOMAIN}"'/g' /garage/garage.toml > /app/data/garage.toml
# For redirecting /health to admin.DOMAIN/health
sed -e 's/CLOUDRON_APP_DOMAIN/'"${CLOUDRON_APP_DOMAIN}"'/g' /garage/caddyfile > /app/data/caddyfile
# Generate an RPC secret file. This is used for clusters. # Generate an RPC secret file. This is used for clusters.
# We don't have clusters, but garage wantses it. # We don't have clusters, but garage wantses it.
# It is precious to garage. # It is precious to garage.
@@ -30,4 +33,6 @@ fi
# Chown the things and run. # Chown the things and run.
chown -R cloudron:cloudron /app/data/garage chown -R cloudron:cloudron /app/data/garage
# gosu cloudron:cloudron caddy run --config /app/data/caddyfile --adapter caddyfile &
gosu cloudron:cloudron /usr/bin/garage server gosu cloudron:cloudron /usr/bin/garage server

View File

@@ -1,5 +1,5 @@
garage status garage status
garage layout assign -z home -c 1G d785aad03f42dd47 garage layout assign -z home -c 1G 8e20b876358d1f32
garage layout show garage layout show
garage layout apply --version 1 garage layout apply --version 1
garage bucket create site garage bucket create site