Compare commits
5 Commits
9b57b2a535
...
v1.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
| dd8dd7cdc2 | |||
| fc54f7bb86 | |||
| 42030003d3 | |||
| 25bc095412 | |||
| 54bb68642f |
46
.gitea/workflows/publish.yml
Normal file
46
.gitea/workflows/publish.yml
Normal 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
|
||||
16
Dockerfile
16
Dockerfile
@@ -1,6 +1,8 @@
|
||||
# Stage 1: Build
|
||||
FROM golang:1.23-alpine AS builder
|
||||
|
||||
ARG APP_VERSION=""
|
||||
|
||||
RUN apk add --no-cache git ca-certificates
|
||||
|
||||
WORKDIR /build
|
||||
@@ -16,12 +18,19 @@ COPY static/ static/
|
||||
COPY templates/ templates/
|
||||
|
||||
# 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
|
||||
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
|
||||
RUN addgroup -S warpbox && adduser -S warpbox -G warpbox
|
||||
@@ -60,6 +69,9 @@ ENV WARPBOX_DATA_DIR=/app/data \
|
||||
|
||||
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"]
|
||||
|
||||
CMD ["./warpbox", "run", "--addr", ":8080"]
|
||||
|
||||
22
README.md
22
README.md
@@ -189,3 +189,25 @@ keeps most behavior easy to follow from the Go handlers and the small browser
|
||||
scripts.
|
||||
|
||||
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
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ services:
|
||||
ports:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
# For podman please use :Z
|
||||
# - ./data:/app/data:Z
|
||||
- ./data:/app/data
|
||||
env_file:
|
||||
- .env
|
||||
|
||||
@@ -3,6 +3,7 @@ package routing
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
type Handlers struct {
|
||||
Health gin.HandlerFunc
|
||||
Index gin.HandlerFunc
|
||||
ShowBox gin.HandlerFunc
|
||||
BoxLogin gin.HandlerFunc
|
||||
@@ -34,6 +35,7 @@ type Handlers struct {
|
||||
}
|
||||
|
||||
func Register(router *gin.Engine, handlers Handlers) {
|
||||
router.GET("/health", handlers.Health)
|
||||
router.GET("/", handlers.Index)
|
||||
|
||||
router.GET("/box/:id", handlers.ShowBox)
|
||||
|
||||
@@ -48,6 +48,7 @@ func Run(addr string) error {
|
||||
router.SetHTMLTemplate(htmlTemplates)
|
||||
|
||||
routing.Register(router, routing.Handlers{
|
||||
Health: app.handleHealth,
|
||||
Index: app.handleIndex,
|
||||
ShowBox: app.handleShowBox,
|
||||
BoxLogin: handleBoxLogin,
|
||||
@@ -114,3 +115,9 @@ func applyBoxstoreRuntimeConfig(cfg *config.Config) {
|
||||
boxstore.SetUploadRoot(cfg.UploadsDir)
|
||||
boxstore.SetOneTimeDownloadExpiry(cfg.OneTimeDownloadExpirySeconds)
|
||||
}
|
||||
|
||||
func (app *App) handleHealth(c *gin.Context) {
|
||||
c.JSON(200, gin.H{
|
||||
"status": "healthy",
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user