Skip to content

Commit 2b25839

Browse files
committed
Initial load, tested postgresql and mariadb/mysql
0 parents  commit 2b25839

File tree

13 files changed

+1361
-0
lines changed

13 files changed

+1361
-0
lines changed

.github/workflows/docker-build.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Build and Push Docker Image (AMD64 only)
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
tags:
9+
- 'v*'
10+
pull_request:
11+
branches:
12+
- main
13+
- master
14+
15+
env:
16+
REGISTRY: ghcr.io
17+
IMAGE_NAME: ${{ github.repository }}
18+
19+
jobs:
20+
build-and-push:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
packages: write
25+
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
33+
- name: Log in to GitHub Container Registry
34+
if: github.event_name != 'pull_request'
35+
uses: docker/login-action@v3
36+
with:
37+
registry: ${{ env.REGISTRY }}
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Extract metadata (tags, labels)
42+
id: meta
43+
uses: docker/metadata-action@v5
44+
with:
45+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
46+
tags: |
47+
type=raw,value=latest,enable={{is_default_branch}}
48+
type=semver,pattern={{version}}
49+
type=semver,pattern={{major}}.{{minor}}
50+
type=semver,pattern={{major}}
51+
type=ref,event=branch
52+
type=ref,event=pr
53+
type=sha,prefix={{branch}}-
54+
55+
- name: Build and push Docker image
56+
id: build
57+
uses: docker/build-push-action@v5
58+
with:
59+
context: .
60+
push: ${{ github.event_name != 'pull_request' }}
61+
tags: ${{ steps.meta.outputs.tags }}
62+
labels: ${{ steps.meta.outputs.labels }}
63+
cache-from: type=gha
64+
cache-to: type=gha,mode=max
65+
platforms: linux/amd64

Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM golang:1.21-alpine AS builder
2+
WORKDIR /app
3+
4+
# Install build dependencies
5+
RUN apk add --no-cache git ca-certificates
6+
7+
# Copy go mod files
8+
COPY go.mod go.sum ./
9+
10+
# Download dependencies
11+
RUN go mod download
12+
13+
# Copy source code
14+
COPY main.go ./
15+
16+
# Build the application with static linking
17+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -a -ldflags '-extldflags "-static"' -o provisioner .
18+
19+
# Final stage - use distroless for smaller, more secure image
20+
FROM gcr.io/distroless/static-debian12:nonroot
21+
22+
WORKDIR /app
23+
24+
# Copy CA certificates and binary from builder
25+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
26+
COPY --from=builder /app/provisioner .
27+
28+
# Set default config path
29+
ENV CONFIG_PATH=/config/config.json
30+
31+
USER nonroot:nonroot
32+
33+
ENTRYPOINT ["/app/provisioner"]

0 commit comments

Comments
 (0)