Skip to content

Commit 75f113c

Browse files
committed
add dockerize for statesman, makefile, dockerignore
1 parent 74f9943 commit 75f113c

File tree

4 files changed

+138
-1
lines changed

4 files changed

+138
-1
lines changed

taco/.dockerignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Git
2+
.git
3+
.gitignore
4+
5+
# Documentation
6+
*.md
7+
docs/
8+
agents_*/
9+
10+
# Examples
11+
examples/
12+
13+
# Build artifacts
14+
statesman
15+
taco
16+
terraform-provider-opentaco
17+
*.test
18+
*.out
19+
20+
# Development files
21+
.devdata/
22+
*.log
23+
24+
# IDE files
25+
.vscode/
26+
.idea/
27+
*.swp
28+
*.swo
29+
30+
# OS files
31+
.DS_Store
32+
Thumbs.db
33+
34+
# Temporary files
35+
tmp/
36+
temp/

taco/Dockerfile_statesman

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
FROM golang:1.25 as builder
2+
ARG COMMIT_SHA
3+
RUN echo "commit sha: ${COMMIT_SHA}"
4+
5+
# Set the working directory
6+
WORKDIR /go/src/github.com/diggerhq/digger/taco
7+
8+
# Copy all source code
9+
COPY cmd/statesman/ ./cmd/statesman/
10+
COPY internal/ ./internal/
11+
COPY pkg/sdk/ ./pkg/sdk/
12+
13+
# Download dependencies and build
14+
RUN cd cmd/statesman && \
15+
go mod tidy && \
16+
CGO_ENABLED=0 GOOS=linux go build \
17+
-ldflags="-X 'main.Version=${COMMIT_SHA}' -s -w" \
18+
-a -installsuffix cgo \
19+
-o statesman .
20+
21+
# Multi-stage build - use a minimal image for runtime
22+
FROM ubuntu:24.04 as runner
23+
ARG COMMIT_SHA
24+
WORKDIR /app
25+
26+
# Install ca-certificates for HTTPS requests
27+
RUN apt-get update && \
28+
apt-get install -y ca-certificates && \
29+
apt-get clean && \
30+
rm -rf /var/lib/apt/lists/*
31+
32+
RUN echo "commit sha: ${COMMIT_SHA}"
33+
34+
# Copy the binary from builder stage
35+
COPY --from=builder /go/src/github.com/diggerhq/digger/taco/cmd/statesman/statesman /app/statesman
36+
37+
# Make the binary executable
38+
RUN chmod +x /app/statesman
39+
40+
# Expose the port that statesman runs on
41+
EXPOSE 8080
42+
43+
# Set environment variables with defaults
44+
ENV OPENTACO_PORT=8080
45+
ENV OPENTACO_STORAGE=memory
46+
47+
# Health check
48+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
49+
CMD curl -f http://localhost:8080/healthz || exit 1
50+
51+
# Run the statesman binary
52+
ENTRYPOINT ["/app/statesman"]

taco/Makefile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all build test lint clean svc cli prov help
1+
.PHONY: all build test lint clean svc cli prov help docker-build-svc docker-run-svc docker-clean
22

33
# Default goal
44
.DEFAULT_GOAL := help
@@ -66,5 +66,24 @@ init: ## Initialize Go modules
6666
cd pkg/sdk && go mod init github.com/digger/opentaco/pkg/sdk && go mod tidy
6767
cd providers/terraform/opentaco && go mod init github.com/digger/opentaco/providers/terraform/opentaco && go mod tidy
6868

69+
# Docker targets
70+
docker-build-svc: ## Build statesman Docker image
71+
@echo "Building statesman Docker image..."
72+
docker build -f Dockerfile_statesman -t statesman:latest --build-arg COMMIT_SHA=$(shell git rev-parse HEAD) .
73+
74+
docker-run-svc: ## Run statesman in Docker container
75+
@echo "Running statesman in Docker container..."
76+
docker run -p 8080:8080 \
77+
-e OPENTACO_STORAGE=memory \
78+
-e OPENTACO_AUTH_DISABLE=true \
79+
--name statesman-container \
80+
statesman:latest
81+
82+
docker-clean: ## Clean Docker images and containers
83+
@echo "Cleaning Docker artifacts..."
84+
docker stop statesman-container 2>/dev/null || true
85+
docker rm statesman-container 2>/dev/null || true
86+
docker rmi statesman:latest 2>/dev/null || true
87+
6988
help: ## Show this help
7089
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'

taco/docker-compose.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: '3.8'
2+
3+
services:
4+
statesman:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile_statesman
8+
args:
9+
COMMIT_SHA: ${COMMIT_SHA:-latest}
10+
ports:
11+
- "8080:8080"
12+
environment:
13+
- OPENTACO_PORT=8080
14+
- OPENTACO_STORAGE=memory
15+
- OPENTACO_AUTH_DISABLE=true
16+
# S3 configuration (uncomment and set if using S3 storage)
17+
# - OPENTACO_S3_BUCKET=${OPENTACO_S3_BUCKET}
18+
# - OPENTACO_S3_REGION=${OPENTACO_S3_REGION}
19+
# - OPENTACO_S3_PREFIX=${OPENTACO_S3_PREFIX}
20+
# Auth configuration (uncomment and set if using auth)
21+
# - OPENTACO_AUTH_ISSUER=${OPENTACO_AUTH_ISSUER}
22+
# - OPENTACO_AUTH_CLIENT_ID=${OPENTACO_AUTH_CLIENT_ID}
23+
healthcheck:
24+
test: ["CMD", "curl", "-f", "http://localhost:8080/healthz"]
25+
interval: 30s
26+
timeout: 10s
27+
retries: 3
28+
start_period: 40s
29+
restart: unless-stopped
30+
container_name: statesman-container

0 commit comments

Comments
 (0)