# Written by the inbuxa installer {{.Version}} for {{.Domain}}. # # This is the whole deployment. Bring it up again with `docker compose up -d` # from this directory. Secrets are in .env beside it and the administrator's # password is in credentials.txt -- both readable only by root. # {{- if .RemoteServerURL}} # The mail server is on another machine, {{.RemoteServerURL}}; these front # ends were joined to it with `inbuxa join`, which registered their addresses # with it. Nothing here holds mail. {{- else if .HostServer}} # The mail server runs on this machine under systemd (inbuxa-server.service), # not in this project. Its plain HTTP is on loopback only, which is why the # webmail and Caddy share the host's network: that is where they reach it, as # http://, a leg that never leaves this machine. {{- else}} # The mail server's plain HTTP port is published on loopback only and reached # over the private network below, which is why the front ends talk to it as # http://: that leg never leaves this machine. {{- end}} name: {{.Project}} services: {{- if .Server}} server: image: {{.ServerImage}} hostname: {{.MailHost}} restart: unless-stopped ports: - "{{.ServerBind}}:8080" {{- range .MailPorts}} - "{{.}}:{{.}}" {{- end}} volumes: # Where the image keeps its configuration and its data. Installs made # before this was corrected are moved over on their next run. - inbuxa-etc:/etc/inbuxa - inbuxa-data:/var/lib/inbuxa {{- if .CABundle}} # The system roots plus the private ACME CA, so the server can reach it. - ./ca-bundle.crt:/etc/ssl/certs/ca-certificates.crt:ro {{- end}} environment: # The front ends, which is what registers their OAuth clients and sets # the cross-origin allowlist (contract C-6 and C-14). The webmail's # secret is generated by the installer and given to both sides. {{- if .ConsoleURL}} INBUXA_ADMIN_URL: {{.ConsoleURL}} {{- end}} {{- if .WebmailURL}} INBUXA_WEBMAIL_URL: {{.WebmailURL}} INBUXA_WEBMAIL_CLIENT_SECRET: ${WEBMAIL_CLIENT_SECRET:?WEBMAIL_CLIENT_SECRET is missing from .env} {{- end}} {{- if .Local}} # Where a browser reaches the server, which is what its sign-in page # and OAuth metadata advertise. Without it they name https://, which a loopback-only install has nothing behind. INBUXA_PUBLIC_URL: {{.ServerPublicURL}} {{- end}} networks: stack: ipv4_address: {{.ServerIP}} {{- end}} {{- if .Console}} console: image: {{.ConsoleImage}} restart: unless-stopped {{- if .Server}} depends_on: [server] {{- end}} # Not read-only, unlike the webmail: this image writes the api-base-url # into index.html when it starts, which is what lets one image serve any # installation. A read-only root makes it restart forever instead. tmpfs: [/tmp, /var/cache/nginx, /var/run] ports: - "{{.ConsoleBind}}:8080" environment: # Written into index.html at start, so one image serves any # installation. The browser talks to the server directly from here. API_BASE_URL: {{.ServerPublicURL}} networks: stack: ipv4_address: {{.ConsoleIP}} {{- end}} {{- if .Webmail}} webmail: image: {{.WebmailImage}} restart: unless-stopped {{- if .Server}} depends_on: [server] {{- end}} # Immutable: read-only root, no volume, sessions in memory. A restart # signs everyone out; nothing else is lost, because nothing else is kept. read_only: true tmpfs: [/tmp] {{- if .WebmailOnHost}} # On the host's network, listening on loopback only, where it reaches # the server. network_mode: host {{- else}} ports: - "{{.WebmailBind}}:8080" {{- end}} environment: {{- if .WebmailOnHost}} HOST: 127.0.0.1 PORT: "8080" {{- end}} MAIL_SERVER_URL: {{.WebmailServerURL}} APP_SECRET: ${APP_SECRET:?APP_SECRET is missing from .env} APP_NAME: inbuxa IMMUTABLE: "1" SESSION_FILE: "" TRUST_PROXY: "1" IMAGE_PROXY: "1" # Sign-in goes through the mail server's own page, as the first-party # client the server registered for this URL -- on --local too: the # server takes a token, never a password, on /jmap (contract C-23), so # a webmail that signed people in with their password would have # nothing to pass it on with. OAUTH_CLIENT_ID: ihasmail-inbuxa OAUTH_CLIENT_SECRET: ${WEBMAIL_CLIENT_SECRET:?WEBMAIL_CLIENT_SECRET is missing from .env} PUBLIC_URL: {{.WebmailURL}} {{- if .ConsoleURL}} ADMIN_URL: {{.ConsoleURL}} {{- end}} {{- if not .Local}} # The server pushes changes here instead of holding a connection per # tab. If it cannot reach it, every tab falls back to the relay, which # is what --local does: from inside the server's container, 127.0.0.1 # is not the webmail. PUSH_URL: {{.WebmailURL}} {{- end}} {{- if not .WebmailOnHost}} networks: stack: ipv4_address: {{.WebmailIP}} {{- end}} {{- end}} {{- if .Proxy}} caddy: image: {{.CaddyImage}} restart: unless-stopped {{- if .Server}} depends_on: [server] {{- end}} {{- if .CaddyOnHost}} # On the host's network: it holds 80 and 443 itself, and reaches the # server, the webmail and the console on loopback. network_mode: host {{- else}} ports: - "80:80" - "443:443" - "443:443/udp" {{- end}} volumes: - ./Caddyfile:/etc/caddy/Caddyfile:ro - caddy-data:/data - caddy-config:/config {{- if .ConsoleFiles}} # The console, installed on the host as files, served from here. - {{.ConsoleFiles}}:/srv/console:ro {{- end}} {{- if .ACMECARoot}} - ./acme-ca-root.pem:/etc/caddy/acme-ca-root.pem:ro {{- end}} {{- if not .CaddyOnHost}} networks: stack: ipv4_address: {{.CaddyIP}} {{- end}} {{- end}} {{- if or .Server .Console (and .Webmail (not .WebmailOnHost)) (and .Proxy (not .CaddyOnHost))}} networks: stack: {{- if .IPv6Subnet}} # IPv6 as well, so a client that connects over IPv6 reaches the # containers with its own address. On an IPv4-only network Docker relays # those connections over IPv4, and every one arrives from the gateway. enable_ipv6: true {{- end}} ipam: config: - subnet: {{.Subnet}} {{- if .IPv6Subnet}} - subnet: {{.IPv6Subnet}} {{- end}} {{- end}} {{- if or .Server .Proxy}} volumes: {{- end}} {{- if .Server}} inbuxa-etc: inbuxa-data: {{- end}} {{- if .Proxy}} # Certificates and the ACME account. Losing this means asking for every # certificate again, which is how rate limits are reached. caddy-data: caddy-config: {{- end}}