Files
wolk/docker-compose.dev.yaml
zias 65ffa1785c
Some checks failed
Continuous Integration / Lint Frontend (push) Failing after 7m48s
Continuous Integration / Lint Backend (push) Failing after 24m58s
Continuous Integration / Test (push) Failing after 12m32s
Continuous Integration / Build (push) Failing after 7m26s
Docs / Build Docs (push) Has been skipped
Docs / Build and Release Docs (push) Failing after 5m42s
Continuous Integration / Release (push) Has been skipped
feat: integrate React frontend with Go backend and containerize with Docker
- Rewrite Dockerfile with 4-stage build process:
  - Stage 1: Build React SPA with Bun (oven/bun:latest)
  - Stage 2: Build Go binary with embedded frontend (golang:1.25-alpine)
  - Stage 3: Fetch runtime dependencies (alpine:3.23)
  - Stage 4: Minimal runtime container (busybox:1.37.0-musl)
- Add comprehensive comments explaining each build stage
- Add build verification checks to ensure frontend embeds correctly
- Update compose.yaml with environment variables (FB_PORT=80, FB_ADDRESS=0.0.0.0)
- Add docker-compose.dev.yaml for development with hot reload support
- Modify http/static.go to serve 'index.html' instead of 'public/index.html'
- Final production image: ~50MB with non-root user and health checks
- Enable both production and development Docker workflows
2026-03-16 16:13:22 +01:00

73 lines
1.8 KiB
YAML

# Development environment - runs Go backend and serves frontend from Vite dev server
#
# This is useful for development as it:
# 1. Runs the Go backend in a container for isolated environment
# 2. Allows running React dev server locally with HMR
#
# Setup:
# 1. Start containers: docker compose -f docker-compose.dev.yaml up
# 2. In another terminal, run frontend dev server: cd frontend && bun run dev
# 3. Access the app at: http://localhost:5173 (frontend dev server)
# 4. API calls proxy to http://backend:8080
#
# For production build, use: docker compose up --build
services:
backend:
container_name: filebrowser_backend
build:
dockerfile: Dockerfile.dev
context: .
restart: unless-stopped
networks:
- filebrowser
ports:
- "8080:8080"
volumes:
- ./:/app
- /app/frontend/node_modules
environment:
- FB_PORT=8080
- FB_ADDRESS=0.0.0.0
- REDIS_CACHE_URL=redis://default:filebrowser@redis:6379
depends_on:
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8080/health"]
interval: 10s
timeout: 5s
retries: 3
start_period: 10s
redis:
container_name: filebrowser_redis_dev
image: redis:7-alpine
restart: unless-stopped
networks:
- filebrowser
command:
- sh
- -c
- |
cat > /tmp/users.acl <<'EOF'
user default on >filebrowser ~* +@all
EOF
redis-server --aclfile /tmp/users.acl
volumes:
- redis_data_dev:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
start_period: 5s
networks:
filebrowser:
driver: bridge
volumes:
redis_data_dev:
driver: local