diff --git a/.goreleaser.yml b/.goreleaser.yml index 5eb92c0..7376eed 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -20,6 +20,24 @@ release: env: - CGO_ENABLED=0 builds: + - id: caddy + dir: caddy/vulcain + ldflags: + - -X 'github.com/caddyserver/caddy/v2.CustomVersion=Vulcain.rocks {{ .Version }} Caddy' + goos: + - linux + - darwin + - windows + goarch: + - "386" + - amd64 + - arm + - arm64 + goarm: + - "5" + - "6" + - "7" + # Legacy build - id: legacy dir: cmd/vulcain env: @@ -37,11 +55,28 @@ builds: - goos: darwin goarch: '386' archives: + - builds: + - caddy + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + files: + - COPYRIGHT + - LICENSE + - README.md + - Caddyfile + format_overrides: + - goos: windows + format: zip - id: legacy builds: - legacy name_template: >- - {{ .ProjectName }}_ + {{ .ProjectName }}-legacy_ {{- title .Os }}_ {{- if eq .Arch "amd64" }}x86_64 {{- else if eq .Arch "386" }}i386 @@ -56,9 +91,55 @@ archives: format: zip dockers: - ids: - - legacy + - caddy + goos: linux + goarch: amd64 + image_templates: + - "dunglas/vulcain:{{ .Tag }}-amd64" + - "dunglas/vulcain:v{{ .Major }}-amd64" + - "dunglas/vulcain:v{{ .Major }}.{{ .Minor }}-amd64" + - "dunglas/vulcain:latest-amd64" + use: buildx + build_flag_templates: + - "--platform=linux/amd64" + extra_files: + - Caddyfile + - ids: + - caddy + goos: linux + goarch: arm64 + image_templates: + - "dunglas/vulcain:{{ .Tag }}-arm64v8" + - "dunglas/vulcain:v{{ .Major }}-arm64v8" + - "dunglas/vulcain:v{{ .Major }}.{{ .Minor }}-arm64v8" + - "dunglas/vulcain:latest-arm64v8" + use: buildx + build_flag_templates: + - "--platform=linux/arm64/v8" + extra_files: + - Caddyfile + - ids: + - legacy + dockerfile: legacy.Dockerfile + image_templates: + - "dunglas/vulcain:legacy-{{ .Tag }}" + - "dunglas/vulcain:legacy-v{{ .Major }}" + - "dunglas/vulcain:legacy-v{{ .Major }}.{{ .Minor }}" + - "dunglas/vulcain:legacy-latest" +docker_manifests: + - name_template: dunglas/vulcain:{{ .Tag }} + image_templates: + - dunglas/vulcain:{{ .Tag }}-amd64 + - dunglas/vulcain:{{ .Tag }}-arm64v8 + - name_template: dunglas/vulcain:v{{ .Major }} + image_templates: + - dunglas/vulcain:v{{ .Major }}-amd64 + - dunglas/vulcain:v{{ .Major }}-arm64v8 + - name_template: dunglas/vulcain:v{{ .Major }}.{{ .Minor }} + image_templates: + - dunglas/vulcain:v{{ .Major }}.{{ .Minor }}-amd64 + - dunglas/vulcain:v{{ .Major }}.{{ .Minor }}-arm64v8 + - name_template: dunglas/vulcain:latest image_templates: - - 'dunglas/vulcain:{{ .Tag }}' - - 'dunglas/vulcain:v{{ .Major }}' - - 'dunglas/vulcain:v{{ .Major }}.{{ .Minor }}' - - 'dunglas/vulcain:latest' + - dunglas/vulcain:latest-amd64 + - dunglas/vulcain:latest-arm64v8 \ No newline at end of file diff --git a/Caddyfile b/Caddyfile new file mode 100644 index 0000000..fa8ef3d --- /dev/null +++ b/Caddyfile @@ -0,0 +1,20 @@ +{ + order vulcain before request_header + + {$CADDY_GLOBAL_OPTIONS} +} + +{$CADDY_EXTRA_CONFIG} + +{$SERVER_NAME:localhost} { + vulcain { + #openapi_file ../../fixtures/openapi.yaml + #max_pushes 0 + #early_hints + } + log + encode zstd gzip + reverse_proxy {env.VULCAIN_UPSTREAM} + + {$CADDY_SERVER_EXTRA_DIRECTIVES} +} diff --git a/Dockerfile b/Dockerfile index ef312d9..449a460 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM scratch -COPY vulcain / -CMD ["./vulcain"] -EXPOSE 80 443 +FROM caddy:2-alpine + +COPY vulcain /usr/bin/caddy +COPY Caddyfile /etc/caddy/Caddyfile diff --git a/docs/gateway/caddy.md b/docs/gateway/caddy.md index 42a5cfc..6610ec1 100644 --- a/docs/gateway/caddy.md +++ b/docs/gateway/caddy.md @@ -11,6 +11,18 @@ The Vulcain module for Caddy allows to turn any existing web API in a one suppor ## Install +### Docker + +The easiest way to get started is to use Docker: + +```console +docker run -e VULCAIN_UPSTREAM='http://your-api' -p 80:80 -p 443:443 dunglas/vulcain +``` + +The configuration file is located at `/etc/caddy/Caddyfile`. + +### Binaries + 1. Go on [the Caddy server download page](https://caddyserver.com/download) 2. Select the `github.com/dunglas/vulcain/caddy` module 3. Select other modules you're interested in such as [the cache module](https://github.com/caddyserver/cache-handler) or [Mercure](https://mercure.rocks) (optional) @@ -18,6 +30,8 @@ The Vulcain module for Caddy allows to turn any existing web API in a one suppor Alternatively, you can use [xcaddy](https://github.com/caddyserver/xcaddy) to create a custom build of Caddy containing the Vulcain module: `xcaddy build --with github.com/dunglas/vulcain/caddy` +Pre-built binaries are also available for download [on the releases page](https://github.com/dunglas/vulcain/releases). + ## Configuration Example configuration: @@ -37,6 +51,8 @@ example.com { } ``` +All other [Caddyfile directives](https://caddyserver.com/docs/caddyfile) are also supported. + ## Start the Server Just run `./caddy run`. diff --git a/docs/gateway/install.md b/docs/gateway/install.md index f06da7e..3d0f569 100644 --- a/docs/gateway/install.md +++ b/docs/gateway/install.md @@ -51,7 +51,7 @@ A Docker image is available on Docker Hub. The following command is enough to ge -v /your/tls/certs:/tls \ -e UPSTREAM='http://your-api' -e KEY_FILE='tls/key.pem' -e CERT_FILE='tls/cert.pem' \ -p 443:443 \ - dunglas/vulcain + dunglas/vulcain:legacy-latest The gateway is available on `https://localhost`. @@ -60,7 +60,7 @@ In production, run: docker run \ -e UPSTREAM='http://your-api' -e ACME_HOSTS='example.com' \ -p 80:80 -p 443:443 \ - dunglas/vulcain + dunglas/vulcain:legacy-latest Be sure to update the value of `ACME_HOSTS` to match your domain name(s), a Let's Encrypt TLS certificate will be automatically generated. diff --git a/docs/help.md b/docs/help.md index cebd4d2..829c424 100644 --- a/docs/help.md +++ b/docs/help.md @@ -9,8 +9,8 @@ [Les-Tilleuls.coop](https://les-tilleuls.coop) provides professional services for Vulcain including training, development and API design. -[Contact Les-Tilleuls.coop](https://les-tilleuls.coop/en/contact) for more information. +[Contact Les-Tilleuls.coop](https://les-tilleuls.coop/#contact) for more information. ## Training -[Masterclass](https://masterclass.les-tilleuls.coop) organizes official training sessions about the Mercure protocol (available in English and in French). +[Masterclass](https://les-tilleuls.coop/masterclass) organizes official training sessions about Vulcain (available in English and in French). diff --git a/legacy.Dockerfile b/legacy.Dockerfile new file mode 100644 index 0000000..8fbb81b --- /dev/null +++ b/legacy.Dockerfile @@ -0,0 +1,5 @@ +FROM gcr.io/distroless/static +COPY vulcain / +CMD ["/vulcain"] +EXPOSE 80 443 +