Skip to content

Commit 8d34e96

Browse files
committed
switch to atlas like backend
1 parent 0fe2372 commit 8d34e96

File tree

14 files changed

+68
-357
lines changed

14 files changed

+68
-357
lines changed

taco/Dockerfile_statesman

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,8 @@ WORKDIR /go/src/github.com/diggerhq/digger/taco
99
COPY cmd/statesman/ ./cmd/statesman/
1010
COPY internal/ ./internal/
1111
COPY pkg/sdk/ ./pkg/sdk/
12-
COPY Makefile ./Makefile
1312

14-
# Download Atlas amd64 binary for embedding into statesman binary
15-
RUN apt-get update && apt-get install -y curl make && \
16-
make atlas-download-binary && \
17-
apt-get clean && \
18-
rm -rf /var/lib/apt/lists/*
19-
20-
# Download dependencies and build (Atlas binary will be embedded via go:embed)
13+
# Download dependencies and build
2114
# Note: CGO is required for SQLite support
2215
RUN cd cmd/statesman && \
2316
go mod tidy && \
@@ -26,47 +19,49 @@ RUN cd cmd/statesman && \
2619
-a \
2720
-o statesman .
2821

29-
# Install Atlas CLI for migrations (fallback for dev/debugging)
30-
RUN go install ariga.io/atlas/cmd/atlas@latest
31-
3222
# Multi-stage build - use a minimal image for runtime
3323
FROM ubuntu:24.04 AS runner
3424
ARG COMMIT_SHA
3525
WORKDIR /app
3626

37-
# Install ca-certificates and curl for HTTPS requests
27+
# Install ca-certificates, curl for HTTPS requests
3828
RUN apt-get update && \
3929
apt-get install -y ca-certificates curl && \
4030
apt-get clean && \
4131
rm -rf /var/lib/apt/lists/*
4232

4333
RUN echo "commit sha: ${COMMIT_SHA}"
4434

45-
# Install Atlas CLI for customer use
35+
# Install Atlas CLI for migrations
4636
RUN curl -sSf https://atlasgo.sh | sh
4737

48-
# Copy the binary from builder stage (contains embedded Atlas + migrations)
38+
# Copy the binary from builder stage
4939
COPY --from=builder /go/src/github.com/diggerhq/digger/taco/cmd/statesman/statesman /app/statesman
5040

51-
# Copy migration files for customer Atlas CLI usage
52-
COPY --from=builder /go/src/github.com/diggerhq/digger/taco/internal/query/migration/atlas/migrations /app/migrations
41+
# Copy migration files
42+
COPY --from=builder /go/src/github.com/diggerhq/digger/taco/migrations /app/migrations
43+
44+
# Copy entrypoint script
45+
COPY --from=builder /go/src/github.com/diggerhq/digger/taco/scripts/entrypoint.sh /app/entrypoint.sh
5346

54-
# Copy atlas.hcl for customer reference (optional)
47+
# Copy atlas.hcl for reference
5548
COPY --from=builder /go/src/github.com/diggerhq/digger/taco/atlas.hcl /app/atlas.hcl
5649

57-
# Make the binary executable
58-
RUN chmod +x /app/statesman
50+
# Make scripts executable
51+
RUN chmod +x /app/statesman /app/entrypoint.sh
5952

6053
# Expose the port that statesman runs on
6154
EXPOSE 8080
6255

6356
# Set environment variables with defaults
6457
ENV OPENTACO_PORT=8080
6558
ENV OPENTACO_STORAGE=memory
59+
ENV OPENTACO_BACKEND=sqlite
60+
ENV OPENTACO_SQLITE_PATH=/app/data/taco.db
6661

6762
# Health check
6863
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
6964
CMD curl -f http://localhost:8080/healthz || exit 1
7065

71-
# Run the statesman binary
72-
ENTRYPOINT ["/app/statesman"]
66+
# Run via entrypoint script (applies migrations then starts statesman)
67+
ENTRYPOINT ["/bin/bash", "/app/entrypoint.sh"]

taco/Makefile

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,14 @@ atlas-install: ## Install Atlas CLI and GORM provider
104104
@go install ariga.io/atlas-provider-gorm@latest
105105
@echo "✅ Atlas tools installed successfully"
106106

107-
# Download Atlas amd64 binary for packaging
108-
atlas-download-binary: ## Download Atlas amd64 Linux binary for embedding
109-
@echo "Downloading Atlas amd64 binary..."
110-
@mkdir -p internal/query/migration/atlas/bin
111-
@curl -sSfL https://release.ariga.io/atlas/atlas-linux-amd64-latest -o internal/query/migration/atlas/bin/atlas
112-
@chmod +x internal/query/migration/atlas/bin/atlas
113-
@echo "✅ Atlas binary downloaded to internal/query/migration/atlas/bin/atlas"
114-
115107
# Generate migrations for all database dialects (Postgres, MySQL, SQLite)
116108
atlas-diff-all: ## Generate migrations for all databases (use: make atlas-diff-all name=my_change)
117109
@echo "Generating migrations for all databases..."
118110
@if [ -z "$(filter-out $(NAME),$(shell date +%Y%m%d%H%M%S))" ]; then \
119111
echo "⚠️ Using auto-generated name: $(NAME)"; \
120112
echo "💡 Tip: Use 'make atlas-diff-all name=descriptive_name' for better naming"; \
121113
fi
122-
@mkdir -p internal/query/migration/atlas/migrations/postgres internal/query/migration/atlas/migrations/mysql internal/query/migration/atlas/migrations/sqlite
114+
@mkdir -p migrations/postgres migrations/mysql migrations/sqlite
123115
@echo "\n🔐 Generating checksums for existing migrations..."
124116
@$(MAKE) atlas-hash-all
125117
@echo "\n📊 PostgreSQL..." && atlas migrate diff $(NAME) --env postgres
@@ -138,6 +130,6 @@ atlas-lint-all: ## Validate and lint all migration files
138130

139131
# Update migration directory hashes (called automatically by atlas-diff-all)
140132
atlas-hash-all:
141-
@atlas migrate hash --dir file://internal/query/migration/atlas/migrations/postgres 2>/dev/null || true
142-
@atlas migrate hash --dir file://internal/query/migration/atlas/migrations/mysql 2>/dev/null || true
143-
@atlas migrate hash --dir file://internal/query/migration/atlas/migrations/sqlite 2>/dev/null || true
133+
@atlas migrate hash --dir file://migrations/postgres 2>/dev/null || true
134+
@atlas migrate hash --dir file://migrations/mysql 2>/dev/null || true
135+
@atlas migrate hash --dir file://migrations/sqlite 2>/dev/null || true

taco/atlas.hcl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ variable "DB_URL" {
55

66
variable "POSTGRES_MIGRATIONS_DIR" {
77
type = string
8-
default = "file://internal/query/migration/atlas/migrations/postgres"
8+
default = "file://migrations/postgres"
99
}
1010

1111
variable "MYSQL_MIGRATIONS_DIR" {
1212
type = string
13-
default = "file://internal/query/migration/atlas/migrations/mysql"
13+
default = "file://migrations/mysql"
1414
}
1515

1616
variable "SQLITE_MIGRATIONS_DIR" {
1717
type = string
18-
default = "file://internal/query/migration/atlas/migrations/sqlite"
18+
default = "file://migrations/sqlite"
1919
}
2020

2121
data "external_schema" "gorm_postgres" {

taco/internal/query/migration/atlas/migrations/.gitkeep

Lines changed: 0 additions & 3 deletions
This file was deleted.

taco/internal/query/migration/atlas/migrations/README.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

taco/internal/query/migration/atlas/migrations/mysql/.gitkeep

Lines changed: 0 additions & 2 deletions
This file was deleted.

taco/internal/query/migration/atlas/migrations/sqlserver/.gitkeep

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)