From 1787a9090932fd43c03b8a2ce2c683d8e5b0fbd2 Mon Sep 17 00:00:00 2001 From: Arnaud Delcasse Date: Mon, 2 Mar 2026 20:41:59 +0100 Subject: [PATCH] Migrate CI to GitLab, clean up Dockerfile and repo --- .gitea/workflows/build.yml | 82 ------------------------------------- .gitignore | 2 + .gitlab-ci.yml | 31 ++++++++++++++ .idea/.gitignore | 8 ---- .idea/mobility-accounts.iml | 4 -- .idea/vcs.xml | 6 --- Dockerfile | 25 +++-------- 7 files changed, 39 insertions(+), 119 deletions(-) delete mode 100644 .gitea/workflows/build.yml create mode 100644 .gitlab-ci.yml delete mode 100644 .idea/.gitignore delete mode 100644 .idea/mobility-accounts.iml delete mode 100644 .idea/vcs.xml diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml deleted file mode 100644 index 912a100..0000000 --- a/.gitea/workflows/build.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: Build and Push Docker Image - -on: - push: - tags: - - '*' - branches: - - main - - dev - -jobs: - build_and_push: - runs-on: ubuntu-latest - - steps: - - name: Install Docker - run: | - apt-get update - apt-get install -y docker.io - - - name: Checkout Repository - uses: actions/checkout@v4 - - - name: Set Kubernetes Context - uses: azure/k8s-set-context@v4 - with: - method: kubeconfig - kubeconfig: ${{secrets.buildx_kubeconfig}} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - driver: kubernetes - driver-opts: | - namespace=gitea - - - name: Login to Docker Registry - uses: docker/login-action@v3 - with: - registry: git.coopgo.io - username: ${{ secrets.REGISTRY_USER }} - password: ${{ secrets.REGISTRY_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker image - id: metadata - uses: docker/metadata-action@v3 - with: - images: git.coopgo.io/${{gitea.repository}} - tags: | - type=ref,event=branch - type=ref,event=tag - type=ref,event=pr - flavor: | - latest=auto - - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: | - ${{ steps.metadata.outputs.tags }} - build-args: | - ACCESS_TOKEN_USR=${{gitea.actor}} - ACCESS_TOKEN_PWD=${{gitea.token}} - - # BUILD WITH KANIKO - # - name: Kaniko build and push - # uses: aevea/action-kaniko@master - # with: - # build_file: Dockerfile - # registry: git.coopgo.io - # username: ${{secrets.registry_user}} - # password: ${{secrets.registry_token}} - # image: ${{gitea.repository}} - # tag: ${{gitea.ref_name}} - # cache: true - # cache_registry: git.coopgo.io/${{gitea.repository}}/cache - # extra-args: | - # ACCESS_TOKEN_USR=${{gitea.actor}} - # ACCESS_TOKEN_PWD=${{gitea.token}} - diff --git a/.gitignore b/.gitignore index da7de7e..2d9baa7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ config.yaml .vscode +.idea/ __debug_bin mobility-accounts +build/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..2927d0f --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,31 @@ +stages: + - test + - publish + +variables: + GOLANG_VERSION: "1.24" + +default: + image: golang:${GOLANG_VERSION} + +test: + stage: test + script: + - go test ./... + +docker: + stage: publish + image: docker:latest + services: + - docker:dind + variables: + DOCKER_BUILDKIT: "1" + before_script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + script: + - docker build -t $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG . + - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG + - docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG $CI_REGISTRY_IMAGE:latest + - docker push $CI_REGISTRY_IMAGE:latest + rules: + - if: $CI_COMMIT_TAG diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/mobility-accounts.iml b/.idea/mobility-accounts.iml deleted file mode 100644 index 7ee078d..0000000 --- a/.idea/mobility-accounts.iml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ce3ab3e..40b53ae 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,15 @@ -FROM golang:alpine as builder +FROM golang:alpine AS builder -ARG ACCESS_TOKEN_USR="nothing" -ARG ACCESS_TOKEN_PWD="nothing" - -RUN apk add --no-cache ca-certificates tzdata - -WORKDIR / - -# Create a netrc file using the credentials specified using --build-arg -RUN printf "machine git.coopgo.io\n\ - login ${ACCESS_TOKEN_USR}\n\ - password ${ACCESS_TOKEN_PWD}\n"\ - >> ~/.netrc -RUN chmod 600 ~/.netrc +WORKDIR /app COPY . . -RUN go mod download && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /server +RUN CGO_ENABLED=0 go build -o /server + +FROM gcr.io/distroless/static:nonroot -FROM scratch -COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ -COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo COPY --from=builder /server / -COPY --from=builder /oidc-provider/web /oidc-provider/web +COPY --from=builder /app/oidc-provider/web /oidc-provider/web EXPOSE 8080 EXPOSE 80