diff --git a/.gitignore b/.gitignore index feb5de7..88bb38f 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,5 @@ config.yaml *.local.yaml *.local.yml *.local.json -*.log \ No newline at end of file +*.log +/test/reports/ diff --git a/CLAUDE.md b/CLAUDE.md index 98b9db2..3c20b2a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -20,6 +20,10 @@ make build # Build optimised binary with version info make build-local # Build binary to ./build/ (fast, for testing) make run # Run with version info make run-debug # Run with debug logging +make docker-build # Build Docker image with goreleaser (requires goreleaser) +make docker-build-local # Build Docker image locally for amd64 (no goreleaser required) +make docker-build-local-arm64 # Build Docker image locally for ARM64 (no goreleaser required) +make docker-run # Run Docker image with local config (amd64) make ci # Run full CI pipeline locally make help # Show all available targets ``` diff --git a/docs/content/development/setup.md b/docs/content/development/setup.md index e1cf970..7c79bca 100644 --- a/docs/content/development/setup.md +++ b/docs/content/development/setup.md @@ -85,6 +85,15 @@ make dev | `make lint` | Run golangci-lint | | `make ready` | Run all checks (test-short, test-race, fmt, lint, align) | +### Docker Commands + +| Command | Description | +|---------|-------------| +| `make docker-build-local` | Build Docker image locally for amd64 (no goreleaser required) | +| `make docker-build-local-arm64` | Build Docker image locally for ARM64 (no goreleaser required) | +| `make docker-build` | Build Docker image with goreleaser (requires goreleaser installed) | +| `make docker-run` | Run Docker image with local config (amd64) | + ## Configuration ### Development Config @@ -183,6 +192,57 @@ Run with hot reload: air ``` +## Docker Development + +### Building Docker Images Locally + +You can build Docker images without requiring [goreleaser](https://goreleaser.com/): + +#### AMD64 (Intel/most systems) + +```bash +make docker-build-local +# Produces: ghcr.io/thushan/olla:local-amd64 +``` + +#### ARM64 (Apple Silicon, Raspberry Pi, ARM servers) + +```bash +make docker-build-local-arm64 +# Produces: ghcr.io/thushan/olla:local-arm64 +``` + +#### Custom architecture + +```bash +make docker-build-local DOCKER_ARCH=arm64 +# Produces: ghcr.io/thushan/olla:local-arm64 +``` + +If you have goreleaser installed, use the full release build: + +```bash +# Full goreleaser build with all platforms and tags +make docker-build +``` + +### Running the Docker Image + +```bash +# Run the locally built image +docker run -p 40114:40114 \ + -v "$(pwd)/config/config.local.yaml:/config/config.yaml:ro" \ + -e OLLA_CONFIG_FILE=/config/config.yaml \ + ghcr.io/thushan/olla:local + +# Or use the convenience make target +make docker-run +``` + +!!! warning "Docker Network Configuration" + + When running Olla in Docker, ensure your config has `server.host: 0.0.0.0` (not `localhost`). Inside the container, `localhost` binds to the loopback interface and won't be accessible from the host machine, even with published ports (`-p 40114:40114`). Use `0.0.0.0` to listen on all interfaces. + ## IDE Configuration ### VS Code diff --git a/makefile b/makefile index 9dd6324..12890a7 100644 --- a/makefile +++ b/makefile @@ -205,21 +205,43 @@ build-snapshot: # Deprecated: use build-local or build-snapshot instead ready-local: build-snapshot +DOCKER_ARCH ?= amd64 + +# Build Docker image without goreleaser (for local development) +docker-build-local: + @echo "Building Docker image locally (without goreleaser) for $(DOCKER_ARCH)..." + @echo "Building olla binary to root..." + @CGO_ENABLED=0 GOOS=linux GOARCH=$(DOCKER_ARCH) go build $(LDFLAGS) -o olla . + @echo "Building Docker image..." + @docker build -t ghcr.io/thushan/olla:local-$(DOCKER_ARCH) . + @echo "Cleaning up binary..." + @rm -f olla + @echo "Docker image built: ghcr.io/thushan/olla:local-$(DOCKER_ARCH)" + @docker images --filter reference='*olla*local*' + +# Build Docker image for ARM64 (convenience target) +docker-build-local-arm64: + @$(MAKE) docker-build-local DOCKER_ARCH=arm64 + # Build and test Docker image locally docker-build: + @if ! command -v goreleaser > /dev/null 2>&1; then \ + echo "❌ goreleaser not found. Use 'make docker-build-local' instead (no goreleaser required)"; \ + exit 1; \ + fi @echo "Building Docker image locally..." @goreleaser release --snapshot --clean --skip=publish,announce,sign,sbom @echo "Docker images:" @docker images | grep olla | head -5 -# Run Docker image with local config +# Run Docker image with local config (defaults to amd64) docker-run: - @echo "Running Docker image with local config..." + @echo "Running Docker image with local config (amd64)..." @docker run --rm -it \ -p 40114:40114 \ -v "$(shell pwd)/config/config.local.yaml:/config/config.yaml:ro" \ -e OLLA_CONFIG_FILE=/config/config.yaml \ - ghcr.io/thushan/olla:latest + ghcr.io/thushan/olla:local-amd64 # Test full release locally (binaries + docker + archives) release-test: diff --git a/readme.md b/readme.md index 6fc9f3c..f23e176 100644 --- a/readme.md +++ b/readme.md @@ -100,6 +100,12 @@ git clone https://github.com/thushan/olla.git && cd olla && make build-release ./bin/olla ``` +```bash +# Build Docker image locally (no goreleaser required) +git clone https://github.com/thushan/olla.git && cd olla && make docker-build-local +docker run -p 40114:40114 ghcr.io/thushan/olla:local +``` + ### Verification When you have everything running, you can check it's all working with: