From 0a1cf3d74b234097326674025a201023d57d01df Mon Sep 17 00:00:00 2001 From: Faberto Date: Thu, 25 Jan 2024 14:10:16 +0100 Subject: [PATCH] switch to ghcr --- .github/workflows/build-backend.yaml | 47 ++++++++++++++++++++ .github/workflows/build-frontend.yaml | 47 ++++++++++++++++++++ .gitlab-ci.yml | 63 --------------------------- Dockerfile | 3 ++ k8s/backend-deployment.yaml | 2 +- k8s/nuxt-deployment.yaml | 2 +- 6 files changed, 99 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/build-backend.yaml create mode 100644 .github/workflows/build-frontend.yaml delete mode 100644 .gitlab-ci.yml diff --git a/.github/workflows/build-backend.yaml b/.github/workflows/build-backend.yaml new file mode 100644 index 0000000..ab60ca9 --- /dev/null +++ b/.github/workflows/build-backend.yaml @@ -0,0 +1,47 @@ +name: Build Backend Docker Image + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + release: + types: [ created ] + +permissions: + contents: read + packages: write + +jobs: + build_docker: + runs-on: ubuntu-22.04 + name: Build & publish docker image + steps: + - name: Check out the repo + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }}-backend + flavor: latest=true + + - name: Login to image repository + if: github.ref_type == 'tag' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 + with: + context: ./backend + file: backend/Dockerfile + push: ${{ github.ref_type == 'tag' }} + provenance: false + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/build-frontend.yaml b/.github/workflows/build-frontend.yaml new file mode 100644 index 0000000..118397b --- /dev/null +++ b/.github/workflows/build-frontend.yaml @@ -0,0 +1,47 @@ +name: Build Frontend Docker Image + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + release: + types: [ created ] + +permissions: + contents: read + packages: write + +jobs: + build_docker: + runs-on: ubuntu-22.04 + name: Build & publish docker image + steps: + - name: Check out the repo + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }}-frontend + flavor: latest=true + + - name: Login to image repository + if: github.ref_type == 'tag' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 + with: + context: . + file: Dockerfile + push: ${{ github.ref_type == 'tag' }} + provenance: false + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index d897f15..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,63 +0,0 @@ -image: node:20.11.0-alpine3.19 - -stages: - - lint - - docker-build - -include: - # include the component located in the current project from the current SHA - - component: $CI_SERVER_HOST/mondata/devops/typescript-cicd-components/lint@1.0.0 - inputs: - image: node:20.11.0-alpine3.19 - lintOptions: --quiet # lint only for errors - -docker-build-backend: - stage: docker-build - tags: - - docker-builds # use runner that can perform docker builds - - image: docker:23.0.1 - services: - - docker:23.0.1-dind - - variables: - IMAGE: docker.io/mondata/staqe-backend - - script: - - cd backend - - docker --version - - docker info - - docker build -t $IMAGE:latest . - # only push if we are on a tag - - | - if [ "$CI_COMMIT_TAG" ]; then - docker login -u mondata -p $DOCKER_HUB_PASSWORD - docker tag $IMAGE:latest $IMAGE:$CI_COMMIT_TAG - docker push $IMAGE:$CI_COMMIT_TAG - docker push $IMAGE:latest - fi - -docker-build-frontend: - stage: docker-build - tags: - - docker-builds # use runner that can perform docker builds - - image: docker:23.0.1 - services: - - docker:23.0.1-dind - - variables: - IMAGE: docker.io/mondata/staqe-app - - script: - - docker --version - - docker info - - docker build -t $IMAGE:latest . - # only push if we are on a tag - - | - if [ "$CI_COMMIT_TAG" ]; then - docker login -u mondata -p $DOCKER_HUB_PASSWORD - docker tag $IMAGE:latest $IMAGE:$CI_COMMIT_TAG - docker push $IMAGE:$CI_COMMIT_TAG - docker push $IMAGE:latest - fi diff --git a/Dockerfile b/Dockerfile index e12b23f..4729fc5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,9 @@ RUN --mount=type=cache,target=/root/.npm \ # copy over all files to the work directory ADD . /app +# make the postbuild.sh executable +RUN chmod +x /app/postbuild.sh + # In the first build there sometimes is a problem with the # stq-card-header-large-font; however this problem typically # disappears in the second build diff --git a/k8s/backend-deployment.yaml b/k8s/backend-deployment.yaml index 0275687..9a48362 100644 --- a/k8s/backend-deployment.yaml +++ b/k8s/backend-deployment.yaml @@ -20,7 +20,7 @@ spec: serviceAccountName: staqe-backend containers: - name: staqe - image: docker.io/mondata/staqe-backend:latest + image: ghcr.io/mondata-dev/staqe-backend:latest ports: - name: http containerPort: 3300 diff --git a/k8s/nuxt-deployment.yaml b/k8s/nuxt-deployment.yaml index 4a4e3ba..493c5e8 100644 --- a/k8s/nuxt-deployment.yaml +++ b/k8s/nuxt-deployment.yaml @@ -20,7 +20,7 @@ spec: spec: containers: - name: nuxt - image: docker.io/mondata/staqe-app:latest + image: ghcr.io/mondata-dev/staqe-frontend:latest ports: - name: http containerPort: 3000