Skip to content

Commit

Permalink
Add cloudflare support to docker with Caddy
Browse files Browse the repository at this point in the history
  • Loading branch information
rmartinoscar committed Oct 16, 2024
1 parent 6507548 commit 8e48822
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .github/docker/Caddyfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
admin off
email {$ADMIN_EMAIL}
}

{$APP_URL} {
Expand All @@ -9,4 +8,9 @@

php_fastcgi 127.0.0.1:9000
file_server

tls {
dns cloudflare {$CLOUDFLARE_API_TOKEN}
}

}
17 changes: 17 additions & 0 deletions .github/docker/Caddyfile_ssl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
admin off
email {$ADMIN_EMAIL}
}

{$APP_URL} {
root * /var/www/html/public
encode gzip

php_fastcgi 127.0.0.1:9000
file_server

tls {
dns cloudflare {$CLOUDFLARE_API_TOKEN}
}

}
4 changes: 3 additions & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ on:
push:
tags:
- "v*"

release:
types:
- published
jobs:
build-and-push:
name: Build and Push
Expand Down
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ RUN yarn config set network-timeout 300000 \
&& yarn install --frozen-lockfile \
&& yarn run build:production

FROM caddy:builder AS xcaddy
RUN xcaddy build \
--with github.com/caddy-dns/cloudflare

FROM php:8.3-fpm-alpine
# FROM --platform=$TARGETOS/$TARGETARCH php:8.3-fpm-alpine

ENV CADDY_ADMIN=off
ENV [email protected]

COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

Expand All @@ -28,6 +31,9 @@ RUN apk update && apk add --no-cache \
caddy ca-certificates supervisor \
&& docker-php-ext-install bcmath gd intl zip opcache pcntl posix pdo_mysql

# Copy the binary with plugins
COPY --from=xcaddy /usr/bin/caddy /usr/sbin/caddy

# Copy the Caddyfile to the container
COPY .github/docker/Caddyfile /etc/caddy/Caddyfile

Expand Down
1 change: 1 addition & 0 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ x-common:
&panel-environment
APP_URL: "https://localhost" # can be set to 'http://localhost' on port 80 only
ADMIN_EMAIL: "[email protected]"
CLOUDFLARE_API_TOKEN: "" # see https://pelican.dev/docs/guides/ssl#obtaining-cloudflare-api-token

APP_DEBUG: "false"
APP_ENVIRONMENT_ONLY: "false"
Expand Down

0 comments on commit 8e48822

Please sign in to comment.