Compare commits
4 Commits
9b57b2a535
...
v1.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
| fc54f7bb86 | |||
| 42030003d3 | |||
| 25bc095412 | |||
| 54bb68642f |
45
.gitea/workflows/publish.yml
Normal file
45
.gitea/workflows/publish.yml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
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 \
|
||||||
|
-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
|
||||||
11
Dockerfile
11
Dockerfile
@@ -16,12 +16,16 @@ 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
|
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 +64,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"]
|
||||||
|
|||||||
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.
|
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
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -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",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user