diff --git a/.github/workflows/caddy.yml b/.github/workflows/caddy.yml new file mode 100644 index 0000000..d9e2e8a --- /dev/null +++ b/.github/workflows/caddy.yml @@ -0,0 +1,47 @@ +name: deploy-caddy + +on: + push: + paths: + - '.github/workflows/caddy.yml' + - 'caddy/**' + branches: [main] + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Tailscale + uses: tailscale/github-action@65cdd9a05d7ebe4ef4e8c70141f5d84e1cd4cab4 + with: + oauth-client-id: ${{ secrets.TAILSCALE_CLIENT_ID }} + oauth-secret: ${{ secrets.TAILSCALE_SECRET }} + tags: tag:deploy-ci + hostname: Github-actions + version: ${{ vars.TAILSCALE_VERSION }} + + - name: Add secrets to config files + env: + CLOUDFLARE_TOKEN: ${{ secrets.cloudflare_token }} + EMAIL: ${{ secrets.email }} + run: | + sed -i "s|(email)|$EMAIL|g" $GITHUB_WORKSPACE/caddy/docker-compose.yml + sed -i "s|(cloudflare_token)|$CLOUDFLARE_TOKEN|g" $GITHUB_WORKSPACE/caddy/docker-compose.yml + + - name: Start Deployment + uses: FarisZR/docker-compose-gitops-action@v1.0.1 + env: + EMAIL: ${{ secrets.email }} + with: + remote_docker_host: ${{ secrets.server_address }} + tailscale_ssh: true # no need for manual private and public keys + compose_file_path: caddy/docker-compose.yml + args: -p caddy up -d --remove-orphans + upload_directory: true + docker_compose_directory: caddy \ No newline at end of file diff --git a/caddy/Caddyfile b/caddy/Caddyfile new file mode 100644 index 0000000..aef767e --- /dev/null +++ b/caddy/Caddyfile @@ -0,0 +1,25 @@ +{ + email {env.EMAIL} + admin off + acme_dns cloudflare { + token {env.CLOUDFLARE_TOKEN} + } +} +# generate cert for turn.aosus.org, but don't serve anything +turn.aosus.org { + abort +} + +mail.aosus.org { + tls { + key_type rsa4096 + } + abort +} + +www.aosus.org { + redir https://aosus.org{uri} + header Cache-Control "max-age=2592000, stale-while-revalidate=2592000" +} + +import /etc/caddy/configs/*.caddyfile diff --git a/caddy/docker-compose.yml b/caddy/docker-compose.yml new file mode 100644 index 0000000..d2d642b --- /dev/null +++ b/caddy/docker-compose.yml @@ -0,0 +1,43 @@ +version: "3.7" + +networks: + web: + external: true + discourse: + external: true + +services: + caddy: + image: oci.fariszr.com/caddy-dns:cloudflare-alpine + container_name: caddy + restart: always + ports: + - "80:80" + - "443:443" + - "443:443/udp" + environment: + - EMAIL=(email) + - CLOUDFLARE_TOKEN=(cloudflare_token) + configs: + - source: Caddyfile + target: /etc/caddy/Caddyfile + volumes: + - /home/aosus/caddy/configs:/etc/caddy/configs:ro + - /home/aosus/caddy/proxy_error_page.html:/srv/proxy_error_page.html:ro + - data:/data + - config:/config + - piped-proxy:/var/run/ytproxy + networks: + web: + discourse: + +configs: + Caddyfile: + file: /home/aosus/caddy/Caddyfile + +volumes: + data: + config: + piped-proxy: + external: + name: piped_piped-proxy \ No newline at end of file diff --git a/caddy/proxy_error_page.html b/caddy/proxy_error_page.html new file mode 100644 index 0000000..f301fdb --- /dev/null +++ b/caddy/proxy_error_page.html @@ -0,0 +1,132 @@ + + + +
+ربما يتم تحديثها او تواجه صعوبات تقنية
+ تأكد من حالة خدمات مجتمع عبر الزر بالاسفل
+
الصفحة يتم تحديثها تلقائيا كل 60 ثانية
+