Skip to content

Commit 28291d6

Browse files
committed
feat: add standalone rds-refresh component
Add a fully standalone version of the RDS/Aurora refresh tool that can be built and deployed immediately without requiring a DBLab Engine release. This version has no dependencies on DBLab internal packages. The standalone component includes: - Self-contained Go module with minimal dependencies - Makefile for easy building (CLI, Lambda, Docker) - SAM template for AWS Lambda deployment - Dockerfile for container builds - Comprehensive documentation Can be used immediately by: 1. go build -o rds-refresh . 2. ./rds-refresh -config config.yaml
1 parent 7b69090 commit 28291d6

File tree

12 files changed

+2299
-0
lines changed

12 files changed

+2299
-0
lines changed

rds-refresh/Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Build stage
2+
FROM golang:1.21-alpine AS builder
3+
4+
RUN apk add --no-cache git ca-certificates
5+
6+
WORKDIR /build
7+
8+
# Copy go mod files first for better caching
9+
COPY go.mod go.sum ./
10+
RUN go mod download
11+
12+
# Copy source code
13+
COPY *.go ./
14+
15+
# Build the binary
16+
ARG VERSION=dev
17+
ARG BUILD_TIME=unknown
18+
19+
RUN CGO_ENABLED=0 GOOS=linux go build \
20+
-ldflags="-s -w -X main.version=${VERSION} -X main.buildTime=${BUILD_TIME}" \
21+
-o /rds-refresh \
22+
.
23+
24+
# Runtime stage
25+
FROM alpine:3.19
26+
27+
RUN apk add --no-cache ca-certificates tzdata
28+
29+
# Create non-root user
30+
RUN adduser -D -u 1000 appuser
31+
32+
WORKDIR /app
33+
34+
COPY --from=builder /rds-refresh /usr/local/bin/rds-refresh
35+
36+
USER appuser
37+
38+
ENTRYPOINT ["/usr/local/bin/rds-refresh"]
39+
CMD ["--help"]

rds-refresh/Makefile

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
.PHONY: build build-linux build-lambda clean test fmt vet
2+
3+
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
4+
BUILD_TIME ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
5+
LDFLAGS = -ldflags "-s -w -X main.version=$(VERSION) -X main.buildTime=$(BUILD_TIME)"
6+
7+
# Build for current platform
8+
build:
9+
go build $(LDFLAGS) -o rds-refresh .
10+
11+
# Build for Linux (for Docker/Lambda)
12+
build-linux:
13+
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o rds-refresh-linux-amd64 .
14+
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o rds-refresh-linux-arm64 .
15+
16+
# Build Lambda bootstrap binary
17+
build-lambda:
18+
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build $(LDFLAGS) -o bootstrap .
19+
zip rds-refresh-lambda.zip bootstrap
20+
rm bootstrap
21+
22+
# Clean build artifacts
23+
clean:
24+
rm -f rds-refresh rds-refresh-linux-* bootstrap rds-refresh-lambda.zip
25+
26+
# Run tests
27+
test:
28+
go test -v ./...
29+
30+
# Format code
31+
fmt:
32+
go fmt ./...
33+
34+
# Run go vet
35+
vet:
36+
go vet ./...
37+
38+
# Download dependencies
39+
deps:
40+
go mod download
41+
go mod tidy
42+
43+
# Run locally (requires config.yaml)
44+
run:
45+
go run . -config config.yaml
46+
47+
# Run dry-run locally
48+
dry-run:
49+
go run . -config config.yaml -dry-run

0 commit comments

Comments
 (0)