summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorexatombe <jeremy27.clara22@gmail.com>2025-10-27 21:53:01 +0100
committerexatombe <jeremy27.clara22@gmail.com>2025-10-27 21:53:01 +0100
commit46255f5cae1c8314800817db17be3b3ebefb7983 (patch)
treea8deeb4644527d6a3f6ce1cd075cd0f6fee61db9
parent90c234ad70a387b371a1fdbc78b0799c6a889f26 (diff)
Supprimer le workflow Hello World et ajouter un workflow Docker CI pour construire et pousser l'image Docker
-rw-r--r--.dockerignore47
-rw-r--r--.forgejo/workflows/docker-ci.yml50
-rw-r--r--.forgejo/workflows/hello-world.yml17
-rw-r--r--Dockerfile45
4 files changed, 142 insertions, 17 deletions
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..5509e3c
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,47 @@
+# Git
+.git
+.gitignore
+.gitattributes
+
+# CI/CD
+.forgejo
+.github
+
+# Documentation
+README.md
+docs/
+LICENSE
+
+# Development
+.devenv
+.direnv
+devenv.nix
+devenv.yaml
+devenv.lock
+
+# Build artifacts
+*.out
+*.test
+coverage.txt
+
+# IDE
+.vscode
+.idea
+*.swp
+*.swo
+*~
+
+# OS
+.DS_Store
+Thumbs.db
+
+# Tests
+tests/
+
+# Scripts
+scripts/
+
+# Temporary files
+tmp/
+temp/
+*.tmp
diff --git a/.forgejo/workflows/docker-ci.yml b/.forgejo/workflows/docker-ci.yml
new file mode 100644
index 0000000..734e11e
--- /dev/null
+++ b/.forgejo/workflows/docker-ci.yml
@@ -0,0 +1,50 @@
+name: Build and Push Docker Image
+
+on:
+ push:
+ branches:
+ - main
+ pull_request:
+ workflow_dispatch:
+
+jobs:
+ build:
+ runs-on: docker
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
+
+ - name: Login to Forgejo Container Registry
+ if: github.event_name != 'pull_request'
+ uses: docker/login-action@v3
+ with:
+ registry: ${{ env.REPO_URL }}
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Extract metadata
+ id: meta
+ uses: docker/metadata-action@v5
+ with:
+ images: ${{ env.REPO_URL }}/${{ github.repository }}
+ tags: |
+ type=ref,event=branch
+ type=ref,event=pr
+ type=semver,pattern={{version}}
+ type=semver,pattern={{major}}.{{minor}}
+ type=sha,prefix={{branch}}-
+ type=raw,value=latest,enable={{is_default_branch}}
+
+ - name: Build and push Docker image
+ uses: docker/build-push-action@v5
+ with:
+ context: .
+ file: ./Dockerfile
+ push: ${{ github.event_name != 'pull_request' }}
+ tags: ${{ steps.meta.outputs.tags }}
+ labels: ${{ steps.meta.outputs.labels }}
+ cache-from: type=gha
+ cache-to: type=gha,mode=max
diff --git a/.forgejo/workflows/hello-world.yml b/.forgejo/workflows/hello-world.yml
deleted file mode 100644
index 51b8052..0000000
--- a/.forgejo/workflows/hello-world.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-name: Hello World
-
-on:
- push:
- branches:
- - main
- pull_request:
- workflow_dispatch:
-
-jobs:
- hello:
- runs-on: docker
- steps:
- - name: checkout code
- uses: actions/checkout@v4
- - name: list directory contents
- run: ls -la
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..9fffe62
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,45 @@
+# Stage 1: Build
+FROM golang:1.25.2-alpine AS builder
+
+# Install build dependencies
+RUN apk add --no-cache git ca-certificates tzdata
+
+WORKDIR /build
+
+# Copy go mod files
+COPY go.mod go.sum ./
+
+# Download dependencies
+RUN go mod download
+
+# Copy source code
+COPY . .
+
+# Build the application
+# CGO_ENABLED=0 for static binary
+# -ldflags="-w -s" to strip debug info and reduce binary size
+RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
+ -ldflags="-w -s" \
+ -o sovrabase \
+ ./cmd/server/main.go
+
+# Stage 2: Runtime
+FROM scratch
+
+# Copy CA certificates for HTTPS
+COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
+
+# Copy timezone data
+COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
+
+# Copy binary
+COPY --from=builder /build/sovrabase /sovrabase
+
+# Copy config file
+COPY --from=builder /build/config.toml /config.toml
+
+# Expose gRPC port (adjust based on your config)
+EXPOSE 50051
+
+# Run the application
+ENTRYPOINT ["/sovrabase"]