+8
.dockerignore
+8
.dockerignore
+2
.gitignore
+2
.gitignore
+46
Dockerfile
+46
Dockerfile
···
1
+
ARG GO_VERSION=1
2
+
FROM golang:${GO_VERSION}-bookworm as builder
3
+
4
+
# Install the templ CLI tool for Go
5
+
RUN go install github.com/a-h/templ/cmd/templ@latest
6
+
7
+
# Install the standalone Tailwind CSS CLI
8
+
RUN curl -sLO https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64 && \
9
+
chmod +x tailwindcss-linux-x64 && \
10
+
mv tailwindcss-linux-x64 /usr/local/bin/tailwindcss
11
+
12
+
WORKDIR /usr/src/app
13
+
14
+
COPY go.mod go.sum ./
15
+
RUN go mod download && go mod verify
16
+
17
+
COPY . .
18
+
19
+
RUN /go/bin/templ generate
20
+
21
+
# Create the directory structure for static assets
22
+
RUN mkdir -p ./internal/web/state/static
23
+
24
+
# Download frontend libraries into the static folder
25
+
RUN curl -sLo ./internal/web/state/static/htmx.min.js https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.min.js
26
+
RUN curl -sLo ./internal/web/state/static/lucide.min.js https://unpkg.com/lucide@0.525.0/dist/umd/lucide.min.js
27
+
28
+
RUN tailwindcss -i ./input.css -o ./internal/web/state/static/style.css --minify
29
+
30
+
RUN go build -v -o /run-app ./cmd/web/main.go
31
+
32
+
FROM debian:bookworm
33
+
34
+
# Install ca-certificates for TLS and the sqlite3 CLI tool
35
+
RUN apt-get update -y && \
36
+
apt-get install -y ca-certificates fuse3 sqlite3 && \
37
+
rm -rf /var/lib/apt/lists/*
38
+
39
+
# Copy LiteFS binary and config
40
+
COPY --from=flyio/litefs:0.5 /usr/local/bin/litefs /usr/local/bin/litefs
41
+
COPY litefs.yml /etc/litefs.yml
42
+
43
+
# Copy the compiled Go binary
44
+
COPY --from=builder /run-app /usr/local/bin/
45
+
46
+
CMD ["litefs", "mount", "-config", "/etc/litefs.yml"]
+37
fly.toml
+37
fly.toml
···
1
+
app = 'yoten-study-tracker'
2
+
primary_region = 'syd'
3
+
kill_signal = "SIGINT"
4
+
kill_timeout = "5s"
5
+
6
+
[build]
7
+
[build.args]
8
+
GO_VERSION = '1.24.0'
9
+
10
+
[experimental]
11
+
auto_rollback = true
12
+
13
+
[env]
14
+
YOTEN_PORT = '8081'
15
+
YOTEN_DB_PATH = '/litefs/web.db'
16
+
17
+
[http_service]
18
+
internal_port = 8080
19
+
force_https = true
20
+
auto_stop_machines = true
21
+
auto_start_machines = true
22
+
min_machines_running = 1
23
+
processes = ['app']
24
+
25
+
[http_service.concurrency]
26
+
type = "requests"
27
+
hard_limit = 1000
28
+
soft_limit = 1000
29
+
30
+
[[vm]]
31
+
memory = '1gb'
32
+
cpu_kind = 'shared'
33
+
cpus = 1
34
+
35
+
[mounts]
36
+
source = 'litefs'
37
+
destination = '/var/lib/litefs'
+28
litefs.yml
+28
litefs.yml
···
1
+
fuse:
2
+
dir: "/litefs"
3
+
4
+
data:
5
+
dir: "/var/lib/litefs"
6
+
7
+
exit-on-error: false
8
+
9
+
proxy:
10
+
addr: ":8080"
11
+
target: "localhost:8081"
12
+
db: "web.db"
13
+
passthrough:
14
+
- "*.ico"
15
+
- "*.png"
16
+
17
+
exec:
18
+
- cmd: "run-app"
19
+
20
+
lease:
21
+
type: "consul"
22
+
advertise-url: "http://${HOSTNAME}.vm.${FLY_APP_NAME}.internal:20202"
23
+
candidate: ${FLY_REGION == PRIMARY_REGION}
24
+
promote: true
25
+
26
+
consul:
27
+
url: "${FLY_CONSUL_URL}"
28
+
key: "litefs/${FLY_APP_NAME}"