5 Commits

Author SHA1 Message Date
dd8dd7cdc2 feat(versioning): Implemented APP_VERSION from build tags
All checks were successful
Build and Publish Docker Image / deploy (push) Successful in 1m35s
2026-05-01 03:45:15 +03:00
fc54f7bb86 fix(ci/cd): Naming fix
All checks were successful
Build and Publish Docker Image / deploy (push) Successful in 1m38s
2026-05-01 03:41:32 +03:00
42030003d3 feat(ci/cd): Implemented simple package publishing to registry
Some checks failed
Build and Publish Docker Image / deploy (push) Failing after 1m1s
2026-05-01 03:39:33 +03:00
25bc095412 feat(docker): add healthcheck and wget dependency
Adds a healthcheck endpoint and updates Dockerfile/README
to include wget and define healthcheck logic.
2026-05-01 03:31:01 +03:00
54bb68642f chore(docker): update build path and volume comment 2026-05-01 02:58:16 +03:00
6 changed files with 93 additions and 2 deletions

View File

@@ -0,0 +1,46 @@
name: Build and Publish Docker Image
run-name: Publishing ${{ gitea.ref_name }}
on:
push:
tags:
- "v*"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false
- name: Run Tests
run: go test ./...
- name: Install Docker
run: curl -fsSL https://get.docker.com | sh
- name: Build Docker Image
run: |
docker build \
--build-arg APP_VERSION=${{ gitea.ref_name }} \
-t tea.chunkbyte.com/kato/warpbox:${{ gitea.ref_name }} \
-t tea.chunkbyte.com/kato/warpbox:latest \
.
- name: Login to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: tea.chunkbyte.com
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Push Docker Image
run: |
docker push tea.chunkbyte.com/kato/warpbox:${{ gitea.ref_name }}
docker push tea.chunkbyte.com/kato/warpbox:latest

View File

@@ -1,6 +1,8 @@
# Stage 1: Build # Stage 1: Build
FROM golang:1.23-alpine AS builder FROM golang:1.23-alpine AS builder
ARG APP_VERSION=""
RUN apk add --no-cache git ca-certificates RUN apk add --no-cache git ca-certificates
WORKDIR /build WORKDIR /build
@@ -16,12 +18,19 @@ COPY static/ static/
COPY templates/ templates/ COPY templates/ templates/
# Build the binary # Build the binary
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o warpbox ./cmd/main.go RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o warpbox ./cmd/
# Stage 2: Runtime # Stage 2: Runtime
FROM alpine:3.21 FROM alpine:3.21
RUN apk add --no-cache ca-certificates tzdata ARG APP_VERSION=""
ENV APP_VERSION=${APP_VERSION}
RUN apk add \
--no-cache \
ca-certificates \
tzdata \
wget
# Create non-root user # Create non-root user
RUN addgroup -S warpbox && adduser -S warpbox -G warpbox RUN addgroup -S warpbox && adduser -S warpbox -G warpbox
@@ -60,6 +69,9 @@ ENV WARPBOX_DATA_DIR=/app/data \
EXPOSE 8080 EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD wget -qO- http://127.0.0.1:8080/health >/dev/null || exit 1
VOLUME ["/app/data"] VOLUME ["/app/data"]
CMD ["./warpbox", "run", "--addr", ":8080"] CMD ["./warpbox", "run", "--addr", ":8080"]

View File

@@ -189,3 +189,25 @@ keeps most behavior easy to follow from the Go handlers and the small browser
scripts. scripts.
For a short implementation overview, see [docs/tech.md](docs/tech.md). For a short implementation overview, see [docs/tech.md](docs/tech.md).
## Docker / Podman
If you are using Podman, please pay attention in the [docker-compose.yml](./docker-compose.example.yml) example
file that has been provided, there's comments in regards to differences between the two.
When it comes to building the image, please make sure that you basically set the `--format docker` in the podman
build command, otherwise it won't have HealthChecks and other issues might arise.
Tip: Put the following in `~/.config/containers/containers.conf`
```toml
[engine]
image_default_format = "docker"
```
For just running the docker-compose.yml with docker image format:
```bash
BUILDAH_FORMAT=docker podman compose up --build
```

View File

@@ -5,6 +5,8 @@ services:
ports: ports:
- "8080:8080" - "8080:8080"
volumes: volumes:
# For podman please use :Z
# - ./data:/app/data:Z
- ./data:/app/data - ./data:/app/data
env_file: env_file:
- .env - .env

View File

@@ -3,6 +3,7 @@ package routing
import "github.com/gin-gonic/gin" import "github.com/gin-gonic/gin"
type Handlers struct { type Handlers struct {
Health gin.HandlerFunc
Index gin.HandlerFunc Index gin.HandlerFunc
ShowBox gin.HandlerFunc ShowBox gin.HandlerFunc
BoxLogin gin.HandlerFunc BoxLogin gin.HandlerFunc
@@ -34,6 +35,7 @@ type Handlers struct {
} }
func Register(router *gin.Engine, handlers Handlers) { func Register(router *gin.Engine, handlers Handlers) {
router.GET("/health", handlers.Health)
router.GET("/", handlers.Index) router.GET("/", handlers.Index)
router.GET("/box/:id", handlers.ShowBox) router.GET("/box/:id", handlers.ShowBox)

View File

@@ -48,6 +48,7 @@ func Run(addr string) error {
router.SetHTMLTemplate(htmlTemplates) router.SetHTMLTemplate(htmlTemplates)
routing.Register(router, routing.Handlers{ routing.Register(router, routing.Handlers{
Health: app.handleHealth,
Index: app.handleIndex, Index: app.handleIndex,
ShowBox: app.handleShowBox, ShowBox: app.handleShowBox,
BoxLogin: handleBoxLogin, BoxLogin: handleBoxLogin,
@@ -114,3 +115,9 @@ func applyBoxstoreRuntimeConfig(cfg *config.Config) {
boxstore.SetUploadRoot(cfg.UploadsDir) boxstore.SetUploadRoot(cfg.UploadsDir)
boxstore.SetOneTimeDownloadExpiry(cfg.OneTimeDownloadExpirySeconds) boxstore.SetOneTimeDownloadExpiry(cfg.OneTimeDownloadExpirySeconds)
} }
func (app *App) handleHealth(c *gin.Context) {
c.JSON(200, gin.H{
"status": "healthy",
})
}