feature(docker): Implemented DockerFile, docker compose .env and updated the run.sh file.
This commit is contained in:
10
.dockerignore
Normal file
10
.dockerignore
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
docs/
|
||||||
|
memory-bank/
|
||||||
|
*_test.go
|
||||||
|
README.md
|
||||||
|
run.sh
|
||||||
|
Dockerfile
|
||||||
|
.dockerignore
|
||||||
|
data/
|
||||||
25
.env.example
Normal file
25
.env.example
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
# Core service switches
|
||||||
|
WARPBOX_GUEST_UPLOADS_ENABLED=true
|
||||||
|
WARPBOX_API_ENABLED=true
|
||||||
|
WARPBOX_ZIP_DOWNLOADS_ENABLED=true
|
||||||
|
WARPBOX_ONE_TIME_DOWNLOADS_ENABLED=true
|
||||||
|
|
||||||
|
# Storage and expiry limits (in MB)
|
||||||
|
WARPBOX_GLOBAL_MAX_FILE_SIZE_MB=2048
|
||||||
|
WARPBOX_GLOBAL_MAX_BOX_SIZE_MB=4096
|
||||||
|
WARPBOX_DEFAULT_GUEST_EXPIRY_SECONDS=3600
|
||||||
|
WARPBOX_MAX_GUEST_EXPIRY_SECONDS=172800
|
||||||
|
|
||||||
|
# Tuning
|
||||||
|
WARPBOX_BOX_POLL_INTERVAL_MS=5000
|
||||||
|
WARPBOX_THUMBNAIL_BATCH_SIZE=10
|
||||||
|
WARPBOX_THUMBNAIL_INTERVAL_SECONDS=30
|
||||||
|
|
||||||
|
# Data location
|
||||||
|
# For local run: ./data
|
||||||
|
# For Docker: /app/data
|
||||||
|
WARPBOX_DATA_DIR=./data
|
||||||
|
|
||||||
|
# Admin Area
|
||||||
|
WARPBOX_ADMIN_ENABLED=true
|
||||||
|
WARPBOX_ADMIN_PASSWORD=123
|
||||||
21
.gitignore
vendored
21
.gitignore
vendored
@@ -1 +1,22 @@
|
|||||||
|
# Data & Env
|
||||||
data/
|
data/
|
||||||
|
.env
|
||||||
|
docker-compose.yml
|
||||||
|
|
||||||
|
# Go
|
||||||
|
bin/
|
||||||
|
vendor/
|
||||||
|
*.exe
|
||||||
|
*.test
|
||||||
|
*.out
|
||||||
|
*.prof
|
||||||
|
|
||||||
|
# IDEs
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
63
Dockerfile
Normal file
63
Dockerfile
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# Stage 1: Build
|
||||||
|
FROM golang:1.23-alpine AS builder
|
||||||
|
|
||||||
|
RUN apk add --no-cache git ca-certificates
|
||||||
|
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
|
# Copy go modules and download dependencies
|
||||||
|
COPY go.mod go.sum ./
|
||||||
|
RUN go mod download && go mod verify
|
||||||
|
|
||||||
|
# Copy source code and static assets
|
||||||
|
COPY cmd/ cmd/
|
||||||
|
COPY lib/ lib/
|
||||||
|
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
|
||||||
|
|
||||||
|
# Stage 2: Runtime
|
||||||
|
FROM alpine:3.21
|
||||||
|
|
||||||
|
RUN apk add --no-cache ca-certificates tzdata
|
||||||
|
|
||||||
|
# Create non-root user
|
||||||
|
RUN addgroup -S warpbox && adduser -S warpbox -G warpbox
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copy binary from builder
|
||||||
|
COPY --from=builder /build/warpbox .
|
||||||
|
|
||||||
|
# Copy static assets
|
||||||
|
COPY --from=builder /build/static/ static/
|
||||||
|
COPY --from=builder /build/templates/ templates/
|
||||||
|
|
||||||
|
# Create data directory
|
||||||
|
RUN mkdir -p /app/data/uploads /app/data/db && chown -R warpbox:warpbox /app/data
|
||||||
|
|
||||||
|
# Switch to non-root user
|
||||||
|
USER warpbox
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
ENV WARPBOX_DATA_DIR=/app/data \
|
||||||
|
WARPBOX_GUEST_UPLOADS_ENABLED=true \
|
||||||
|
WARPBOX_API_ENABLED=true \
|
||||||
|
WARPBOX_ZIP_DOWNLOADS_ENABLED=true \
|
||||||
|
WARPBOX_ONE_TIME_DOWNLOADS_ENABLED=true \
|
||||||
|
WARPBOX_ADMIN_ENABLED=true \
|
||||||
|
WARPBOX_GLOBAL_MAX_FILE_SIZE_MB=2048 \
|
||||||
|
WARPBOX_GLOBAL_MAX_BOX_SIZE_MB=4096 \
|
||||||
|
WARPBOX_DEFAULT_GUEST_EXPIRY_SECONDS=3600 \
|
||||||
|
WARPBOX_MAX_GUEST_EXPIRY_SECONDS=172800 \
|
||||||
|
WARPBOX_BOX_POLL_INTERVAL_MS=5000 \
|
||||||
|
WARPBOX_THUMBNAIL_BATCH_SIZE=10 \
|
||||||
|
WARPBOX_THUMBNAIL_INTERVAL_SECONDS=30
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
|
||||||
|
VOLUME ["/app/data"]
|
||||||
|
|
||||||
|
CMD ["./warpbox", "run", "--addr", ":8080"]
|
||||||
11
docker-compose.example.yml
Normal file
11
docker-compose.example.yml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
services:
|
||||||
|
warpbox:
|
||||||
|
image: warpbox:latest
|
||||||
|
container_name: warpbox
|
||||||
|
ports:
|
||||||
|
- "8080:8080"
|
||||||
|
volumes:
|
||||||
|
- ./data:/app/data
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
restart: unless-stopped
|
||||||
11
run.sh
11
run.sh
@@ -1,6 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Load .env if exists
|
||||||
|
if [ -f .env ]; then
|
||||||
|
export $(grep -v '^#' .env | xargs)
|
||||||
|
fi
|
||||||
|
|
||||||
# Core service switches.
|
# Core service switches.
|
||||||
export WARPBOX_GUEST_UPLOADS_ENABLED="${WARPBOX_GUEST_UPLOADS_ENABLED:-true}"
|
export WARPBOX_GUEST_UPLOADS_ENABLED="${WARPBOX_GUEST_UPLOADS_ENABLED:-true}"
|
||||||
export WARPBOX_API_ENABLED="${WARPBOX_API_ENABLED:-true}"
|
export WARPBOX_API_ENABLED="${WARPBOX_API_ENABLED:-true}"
|
||||||
@@ -26,4 +31,10 @@ export WARPBOX_DATA_DIR="${WARPBOX_DATA_DIR:-./data}"
|
|||||||
export WARPBOX_ADMIN_ENABLED="${WARPBOX_ADMIN_ENABLED:-true}"
|
export WARPBOX_ADMIN_ENABLED="${WARPBOX_ADMIN_ENABLED:-true}"
|
||||||
export WARPBOX_ADMIN_PASSWORD="${WARPBOX_ADMIN_PASSWORD:-123}"
|
export WARPBOX_ADMIN_PASSWORD="${WARPBOX_ADMIN_PASSWORD:-123}"
|
||||||
|
|
||||||
|
# Option to run via Docker Compose
|
||||||
|
if [ "${1:-}" = "--docker" ]; then
|
||||||
|
docker-compose up --build
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
go run ./cmd/main.go run
|
go run ./cmd/main.go run
|
||||||
Reference in New Issue
Block a user