Skip to content

Commit

Permalink
add caddy
Browse files Browse the repository at this point in the history
  • Loading branch information
FarisZR committed Oct 20, 2024
1 parent bd5da9e commit 10eda3a
Show file tree
Hide file tree
Showing 4 changed files with 247 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/caddy.yml
Original file line number Diff line number Diff line change
@@ -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@v4
with:
fetch-depth: 0

- name: Tailscale
uses: tailscale/github-action@7a0b30ed3517c2244d1330e39467b95f067a33bd
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
23 changes: 23 additions & 0 deletions caddy/Caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
email {env.EMAIL}
admin off
acme_dns cloudflare {env.CLOUDFLARE_TOKEN}
}
# generate cert for turn.aosus.org, but don't serve anything
turn.aosus.org {
abort
}

cups-g11.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
45 changes: 45 additions & 0 deletions caddy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: "3.7"

networks:
web:
external: true
discourse:
external: true

services:
caddy:
image: oci.fariszr.com/fariszr/caddy-dns:cloudflare-alpine@sha256:41257d70b1eb77d230c119560aedc145fc181b2d7cb0069e3fe56518c1ad1ab8
container_name: caddy
command: caddy run --watch --config /etc/caddy/Caddyfile --adapter caddyfile
cap_add:
- NET_ADMIN
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
networks:
web:
discourse:

configs:
Caddyfile:
file: /home/aosus/caddy/Caddyfile

volumes:
data:
config:
piped-proxy:
external:
name: piped_piped-proxy
132 changes: 132 additions & 0 deletions caddy/proxy_error_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<!doctype html>
<html lang="ar">

<head>
<div dir="RTL">
<meta charset="utf-8">
<meta http-equiv="refresh" content="60">
<title>هذه الخدمة غير متوفرة حاليا</title>
<style>
.center {
display: flex;
justify-content: center;
}

.container {
background: #ececec;
max-width: 500px;
padding: 50px 50px 30px 50px;
margin-top: 50px;
border-radius: 20px; /* Rounded corners */
}

.title {
padding-top: 20px;
}

h1,
p {
font-family: “Helvetica Neue”, Helvetica, Arial, sans-serif;
}

@keyframes spin {
from {
transform: rotate(0deg);
}

to {
transform: rotate(360deg);
}
}

.spinner {
animation: spin 2s infinite linear;
height: 30px;
width: 30px;
border: 4px solid #919191;
border-right-color: transparent;
border-radius: 50%;
margin-top: 20px;
}

/* Center the buttons */
.button-container {
display: flex;
justify-content: center;
align-items: center;
}

/* Style the buttons */
.button {
border: none; /* Remove border */
color: white; /* White text */
padding: 15px 32px; /* Add some padding */
text-align: center; /* Centered text */
text-decoration: none; /* Remove underline */
display: inline-block; /* Inline element */
font-size: 16px; /* Set a font size */
border-radius: 30px; /* Rounded corners */
box-shadow: 0 2px 5px 0 rgba(0,0,0,0.26); /* Add a shadow */
transition: 0.3s; /* Add a transition effect */
}

/* Change the button color on hover */
.button:hover {
box-shadow: 0 4px 10px 0 rgba(0,0,0,0.37); /* Bigger shadow */
}

/* Green button */
.green {
background-color: green; /* Green background */
}

/* Green button on hover */
.green:hover {
background-color: #66bb6a; /* Lighter green */
}

/* Cyan button */
.cyan {
background-color: #0088CC; /* Cyan background */
}

/* Cyan button on hover */
.cyan:hover {
background-color: #00aaff; /* Lighter cyan */
}

/* Add some margin between the buttons */
.button + .button {
margin: 10px;
}
</style>
</head>

<body>
<div class="center">
<div class="container">
<div class="center">
<img src="https://cdn-cf-discourse.aosus.org/original/2X/c/c3ea74b68d4f80fbf949a0b6989e44a1b33dce29.svg"
alt="Discourse logo" width="244" height="66">
</div>
<h1 class="title">هذه الخدمة غير متوفرة حاليا&hellip;</h1>
<div class="center">
<p>ربما يتم تحديثها او تواجه صعوبات تقنية <br />
تأكد من حالة خدمات مجتمع عبر الزر بالاسفل
</p>
</div>
<div class="button-container">
<a href="https://status.aosus.org" class="button green">حالة خدمات أسس</a>
<a href="https://t.me/aosus" class="button cyan"> أسس على التيليجرام</a>
</div>
<div class="center">
<p>الصفحة يتم تحديثها تلقائيا كل 60 ثانية</p>
</div>
<div class="center">
<div class="spinner"></div>
</div>
</div>
</div>
</body>

</html>

0 comments on commit 10eda3a

Please sign in to comment.