So, an earlier discussion noted the limitations of Eel regarding not being able to edit after uploading them via create custom app, inability to use .env files, and, needing to keep Dockerfiles elsewhere via a full path build context. I have solved all that, for the way I want to do it at least. Let’s see if anyone likes.
Here is a caddy reverse proxy setup with custom plugins (porkbun dns and labels) where I illustrate:
Dockerfile:
FROM caddy:2.8-builder AS builder
RUN xcaddy build \
--with github.com/caddy-dns/porkbun \
--with github.com/lucaslorentz/caddy-docker-proxy/v2
FROM caddy:2.8
EXPOSE 80 443
COPY --from=builder /usr/bin/caddy /usr/bin/caddy
RUN apk add --no-cache tzdata
CMD ["caddy", "docker-proxy"]
Compose file:
services:
caddy:
restart: always
env_file: .env
ports:
- name: Reverse Proxy Ingress
target: 443
published: "443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /mnt/tank/Data/Caddy/Config:/config
- /mnt/tank/Data/Caddy/Data:/data
labels:
caddy_0.email: "{env.EMAIL}"
caddy_0.acme_dns: porkbun
caddy_0.acme_dns.api_key: "{env.PORKBUN_API_KEY}"
caddy_0.acme_dns.api_secret_key: "{env.PORKBUN_API_SECRET_KEY}"
caddy_1: (encode)
caddy_1.encode: zstd gzip
caddy_2: "localhost:80, localhost"
caddy_2.root: "* /usr/share/caddy"
caddy_2.file_server:
build:
context: .
healthcheck:
test: ["CMD-SHELL", "wget --no-verbose -T3 --spider http://localhost:80 || exit 1"]
interval: 1m
timeout: 10s
retries: 3
start_period: 30s
start_interval: 5s
pull_policy: missing
networks:
- Caddy
networks:
Caddy:
name: fatula
external: true
So, how you say does that work? I use include! So, on the custom app creation screen, app name is caddy. and the compose file is simply:
include:
- /fullpathtocomposefile
Now, there is no need to edit the compose file in the UI as the compose file is in somedir on the NAS. Since env files and dockerfiles are relative to the compose file, those work fine in the same fullpathtocomposefile dir (somedir). Note that compose specifies env_file: .env so it knows what dir. And the build context is . so same somedir. This also allows me to use the same exact files on another machine to develop them, no paths to change. So, compose.yml, .env, Dockerfile all in one dir somewhere on the NAS.
This gets around not being able to simply use .env files in the UI custom app creator, or to easily do custom builds.
The reason same files on another machine is important to me is I develop them on a non Truenas machine for testing (desktop). I don’t have to want to have to change the files to test it.