From 74ebd2b38f0156db786cc6da8463f1131e629719 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 30 Nov 2026 17:39:27 +0000 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Build=20on=20PocketBase=20?= =?UTF-8?q?defaults=20in=20container=20and=20tasks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 13 +++++++++++++ .gitignore | 2 ++ Containerfile | 13 ++++++------- mise.toml | 23 +++++++++++------------ 4 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d22a5d1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +.git +.github +web/node_modules +web/build +web/.svelte-kit +web/dev-dist +pb_data +wotra +wotra.db +wotra.db.* +wotra.tar.gz +*.md +!README.md diff --git a/.gitignore b/.gitignore index 9e4f7bf..ae64369 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ web/build/* !web/build/.gitkeep web/.svelte-kit/ web/node_modules/ +pb_data/ +wotra.db.* diff --git a/Containerfile b/Containerfile index de15d51..547c170 100644 --- a/Containerfile +++ b/Containerfile @@ -17,22 +17,21 @@ RUN go mod download COPY . . COPY --from=web-builder /app/web/build ./web/build -RUN go build -tags production -o wotra ./cmd/wotra +RUN CGO_ENABLED=0 go build -trimpath -o /out/wotra . # ── Stage 3: minimal runtime image ─────────────────────────────────────────── FROM alpine:3.21 -RUN adduser -D -u 1000 wotra +RUN apk add --no-cache ca-certificates && adduser -D -u 1000 wotra -WORKDIR /data +WORKDIR /pb_data USER wotra -COPY --from=go-builder /app/wotra /usr/local/bin/wotra +COPY --from=go-builder /out/wotra /usr/local/bin/wotra EXPOSE 8080 -ENV PORT=8080 \ - DB_PATH=/data/wotra.db \ - TZ=UTC +VOLUME /pb_data ENTRYPOINT ["/usr/local/bin/wotra"] +CMD ["serve", "--http=0.0.0.0:8080", "--dir=/pb_data"] diff --git a/mise.toml b/mise.toml index 6b41577..80315d4 100644 --- a/mise.toml +++ b/mise.toml @@ -12,12 +12,6 @@ auto = true go = "1.27.0" node = "24.14.0" -[env] -AUTH_TOKEN = "devtoken" -PORT = "8080" -DB_PATH = "wotra.db" -TZ = "UTC" - [tasks.build] description = "Build production single binary (web + Go, sequential)" run = """ @@ -32,20 +26,20 @@ run = "npm run build" [tasks."build:go"] description = "Build Go binary with embedded web assets" -run = "go build -tags production -o wotra ./cmd/wotra" +run = "go build -trimpath -o wotra ." [tasks.dev] -description = "Start Go API and Vite dev server concurrently" +description = "Start PocketBase API and Vite dev server concurrently" run = """ -echo "Go API: http://localhost:${PORT}" +echo "PocketBase API: http://localhost:8080 (admin UI: /_/)" echo "Vite UI: http://localhost:5173" mise run dev:api & mise run dev:ui wait """ [tasks."dev:api"] -description = "Start Go API server" -run = "go run ./cmd/wotra" +description = "Start PocketBase API server" +run = "go run . serve --http=127.0.0.1:8080" [tasks."dev:ui"] description = "Start Vite dev server" @@ -65,9 +59,14 @@ run = "npm test" description = "Run Go tests and frontend Vitest tests" depends = ["test", "test:web"] +[tasks.check] +description = "Lint and typecheck" +run = ["go vet ./...", "test -z \"$(gofmt -l .)\"", "npm --prefix web run check"] + [tasks.clean] description = "Remove build artifacts" run = """ rm -f wotra -rm -rf web/build web/.svelte-kit +rm -rf web/build web/.svelte-kit web/dev-dist +mkdir -p web/build && touch web/build/.gitkeep """