aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.dockerignore3
-rw-r--r--Dockerfile25
-rw-r--r--README.md21
-rw-r--r--mise.toml8
4 files changed, 57 insertions, 0 deletions
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..ae73746
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,3 @@
+.git
+data
+gallery
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..e7aeed9
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,25 @@
+FROM golang:1.25-alpine AS builder
+
+WORKDIR /src
+
+COPY go.mod go.sum ./
+RUN go mod download
+
+COPY . .
+RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
+ go build -trimpath -ldflags="-s -w" -o /out/gallery .
+
+FROM alpine:3.22
+
+RUN addgroup -S -g 1000 app && adduser -S -D -u 1000 -G app app
+
+WORKDIR /app
+COPY --from=builder --chown=app:app /out/gallery /app/gallery
+RUN mkdir /app/data && chown app:app /app/data
+
+VOLUME /app/data
+EXPOSE 8020
+ENV HOME=/app
+USER app
+ENTRYPOINT ["/app/gallery"]
+CMD ["serve", "--addr", ":8020", "--data", "/app/data"]
diff --git a/README.md b/README.md
index e4e9ca6..eb7dca9 100644
--- a/README.md
+++ b/README.md
@@ -53,3 +53,24 @@ pics.example.com {
go test ./...
```
+## Deploy
+
+The VPS runs the gallery as a Docker Compose service behind Caddy at
+`https://pics.kagamino.dev`. The replacement service starts with a fresh local
+`./gallery-data` folder next to the VPS Compose file; the former systemd data is
+archived separately and is not imported.
+
+Authenticate the local and VPS Docker clients once, then deploy with:
+
+```sh
+docker login container.registry.kagamino.dev
+ssh ubuntu@feed.kagamino.dev "sudo docker login container.registry.kagamino.dev"
+mise run deploy
+```
+
+Create a new gallery in the empty deployment from the VPS:
+
+```sh
+ssh ubuntu@feed.kagamino.dev \
+ "sudo docker compose exec gallery /app/gallery create <name> '<password>' --data /app/data"
+```
diff --git a/mise.toml b/mise.toml
new file mode 100644
index 0000000..75c6165
--- /dev/null
+++ b/mise.toml
@@ -0,0 +1,8 @@
+[tasks.deploy]
+description = "Build image, push to private registry, and restart gallery"
+run = """
+ssh ubuntu@feed.kagamino.dev "sudo mkdir -p /home/ubuntu/gallery-data && sudo chown ubuntu:ubuntu /home/ubuntu/gallery-data && sudo docker compose up -d registry" && \
+docker build -t container.registry.kagamino.dev/kagapics:latest . && \
+docker push container.registry.kagamino.dev/kagapics:latest && \
+ssh ubuntu@feed.kagamino.dev "sudo docker compose pull gallery && sudo docker compose up -d gallery"
+"""