Skip to content

Commit

Permalink
Update .env.example with CADDY_ORIGIN_URL and CADDY_ORIGIN_DOMAIN_CHE…
Browse files Browse the repository at this point in the history
…CK_URL, set CADDY_ORIGIN_URL to http://origin-server.com and CADDY_ORIGIN_DOMAIN_CHECK_URL to http://origin-server/api/domainCheck, and update CADDY_POWERDNS_SERVER_URL to http://pdns-api-server.com:8081. Additionally, update Caddyfile with http_port set to 80 and https_port set to 443, and update reverse_proxy to use {$CADDY_ORIGIN_URL}. Finally, update docker-compose.yml with CADDY_ORIGIN_URL and CADDY_ORIGIN_DOMAIN_CHECK_URL environment variables, set CADDY_ORIGIN_URL to localhost:9000, and update port mappings to forward to 80 and 443.
  • Loading branch information
nsouto committed Oct 30, 2023
1 parent 344c4b5 commit a4f2450
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 76 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/caddy-octane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ jobs:
fail-fast: false
matrix:
build:
- {tag: "8.0-cli-buster", platforms: "linux/arm/v7,linux/arm64,linux/amd64"}
- {tag: "8.0.26-cli-buster", platforms: "linux/arm/v7,linux/arm64,linux/amd64"}
- {tag: "8.1-cli-buster", platforms: "linux/arm/v7,linux/arm64,linux/amd64"}
- {tag: "8.1.13-cli-buster", platforms: "linux/arm/v7,linux/arm64,linux/amd64"}
- {tag: "8.2-cli-buster", platforms: "linux/arm/v7,linux/arm64,linux/amd64"}
- {tag: "latest", platforms: "linux/arm/v7,linux/arm64,linux/amd64"}
- {tag: "8.0-cli-buster", caddy-tag: "2.7", caddy-builder-tag: "2.7", platforms: "linux/arm/v7,linux/arm64,linux/amd64"}
- {tag: "8.0.26-cli-buster", caddy-tag: "2.7", caddy-builder-tag: "2.7", platforms: "linux/arm/v7,linux/arm64,linux/amd64"}
- {tag: "8.1-cli-buster", caddy-tag: "2.7", caddy-builder-tag: "2.7", platforms: "linux/arm/v7,linux/arm64,linux/amd64"}
- {tag: "8.1.13-cli-buster", caddy-tag: "2.7", caddy-builder-tag: "2.7", platforms: "linux/arm/v7,linux/arm64,linux/amd64"}
- {tag: "8.2-cli-buster", caddy-tag: "2.7", caddy-builder-tag: "2.7", platforms: "linux/arm/v7,linux/arm64,linux/amd64"}
- {tag: "latest", caddy-tag: "2.7", caddy-builder-tag: "2.7", platforms: "linux/arm/v7,linux/arm64,linux/amd64"}
steps:
- name: Check out code
uses: actions/checkout@v3
Expand Down Expand Up @@ -84,4 +84,9 @@ jobs:
context: "{{defaultContext}}:${{ env.APP_NAME }}"
platforms: ${{ matrix.build.platforms }}
push: true
tags: ${{ env.ORG_NAME }}/${{ env.APP_NAME }}:${{ matrix.build.tag }}
tags: ${{ env.ORG_NAME }}/${{ env.APP_NAME }}:${{ matrix.build.tag }}
args:
"OCTANE_TAG=${{ matrix.build.tag }}"
"CADDY_TAG=${{ matrix.build.caddy-tag }}"
"CADDY_BUILDER_TAG=${{ matrix.build.caddy-builder-tag }}"
"CADDY_ORIGIN_URL=${{ env.CADDY_ORIGIN_URL }}"
36 changes: 26 additions & 10 deletions caddy-octane/.env.example
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
## Caddy / Octane Tags
OCTANE_TAG=latest
CADDY_TAG=latest
CADDY_BUILDER_TAG=latest

## Caddy Reverse Proxy Configuration
CADDY_ORIGIN_URL=http://origin-server.com
CADDY_ORIGIN_DOMAIN_CHECK_URL=http://origin-server/api/domainCheck

## LetsEncrypt
CADDY_LETS_ENCRYPT_EMAIL=

## PowerDNS Integration
CADDY_POWERDNS_SERVER_URL=http://pdns-api-server.com:8081
CADDY_POWERDNS_API_TOKEN=

## AWS DynamoDB Integration
CADDY_DYNAMODB_TABLE_NAME=caddy_certs
CADDY_DYNAMODB_AWS_REGION=us-east-1
CADDY_DYNAMODB_AWS_ENDPOINT=dynamodb:8000
CADDY_DYNAMODB_AWS_ACCESS_KEY_ID=abc123
CADDY_DYNAMODB_AWS_SECRET_ACCESS_KEY=abc123

## Local Ports
FORWARD_CADDY_ADMIN_PORT=2019
FORWARD_CADDY_HTTP_PORT=2080
FORWARD_CADDY_HTTPS_PORT=2443
FORWARD_APP_PORT=9000

CADDY_DOMAIN_API_CHECK_URL=
CADDY_POWERDNS_SERVER_URL=
CADDY_POWERDNS_API_TOKEN=
CADDY_LETS_ENCRYPT_EMAIL=
CADDY_DYNAMODB_TABLE_NAME=
CADDY_AWS_REGION=
CADDY_AWS_ACCESS_KEY_ID=
CADDY_AWS_SECRET_ACCESS_KEY=
FORWARD_DYNAMODB_PORT=8000
FORWARD_APP_PORT=9001
24 changes: 6 additions & 18 deletions caddy-octane/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
ARG OCTANE_TAG=latest
ARG CADDY_TAG=latest
ARG CADDY_BUILDER_TAG=builder

FROM caddy:builder AS builder

Expand All @@ -15,23 +17,9 @@ FROM lostlink/octane:${OCTANE_TAG}

LABEL maintainer="Nuno Souto <[email protected]>"

ARG CADDY_DOMAIN_API_CHECK_URL
ARG CADDY_POWERDNS_SERVER_URL
ARG CADDY_POWERDNS_API_TOKEN
ARG CADDY_LETS_ENCRYPT_EMAIL
ARG CADDY_DYNAMODB_TABLE_NAME
ARG CADDY_AWS_REGION
ARG CADDY_AWS_ACCESS_KEY_ID
ARG CADDY_AWS_SECRET_ACCESS_KEY

ENV DOMAIN_API_CHECK_URL=${CADDY_DOMAIN_API_CHECK_URL}
ENV POWERDNS_SERVER_URL=${CADDY_POWERDNS_SERVER_URL}
ENV POWERDNS_API_TOKEN=${CADDY_POWERDNS_API_TOKEN}
ENV LETS_ENCRYPT_EMAIL=${CADDY_LETS_ENCRYPT_EMAIL}
ENV DYNAMODB_TABLE_NAME=${CADDY_DYNAMODB_TABLE_NAME}
ENV AWS_REGION=${CADDY_AWS_REGION}
ENV AWS_ACCESS_KEY_ID=${CADDY_AWS_ACCESS_KEY_ID}
ENV AWS_SECRET_ACCESS_KEY=${CADDY_AWS_SECRET_ACCESS_KEY}
ARG CADDY_ORIGIN_URL

ENV CADDY_ORIGIN_URL=${CADDY_ORIGIN_URL}

RUN apt-get update; \
apt-get upgrade -yqq; \
Expand All @@ -46,4 +34,4 @@ COPY --from=builder /usr/bin/caddy /usr/bin/caddy
COPY ./etc/supervisor/ /etc/supervisor/
COPY ./etc/caddy/ /etc/caddy/

EXPOSE 2080 2443 2019 9000
EXPOSE 80 443 2019 9000
40 changes: 23 additions & 17 deletions caddy-octane/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,35 @@ volumes:
mysql:

services:
# TODO: Add Local dynamodb for easy offline setup
# dynamodb:
dynamodb:
image: amazon/dynamodb-local
ports:
- "${FORWARD_DYNAMODB_PORT:-8000}:${DYNAMODDB_PORT:-8000}"

caddy-octane:
build:
context: .
hostname: caddy-octane.domainlink.test
# TODO: Enable dynamodb dependency once the service is added to the compose file
# depends_on:
# - dynamodb
args:
- OCTANE_TAG=${OCTANE_TAG}
- CADDY_TAG=${CADDY_TAG}
- CADDY_BUILDER_TAG=${CADDY_BUILDER_TAG}
depends_on:
- dynamodb
environment:
- DOMAIN_API_CHECK_URL=${CADDY_DOMAIN_API_CHECK_URL}
- POWERDNS_SERVER_URL=${CADDY_POWERDNS_SERVER_URL}
- POWERDNS_API_TOKEN=${CADDY_POWERDNS_API_TOKEN}
- LETS_ENCRYPT_EMAIL=${CADDY_LETS_ENCRYPT_EMAIL}
- DYNAMODB_TABLE_NAME=${CADDY_DYNAMODB_TABLE_NAME}
- AWS_REGION=${CADDY_AWS_REGION}
- AWS_ACCESS_KEY_ID=${CADDY_AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${CADDY_AWS_SECRET_ACCESS_KEY}
- CADDY_ORIGIN_URL=${CADDY_ORIGIN_URL}
- CADDY_ORIGIN_DOMAIN_CHECK_URL=${CADDY_ORIGIN_DOMAIN_CHECK_URL}
- CADDY_LETS_ENCRYPT_EMAIL=${CADDY_LETS_ENCRYPT_EMAIL}
- CADDY_POWERDNS_SERVER_URL=${CADDY_POWERDNS_SERVER_URL}
- CADDY_POWERDNS_API_TOKEN=${CADDY_POWERDNS_API_TOKEN}
- CADDY_DYNAMODB_TABLE_NAME=${CADDY_DYNAMODB_TABLE_NAME}
- CADDY_DYNAMODB_AWS_REGION=${CADDY_DYNAMODB_AWS_REGION}
- CADDY_DYNAMODB_AWS_ENDPOINT=${CADDY_DYNAMODB_AWS_ENDPOINT}
- AWS_ACCESS_KEY_ID=${CADDY_DYNAMODB_AWS_ACCESS_KEY_ID}
- AWS_SECRET_ACCESS_KEY=${CADDY_DYNAMODB_AWS_SECRET_ACCESS_KEY}
ports:
- "${FORWARD_CADDY_ADMIN_PORT:-2019}:${CADDY_ADMIN_PORT:-2019}"
- "${FORWARD_CADDY_HTTP_PORT:-2080}:${CADDY_HTTP_PORT:-2080}"
- "${FORWARD_CADDY_HTTPS_PORT:-2443}:${CADDY_HTTPS_PORT:-2443}"
- "${FORWARD_APP_PORT:-9000}:${OCTANE_APP_PORT:-9000}"
- "${FORWARD_CADDY_HTTP_PORT:-2080}:${CADDY_HTTP_PORT:-80}"
- "${FORWARD_CADDY_HTTPS_PORT:-2443}:${CADDY_HTTPS_PORT:-443}"
- "${FORWARD_APP_PORT:-9001}:${OCTANE_APP_PORT:-9000}"
volumes:
- /etc/localtime:/etc/localtime:ro
19 changes: 8 additions & 11 deletions caddy-octane/etc/caddy/Caddyfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
{
http_port 2080
https_port 2443
http_port 80
https_port 443

on_demand_tls {
ask {$CADDY_DOMAIN_API_CHECK_URL}
ask {$CADDY_ORIGIN_DOMAIN_CHECK_URL}
}

storage dynamodb {$CADDY_DYNAMODB_TABLE_NAME} {
aws_region {$CADDY_AWS_REGION}
aws_region {$CADDY_DYNAMODB_AWS_REGION}
}
}

:2080 {
reverse_proxy localhost:9000
}

:2443 {
tls {$LETS_ENCRYPT_EMAIL} {
## TODO: Allow configuring multiple origin URL/Servers
: {
tls {$CADDY_LETS_ENCRYPT_EMAIL} {
on_demand
dns powerdns {$CADDY_POWERDNS_SERVER_URL} {$CADDY_POWERDNS_API_TOKEN}
}

reverse_proxy localhost:9000
reverse_proxy {$CADDY_ORIGIN_URL}
}
7 changes: 4 additions & 3 deletions caddy/.env.example
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
## Caddy Version
CADDY_TAG=latest
CADDY_BUILDER_TAG=latest

## Caddy Reverse Proxy Configuration
CADDY_ORIGIN_URL=
CADDY_ORIGIN_DOMAIN_CHECK_URL=
CADDY_ORIGIN_URL=http://origin-server.com
CADDY_ORIGIN_DOMAIN_CHECK_URL=http://origin-server/api/domainCheck

## LetsEncrypt
CADDY_LETS_ENCRYPT_EMAIL=

## PowerDNS Integration
CADDY_POWERDNS_SERVER_URL=
CADDY_POWERDNS_SERVER_URL=http://pdns-api-server.com:8081
CADDY_POWERDNS_API_TOKEN=

## AWS DynamoDB Integration
Expand Down
15 changes: 5 additions & 10 deletions docker.env
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ REDIS_TAG=latest
COMPOSER_TAG=latest
MEILISEARCH_TAG=latest
OCTANE_TAG=latest
CADDY_TAG=latest
CADDY_BUILDER_TAG=latest

## Caddy Origin URL ##
CADDY_ORIGIN_URL=localhost:9000

## Software Versions ##
NODE_VERSION=lts.x
Expand All @@ -20,16 +25,6 @@ WWWGROUP=1000
ENABLE_HORIZON=false
ENABLE_SCHEDULER=false

## Caddy ##
CADDY_DOMAIN_API_CHECK_URL=
CADDY_POWERDNS_SERVER_URL=
CADDY_POWERDNS_API_TOKEN=
CADDY_LETS_ENCRYPT_EMAIL=
CADDY_DYNAMODB_TABLE_NAME=caddy_certs
CADDY_AWS_REGION=us-east-1
CADDY_AWS_ACCESS_KEY_ID=
CADDY_AWS_SECRET_ACCESS_KEY=

## PHP Extensions ##
SWOOLE_SERVER=swoole
INCLUDE_NPM=true
Expand Down

0 comments on commit a4f2450

Please sign in to comment.