Skip to content

Commit

Permalink
added caddy setup for with or without SSL
Browse files Browse the repository at this point in the history
  • Loading branch information
akshat5302 committed Aug 26, 2024
1 parent de2cb6b commit 779a9c0
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ jobs:
- name: Build and Push Plane-Proxy to Docker Hub
uses: docker/build-push-action@v5.1.0
with:
context: ./nginx
file: ./nginx/Dockerfile
context: ./caddy
file: ./caddy/Dockerfile
platforms: ${{ env.BUILDX_PLATFORMS }}
tags: ${{ env.PROXY_TAG }}
push: true
Expand Down
32 changes: 32 additions & 0 deletions caddy/Caddyfile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
(plane_proxy) {
request_body {
max_size {$FILE_SIZE_LIMIT}
}

reverse_proxy /spaces/* space:3000

reverse_proxy /god-mode/* admin:3000

reverse_proxy /api/* api:8000

reverse_proxy /auth/* api:8000

reverse_proxy /{$BUCKET_NAME}/* plane-minio:9000

reverse_proxy /* web:3000
}

{
email {$CERT_EMAIL:admin@example.com}
acme_ca {$CERT_ACME_CA}
{$CERT_ACME_DNS}
servers {
max_header_size 5MB
client_ip_headers X-Forwarded-For X-Real-IP
trusted_proxies static {$TRUSTED_PROXIES:0.0.0.0/0}
}
}

{$SITE_ADDRESS} {
import plane_proxy
}
9 changes: 9 additions & 0 deletions caddy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM makeplane/caddy:latest

COPY ./Caddyfile.template /etc/caddy/Caddyfile

COPY ./caddy.sh /docker-entrypoint.sh

RUN chmod +x /docker-entrypoint.sh

CMD ["/docker-entrypoint.sh"]
4 changes: 4 additions & 0 deletions caddy/caddy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

export SITE_ADDRESS=$(if [ "$SSL" = "true" ]; then echo "${APP_DOMAIN}"; else echo "http://${APP_DOMAIN}"; fi)
exec caddy run --config /etc/caddy/Caddyfile
15 changes: 14 additions & 1 deletion deploy/selfhost/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ x-data-store-env: &data-store-env
BUCKET_NAME: ${BUCKET_NAME:-uploads}

x-proxy-env: &proxy-env
SSL: ${SSL:-false}
APP_DOMAIN: ${APP_DOMAIN:-localhost}
NGINX_PORT: ${NGINX_PORT:-80}
FILE_SIZE_LIMIT: ${FILE_SIZE_LIMIT:-5242880}
CERT_EMAIL: ${CERT_EMAIL:-akshatjain9782@gmail.com}
CERT_ACME_CA: ${CERT_ACME_CA:-}
LISTEN_HTTP_PORT: ${LISTEN_HTTP_PORT:-80}
LISTEN_HTTPS_PORT: ${LISTEN_HTTPS_PORT:-443}

x-app-env: &app-env
WEB_URL: ${WEB_URL:-http://localhost}
Expand Down Expand Up @@ -174,7 +180,11 @@ services:
pull_policy: if_not_present
restart: unless-stopped
ports:
- ${NGINX_PORT}:80
- ${LISTEN_HTTP_PORT:-80}:${LISTEN_HTTP_PORT:-80}
- ${LISTEN_HTTPS_PORT:-443}:${LISTEN_HTTPS_PORT:-443}
volumes:
- caddy_config:/config
- caddy_data:/data
environment:
<<: *proxy-env
depends_on:
Expand All @@ -190,3 +200,6 @@ volumes:
logs_worker:
logs_beat-worker:
logs_migrator:
caddy_config:
caddy_data:

0 comments on commit 779a9c0

Please sign in to comment.