ikurotime / gitgud

public
Add Docker support with Dockerfile and GitHub Actions workflow
DDavid committed on 2026-08-09 16:05 commit 46cf7da
.dockerignore +12 −0
+.git
+.github
+.claude
+.air.toml
+.env
+tmp
+data
+docs
+main
+README.md
+**/*.log
+**/.DS_Store
.github/workflows/deploy.yml +58 −0
+name: Build and Push Docker Image
+
+on:
+ push:
+ branches: ["main"]
+ workflow_dispatch:
+
+jobs:
+ build-and-push:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ packages: write
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Log in to GitHub Container Registry
+ uses: docker/login-action@v3
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Extract metadata (for tags)
+ id: meta
+ uses: docker/metadata-action@v5
+ with:
+ images: ghcr.io/${{ github.repository }}
+ tags: |
+ type=raw,value=latest
+ type=raw,value=main-${{ github.sha }}
+ labels: |
+ org.opencontainers.image.revision=${{ github.sha }}
+
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ file: ./Dockerfile
+ push: true
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
+ platforms: linux/amd64
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
+
+ - name: Trigger Dokploy deployment
+ if: success()
+ run: |
+ curl -X POST "${{ secrets.DOKPLOY_WEBHOOK_URL }}" \
+ -H "Content-Type: application/json" \
+ -w "\nHTTP Status: %{http_code}\n" \
+ --fail-with-body
Dockerfile +34 −0
+# syntax=docker/dockerfile:1
+
+FROM golang:1.25-bookworm AS builder
+
+WORKDIR /src
+
+ENV CGO_ENABLED=1
+
+COPY go.mod go.sum ./
+RUN go mod download
+
+COPY . .
+RUN go build -trimpath -ldflags="-s -w" -o /out/gitgud ./cmd/server
+
+FROM debian:bookworm-slim AS runtime
+
+RUN apt-get update \
+ && apt-get install -y --no-install-recommends \
+ ca-certificates \
+ git \
+ && rm -rf /var/lib/apt/lists/*
+
+WORKDIR /app
+COPY --from=builder /out/gitgud /app/gitgud
+
+ENV GITGUD_ADDR=:8080 \
+ GITGUD_DATA_DIR=/data
+
+RUN mkdir -p /data
+VOLUME ["/data"]
+
+EXPOSE 8080
+
+CMD ["/app/gitgud"]
internal/infra/config/config.go +2 −4
package config
import (
"os"
"path/filepath"
"github.com/joho/godotenv"
)
type Config struct {
Addr string
DataDir string
SessionKey string // random string
}
func (c Config) DBPath() string {
return filepath.Join(c.DataDir, "app.db")
}
func (c Config) ReposDir() string {
return filepath.Join(c.DataDir, "repos")
}
func Load() (Config, error) {
- err := godotenv.Load()
- if err != nil {
- return Config{}, err
- }
+ // Load .env if present; in containers config comes from real env vars.
+ _ = godotenv.Load()
dataDir, err := filepath.Abs(os.Getenv("GITGUD_DATA_DIR"))
if err != nil {
return Config{}, err
}
return Config{
Addr: os.Getenv("GITGUD_ADDR"),
DataDir: dataDir,
SessionKey: os.Getenv("GITGUD_SESSION_KEY"),
}, nil
}