From 8da033a2ff8d267c33b8a3ad0c8b0431d0d9f159 Mon Sep 17 00:00:00 2001 From: Jeremy Mouton Date: Fri, 5 Sep 2025 10:54:23 +0200 Subject: [PATCH 1/5] rename file --- cmd/{main.go => cmd.go} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cmd/{main.go => cmd.go} (100%) diff --git a/cmd/main.go b/cmd/cmd.go similarity index 100% rename from cmd/main.go rename to cmd/cmd.go From 7368c93093f30d0411ea8c45f57b7cc574efc6f3 Mon Sep 17 00:00:00 2001 From: Jeremy Mouton Date: Fri, 5 Sep 2025 10:54:33 +0200 Subject: [PATCH 2/5] rename go file --- .air.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.air.toml b/.air.toml index 3ed4185..27de50a 100644 --- a/.air.toml +++ b/.air.toml @@ -5,7 +5,7 @@ tmp_dir = "tmp" [build] bin = "./tmp/main" args_bin = ["server", "-c", "./config.yaml"] - cmd = "go build -o ./tmp/main cmd/main.go" + cmd = "go build -o ./tmp/main cmd/cmd.go" delay = 1000 exclude_dir = ["assets", "tmp", "vendor", "testdata", "repositories"] exclude_file = [] From ffde2637fd59f6ae8812798fe2b05027a8413391 Mon Sep 17 00:00:00 2001 From: Jeremy Mouton Date: Fri, 5 Sep 2025 10:54:44 +0200 Subject: [PATCH 3/5] add dockerfile --- Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3299785 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM golang:1.23 as builder + +WORKDIR /app +COPY bin/app /app/bin/app + +FROM alpine:latest as release +RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/* +COPY --from=builder /app/bin/app . +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file From 485e0d4e5a83a3c33441b4c4f66bc6db2ca45210 Mon Sep 17 00:00:00 2001 From: Jeremy Mouton Date: Fri, 5 Sep 2025 10:54:56 +0200 Subject: [PATCH 4/5] add entrypoint script for start app --- entrypoint.sh | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..dccfc56 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +# Start the migration +# ./app migration -c /config/config.yaml + +# Start the server +exec ./app server -c /config/config.yaml \ No newline at end of file From 3547b5be858919d7d5cb8d3bfbceec6cac5cf3f2 Mon Sep 17 00:00:00 2001 From: Jeremy Mouton Date: Fri, 5 Sep 2025 10:55:10 +0200 Subject: [PATCH 5/5] add 2 pipelines --- .github/workflows/pr.yaml | 36 +++++++++++++++++++ .github/workflows/release.yaml | 63 ++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 .github/workflows/pr.yaml create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml new file mode 100644 index 0000000..72beb7c --- /dev/null +++ b/.github/workflows/pr.yaml @@ -0,0 +1,36 @@ +name: PR + +on: + pull_request: + branches: + - main + +permissions: + contents: write + packages: write + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + cache-dependency-path: go.sum + + - uses: nowsprinting/check-version-format-action@v3 + if: github.event_name != 'pull_request' + id: version + with: + prefix: 'v' + + - name: Build app + run: CGO_ENABLED=1 GOOS=linux go build -a -ldflags '-linkmode external -extldflags "-static" -X "main.version=${{ steps.version.outputs.full }}"' -o bin/app cmd/cmd.go \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..ef6fb2c --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,63 @@ +name: Release + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + packages: write + +env: + REGISTRY: ghcr.io + IMAGE: ${{ github.repository }} + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + cache: true + cache-dependency-path: go.sum + + - uses: nowsprinting/check-version-format-action@v3 + if: github.event_name != 'pull_request' + id: version + with: + prefix: 'v' + + - name: Build app + run: CGO_ENABLED=1 GOOS=linux go build -a -ldflags '-linkmode external -extldflags "-static" -X "main.version=${{ steps.version.outputs.full }}"' -o bin/app cmd/cmd.go + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE }} + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + if: github.event_name != 'pull_request' + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + 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 }} \ No newline at end of file