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",
"multiDomain": true,
"httpPort": 3900,
"httpPorts": {
"tcpPorts": {
"GARAGE_WEB": {
"title": "Garage web server domain",
"description": "Buckets as static sites can be found here",
"description": "Web port",
"defaultValue": 3902,
"containerPort": 3902,
"defaultValue": "web"
"portCount": 1
},
"GARAGE_ADMIN": {
"title": "Garage Admin API Domain",
"description": "For administering the Garage instance remotely",
"title": "Admin port",
"description": "Admin port",
"defaultValue": 3903,
"containerPort": 3903,
"defaultValue": "admin"
"portCount": 1
}
},
"addons": {

View File

@@ -1,5 +1,8 @@
FROM cloudron/base:5.0.0
RUN apt-get update ; apt-get install -y \
caddy
# 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
@@ -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
COPY garage.toml /garage/garage.toml
COPY caddyfile /garage/caddyfile
# 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

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
DOMAIN?=garage
templates:
VERSION="${VERSION}" DOMAIN="${DOMAIN}" ./process-templates.bash
test-build:
docker build -t garage:latest .
build: templates
cloudron build
@@ -15,5 +15,8 @@ install: build uninstall
--secondary-domains \
GARAGE_WEB="web.${DOMAIN}",GARAGE_ADMIN="admin.${DOMAIN}"
update:
cloudron update
uninstall:
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.
For extended iteration
```
export DOMAIN=<domain>
```
will allow `make build ; make update` as a repeated sequence.
```
<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.
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.
# We don't have clusters, but garage wantses it.
# It is precious to garage.
@@ -30,4 +33,6 @@ fi
# Chown the things and run.
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

View File

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