Skip to content

Commit fa2e7db

Browse files
bianchidotdevbianchidotdev
authored andcommitted
Add anubis and deploy to fly (#3)
Reviewed-on: https://codeberg.org/bianchidotdev/bianchi.dev/pulls/3 Co-authored-by: Bianchi <m@bianchi.dev> Co-committed-by: Bianchi <m@bianchi.dev>
1 parent 766ac6e commit fa2e7db

File tree

5 files changed

+150
-0
lines changed

5 files changed

+150
-0
lines changed

.dockerignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
node_modules
2+
.astro
3+
.vscode
4+
*.log
5+
npm-debug.log*
6+
.env*
7+
.DS_Store
8+
Thumbs.db
9+
10+
# Keep these files for the build
11+
!package*.json
12+
!astro.config.mjs
13+
!tsconfig.json
14+
!src/
15+
!public/

Caddyfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
# disable HTTPS because it's going to be handled by fly.io
3+
auto_https off
4+
servers {
5+
# sets fly proxy as trusted proxy
6+
trusted_proxies static 172.16.0.0/16
7+
client_ip_headers X-Forwarded-For Fly-Client-IP
8+
}
9+
log {
10+
level INFO
11+
exclude http.handlers.anubis.anubis
12+
}
13+
}
14+
15+
:8080 {
16+
# required for anubis to work
17+
request_header +X-Real-IP {client_ip}
18+
19+
handle /health {
20+
respond "OK" 200
21+
}
22+
23+
handle {
24+
# Enable Anubis anti-AI/scraper protection
25+
anubis
26+
27+
# static file server
28+
root * /usr/share/caddy
29+
file_server
30+
}
31+
}

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Multi-stage build for Astro + Custom Caddy with Anubis
2+
3+
# Build custom Caddy with Anubis plugin
4+
FROM caddy:2-builder AS caddy-builder
5+
6+
RUN xcaddy build \
7+
--with github.com/daegalus/caddy-anubis
8+
9+
10+
# Build the Astro site
11+
FROM node:24-alpine AS astro-builder
12+
13+
WORKDIR /app
14+
15+
COPY package*.json ./
16+
RUN npm ci
17+
18+
COPY . .
19+
RUN npm run build
20+
21+
22+
# Runtime image
23+
FROM caddy:2-alpine
24+
25+
# Copy the caddy modules
26+
COPY --from=caddy-builder /usr/bin/caddy /usr/bin/caddy
27+
28+
# Copy the built site
29+
COPY --from=astro-builder /app/dist /usr/share/caddy
30+
COPY ./Caddyfile /etc/caddy/Caddyfile
31+
32+
EXPOSE 8080
33+
CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile"]

fly.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# fly.toml app configuration file generated for bianchi-dev on 2025-08-30T19:37:03-05:00
2+
#
3+
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
4+
#
5+
6+
app = 'bianchi-dev'
7+
primary_region = 'lax'
8+
9+
[build]
10+
dockerfile = 'Dockerfile'
11+
12+
[http_service]
13+
internal_port = 8080
14+
force_https = false
15+
# let's just always run a tiny machine for now
16+
# auto_stop_machines = 'stop'
17+
# auto_start_machines = true
18+
min_machines_running = 1
19+
processes = ['app']
20+
21+
[[http_service.checks]]
22+
interval = "30s"
23+
timeout = "10s"
24+
grace_period = "15s"
25+
method = "GET"
26+
path = "/health"
27+
protocol = "http"
28+
29+
[[vm]]
30+
size = 'shared-cpu-1x'

mise.toml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
#:schema https://mise.jdx.dev/schema/mise.json
2+
13
[tools]
24
flyctl = "latest"
35
node = "24"
6+
7+
# astro
8+
[tasks.build]
9+
run = "npm run build"
10+
11+
[tasks.dev]
12+
run = "npm run dev"
13+
14+
# caddy
15+
[tasks."caddy:build"]
16+
run = "docker build --target=caddy-builder -t caddy-builder ."
17+
[tasks."caddy:fmt"]
18+
depends = ["caddy:build"]
19+
run = [
20+
"docker run -it --rm -v ./Caddyfile:/tmp/Caddyfile caddy-builder caddy fmt --overwrite --config /tmp/Caddyfile",
21+
]
22+
[tasks."caddy:lint"]
23+
depends = ["caddy:build"]
24+
run = [
25+
"docker build --target=caddy-builder -t caddy-builder .",
26+
"docker run -it --rm -v ./Caddyfile:/tmp/Caddyfile caddy-builder caddy validate --config /tmp/Caddyfile",
27+
]
28+
29+
# docker
30+
[tasks."docker:build"]
31+
run = "docker build -t bonkydev ."
32+
33+
[tasks."docker:dev"]
34+
run = [
35+
"docker build -t bonkydev .",
36+
"docker run -it --rm -p 8080:8080 bonkydev",
37+
]
38+
39+
# working with fly
40+
[tasks.deploy]
41+
run = "fly deploy"
42+
43+
[tasks.logs]
44+
run = "fly logs"

0 commit comments

Comments
 (0)