feat: replace Traefik with Caddy
- Add templates for the Caddy installation. - Replace Traefik with Caddy for both dev and prod.
This commit is contained in:
parent
0fd1f05fd7
commit
0490fc6568
5 changed files with 114 additions and 1 deletions
2
config
2
config
|
@ -1 +1 @@
|
||||||
Subproject commit 830827da9e0cd82f93e493074fbbad464c3a1ec4
|
Subproject commit 4bcd59b35e78780e43a22c641517697bfc345dc7
|
|
@ -16,6 +16,7 @@ type Config struct {
|
||||||
RootDomain string `json:"rootDomain"`
|
RootDomain string `json:"rootDomain"`
|
||||||
FlowGID int32 `json:"flowGID"`
|
FlowGID int32 `json:"flowGID"`
|
||||||
Docker Docker `json:"docker"`
|
Docker Docker `json:"docker"`
|
||||||
|
Caddy Caddy `json:"caddy"`
|
||||||
Traefik Traefik `json:"traefik"`
|
Traefik Traefik `json:"traefik"`
|
||||||
Forgejo Forgejo `json:"forgejo"`
|
Forgejo Forgejo `json:"forgejo"`
|
||||||
GoToSocial Gotosocial `json:"gotosocial"`
|
GoToSocial Gotosocial `json:"gotosocial"`
|
||||||
|
@ -33,6 +34,25 @@ type DockerNetwork struct {
|
||||||
Subnet string `json:"subnet"`
|
Subnet string `json:"subnet"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Caddy struct {
|
||||||
|
Version string `json:"version"`
|
||||||
|
ContainerName string `json:"containerName"`
|
||||||
|
ContainerIpv4Address string `json:"containerIpv4Address"`
|
||||||
|
ConfigHostDirectory string `json:"configHostDirectory"`
|
||||||
|
ConfigContainerDirectory string `json:"configContainerDirectory"`
|
||||||
|
DataHostDirectory string `json:"dataHostDirectory"`
|
||||||
|
DataContainerDirectory string `json:"dataContainerDirectory"`
|
||||||
|
GracePeriod string `json:"gracePeriod"`
|
||||||
|
TLS CaddyTLS `json:"tls"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CaddyTLS struct {
|
||||||
|
AcmeEmail string `json:"acmeEmail"`
|
||||||
|
UseCustomCertificates bool `json:"useCustomCertificates"`
|
||||||
|
HostDirectory string `json:"hostDirectory"`
|
||||||
|
ContainerDirectory string `json:"containerDirectory"`
|
||||||
|
}
|
||||||
|
|
||||||
type Traefik struct {
|
type Traefik struct {
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
CheckNewVersion bool `json:"checkNewVersion"`
|
CheckNewVersion bool `json:"checkNewVersion"`
|
||||||
|
|
43
templates/caddy/Caddyfile.gotmpl
Normal file
43
templates/caddy/Caddyfile.gotmpl
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
{
|
||||||
|
admin off
|
||||||
|
grace_period {{ .Caddy.GracePeriod }}
|
||||||
|
{{- if .Caddy.TLS.UseCustomCertificates -}}
|
||||||
|
{{ print "" }}
|
||||||
|
local_certs
|
||||||
|
skip_install_trust
|
||||||
|
auto_https disable_certs
|
||||||
|
{{- end -}}
|
||||||
|
{{ print "" }}
|
||||||
|
{{- if not .Caddy.TLS.UseCustomCertificates -}}
|
||||||
|
{{ print "" }}
|
||||||
|
email {{ .Caddy.TLS.AcmeEmail }}
|
||||||
|
{{- end -}}
|
||||||
|
{{ print "" }}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{ .RootDomain }} {
|
||||||
|
{{- if .Caddy.TLS.UseCustomCertificates -}}
|
||||||
|
{{ print "" }}
|
||||||
|
tls {{ .Caddy.TLS.ContainerDirectory}}/caddy.crt {{ .Caddy.TLS.ContainerDirectory }}/caddy.key
|
||||||
|
{{- end -}}
|
||||||
|
{{ print "" }}
|
||||||
|
reverse_proxy {{ .Landing.ContainerIpv4Address }}:{{ .Landing.Port }}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{ .Forgejo.Subdomain }}.{{ .RootDomain }} {
|
||||||
|
{{- if .Caddy.TLS.UseCustomCertificates -}}
|
||||||
|
{{ print "" }}
|
||||||
|
tls {{ .Caddy.TLS.ContainerDirectory}}/caddy.crt {{ .Caddy.TLS.ContainerDirectory }}/caddy.key
|
||||||
|
{{- end -}}
|
||||||
|
{{ print "" }}
|
||||||
|
reverse_proxy {{ .Forgejo.ContainerIpv4Address }}:{{ .Forgejo.HttpPort }}
|
||||||
|
}
|
||||||
|
|
||||||
|
{{ .GoToSocial.Subdomain }}.{{ .RootDomain }} {
|
||||||
|
{{- if .Caddy.TLS.UseCustomCertificates -}}
|
||||||
|
{{ print "" }}
|
||||||
|
tls {{ .Caddy.TLS.ContainerDirectory}}/caddy.crt {{ .Caddy.TLS.ContainerDirectory }}/caddy.key
|
||||||
|
{{- end -}}
|
||||||
|
{{ print "" }}
|
||||||
|
reverse_proxy {{ .GoToSocial.ContainerIpv4Address }}:{{ .GoToSocial.Port }}
|
||||||
|
}
|
9
templates/caddy/Dockerfile.gotmpl
Normal file
9
templates/caddy/Dockerfile.gotmpl
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# syntax=docker/dockerfile:1
|
||||||
|
FROM caddy:{{ .Caddy.Version }}-alpine
|
||||||
|
|
||||||
|
RUN --mount=type=bind,source=.,target=/packages \
|
||||||
|
mkdir -p {{ .Caddy.DataContainerDirectory }} {{ .Caddy.ConfigContainerDirectory }} {{ if .Caddy.TLS.UseCustomCertificates }}{{ .Caddy.TLS.ContainerDirectory }}{{ end }} \
|
||||||
|
&& cp /packages/Caddyfile /etc/caddy/Caddyfile
|
||||||
|
|
||||||
|
ENV XDG_CONFIG_HOME {{ .Caddy.ConfigContainerDirectory }}
|
||||||
|
ENV XDG_DATA_HOME {{ .Caddy.DataContainerDirectory }}
|
|
@ -20,6 +20,47 @@ networks:
|
||||||
- subnet: "{{ .Docker.Network.Subnet }}"
|
- subnet: "{{ .Docker.Network.Subnet }}"
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
# -- Edge flow --
|
||||||
|
caddy:
|
||||||
|
container_name: "{{ .Caddy.ContainerName }}"
|
||||||
|
image: "localhost/flow/caddy:{{ .Caddy.Version }}"
|
||||||
|
build:
|
||||||
|
context: "../caddy"
|
||||||
|
networks:
|
||||||
|
flow:
|
||||||
|
ipv4_address: "{{ .Caddy.ContainerIpv4Address }}"
|
||||||
|
ports:
|
||||||
|
- target: 80
|
||||||
|
published: 80
|
||||||
|
protocol: "tcp"
|
||||||
|
mode: "host"
|
||||||
|
- target: 443
|
||||||
|
published: 443
|
||||||
|
protocol: "tcp"
|
||||||
|
mode: "host"
|
||||||
|
- target: 443
|
||||||
|
published: 443
|
||||||
|
protocol: "udp"
|
||||||
|
mode: "host"
|
||||||
|
restart: "always"
|
||||||
|
volumes:
|
||||||
|
{{- template "defaultVolumes" }}
|
||||||
|
# Caddy data volume
|
||||||
|
- type: "bind"
|
||||||
|
source: "{{ .Caddy.DataHostDirectory }}"
|
||||||
|
target: "{{ .Caddy.DataContainerDirectory }}"
|
||||||
|
# Caddy config volume
|
||||||
|
- type: "bind"
|
||||||
|
source: "{{ .Caddy.ConfigHostDirectory }}"
|
||||||
|
target: "{{ .Caddy.ConfigContainerDirectory }}"
|
||||||
|
{{- if .Caddy.TLS.UseCustomCertificates -}}
|
||||||
|
{{ print "" }}
|
||||||
|
# Caddy TLS volume
|
||||||
|
- type: "bind"
|
||||||
|
source: "{{ .Caddy.TLS.HostDirectory }}"
|
||||||
|
target: "{{ .Caddy.TLS.ContainerDirectory }}"
|
||||||
|
{{- end -}}
|
||||||
|
{{ print "" }}
|
||||||
# -- Traffic flow --
|
# -- Traffic flow --
|
||||||
traefik:
|
traefik:
|
||||||
container_name: "{{ .Traefik.ContainerName }}"
|
container_name: "{{ .Traefik.ContainerName }}"
|
||||||
|
|
Loading…
Reference in a new issue