Skip to content

Commit 4b65140

Browse files
authored
Merge pull request #138 from thushan/feature/docker-build-local
feat: docker release build locally without goreleaser
2 parents e82fb13 + 9505fba commit 4b65140

5 files changed

Lines changed: 97 additions & 4 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ config.yaml
3939
*.local.yaml
4040
*.local.yml
4141
*.local.json
42-
*.log
42+
*.log
43+
/test/reports/

CLAUDE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ make build # Build optimised binary with version info
2020
make build-local # Build binary to ./build/ (fast, for testing)
2121
make run # Run with version info
2222
make run-debug # Run with debug logging
23+
make docker-build # Build Docker image with goreleaser (requires goreleaser)
24+
make docker-build-local # Build Docker image locally for amd64 (no goreleaser required)
25+
make docker-build-local-arm64 # Build Docker image locally for ARM64 (no goreleaser required)
26+
make docker-run # Run Docker image with local config (amd64)
2327
make ci # Run full CI pipeline locally
2428
make help # Show all available targets
2529
```

docs/content/development/setup.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ make dev
8585
| `make lint` | Run golangci-lint |
8686
| `make ready` | Run all checks (test-short, test-race, fmt, lint, align) |
8787

88+
### Docker Commands
89+
90+
| Command | Description |
91+
|---------|-------------|
92+
| `make docker-build-local` | Build Docker image locally for amd64 (no goreleaser required) |
93+
| `make docker-build-local-arm64` | Build Docker image locally for ARM64 (no goreleaser required) |
94+
| `make docker-build` | Build Docker image with goreleaser (requires goreleaser installed) |
95+
| `make docker-run` | Run Docker image with local config (amd64) |
96+
8897
## Configuration
8998

9099
### Development Config
@@ -183,6 +192,57 @@ Run with hot reload:
183192
air
184193
```
185194

195+
## Docker Development
196+
197+
### Building Docker Images Locally
198+
199+
You can build Docker images without requiring [goreleaser](https://goreleaser.com/):
200+
201+
#### AMD64 (Intel/most systems)
202+
203+
```bash
204+
make docker-build-local
205+
# Produces: ghcr.io/thushan/olla:local-amd64
206+
```
207+
208+
#### ARM64 (Apple Silicon, Raspberry Pi, ARM servers)
209+
210+
```bash
211+
make docker-build-local-arm64
212+
# Produces: ghcr.io/thushan/olla:local-arm64
213+
```
214+
215+
#### Custom architecture
216+
217+
```bash
218+
make docker-build-local DOCKER_ARCH=arm64
219+
# Produces: ghcr.io/thushan/olla:local-arm64
220+
```
221+
222+
If you have goreleaser installed, use the full release build:
223+
224+
```bash
225+
# Full goreleaser build with all platforms and tags
226+
make docker-build
227+
```
228+
229+
### Running the Docker Image
230+
231+
```bash
232+
# Run the locally built image
233+
docker run -p 40114:40114 \
234+
-v "$(pwd)/config/config.local.yaml:/config/config.yaml:ro" \
235+
-e OLLA_CONFIG_FILE=/config/config.yaml \
236+
ghcr.io/thushan/olla:local
237+
238+
# Or use the convenience make target
239+
make docker-run
240+
```
241+
242+
!!! warning "Docker Network Configuration"
243+
244+
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.
245+
186246
## IDE Configuration
187247

188248
### VS Code

makefile

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,21 +205,43 @@ build-snapshot:
205205
# Deprecated: use build-local or build-snapshot instead
206206
ready-local: build-snapshot
207207

208+
DOCKER_ARCH ?= amd64
209+
210+
# Build Docker image without goreleaser (for local development)
211+
docker-build-local:
212+
@echo "Building Docker image locally (without goreleaser) for $(DOCKER_ARCH)..."
213+
@echo "Building olla binary to root..."
214+
@CGO_ENABLED=0 GOOS=linux GOARCH=$(DOCKER_ARCH) go build $(LDFLAGS) -o olla .
215+
@echo "Building Docker image..."
216+
@docker build -t ghcr.io/thushan/olla:local-$(DOCKER_ARCH) .
217+
@echo "Cleaning up binary..."
218+
@rm -f olla
219+
@echo "Docker image built: ghcr.io/thushan/olla:local-$(DOCKER_ARCH)"
220+
@docker images --filter reference='*olla*local*'
221+
222+
# Build Docker image for ARM64 (convenience target)
223+
docker-build-local-arm64:
224+
@$(MAKE) docker-build-local DOCKER_ARCH=arm64
225+
208226
# Build and test Docker image locally
209227
docker-build:
228+
@if ! command -v goreleaser > /dev/null 2>&1; then \
229+
echo "❌ goreleaser not found. Use 'make docker-build-local' instead (no goreleaser required)"; \
230+
exit 1; \
231+
fi
210232
@echo "Building Docker image locally..."
211233
@goreleaser release --snapshot --clean --skip=publish,announce,sign,sbom
212234
@echo "Docker images:"
213235
@docker images | grep olla | head -5
214236

215-
# Run Docker image with local config
237+
# Run Docker image with local config (defaults to amd64)
216238
docker-run:
217-
@echo "Running Docker image with local config..."
239+
@echo "Running Docker image with local config (amd64)..."
218240
@docker run --rm -it \
219241
-p 40114:40114 \
220242
-v "$(shell pwd)/config/config.local.yaml:/config/config.yaml:ro" \
221243
-e OLLA_CONFIG_FILE=/config/config.yaml \
222-
ghcr.io/thushan/olla:latest
244+
ghcr.io/thushan/olla:local-amd64
223245

224246
# Test full release locally (binaries + docker + archives)
225247
release-test:

readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ git clone https://github.com/thushan/olla.git && cd olla && make build-release
100100
./bin/olla
101101
```
102102

103+
```bash
104+
# Build Docker image locally (no goreleaser required)
105+
git clone https://github.com/thushan/olla.git && cd olla && make docker-build-local
106+
docker run -p 40114:40114 ghcr.io/thushan/olla:local
107+
```
108+
103109
### Verification
104110

105111
When you have everything running, you can check it's all working with:

0 commit comments

Comments
 (0)