From 12964dfd1a16a1252f9910f4c99162caf28a6876 Mon Sep 17 00:00:00 2001 From: chabanyknikita Date: Wed, 20 Nov 2024 19:19:09 +0200 Subject: [PATCH 1/6] try to fix ci with new version of werf --- .github/workflows/actions.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index a2d57e3d..19aa1cf1 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -13,7 +13,7 @@ jobs: fetch-depth: 0 - name: Install werf - uses: werf/actions/install@v1.2 + uses: werf/actions/install@v2 - name: Log in to registry # This is where you will update the personal access token to GITHUB_TOKEN From 6f66beac93af3fd5debe7eb76e7678d33efc750b Mon Sep 17 00:00:00 2001 From: chabanyknikita Date: Wed, 20 Nov 2024 19:36:29 +0200 Subject: [PATCH 2/6] migrate from werf to skaffold --- .github/workflows/actions.yml | 30 ++++++++++--------- .github/workflows/actions_onlymain.yml | 34 ++++++++++----------- .github/workflows/tag.yml | 30 ++++++++++--------- Dockerfile | 19 ++++++++++++ skaffold.yaml | 10 +++++++ werf-giterminism.yaml | 4 --- werf.yaml | 41 -------------------------- 7 files changed, 78 insertions(+), 90 deletions(-) create mode 100644 Dockerfile create mode 100644 skaffold.yaml delete mode 100644 werf-giterminism.yaml delete mode 100644 werf.yaml diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 19aa1cf1..329671ce 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -12,23 +12,25 @@ jobs: with: fetch-depth: 0 - - name: Install werf - uses: werf/actions/install@v2 - - name: Log in to registry # This is where you will update the personal access token to GITHUB_TOKEN - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - - - name: Run echo - run: | - werf version - docker version - echo $GITHUB_REPOSITORY - echo $GITHUB_SHA - - name: Run Build run: | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin export URL="https://staging.docs.rarimo.com" export BASE_URL="/" export STAGING="true" - . $(werf ci-env github --as-file) - werf export --dev web --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA + + - name: Cache layers + uses: actions/cache@v3 + with: + path: "${{ github.workspace }}/.skaffold/cache" + key: skaffold-${{ hashFiles('**/cache') }} + restore-keys: | + skaffold- + + - name: Run Skaffold pipeline as command + uses: hiberbee/github-action-skaffold@latest + id: build + with: + command: build --tag ${{ github.sha }} + repository: ghcr.io/${{ github.repository_owner }} diff --git a/.github/workflows/actions_onlymain.yml b/.github/workflows/actions_onlymain.yml index 3899de39..b7cdb688 100644 --- a/.github/workflows/actions_onlymain.yml +++ b/.github/workflows/actions_onlymain.yml @@ -2,6 +2,7 @@ on: push: branches: - 'main' + - 'devops/ci' env: IMAGE_NAME: ghcr.io/${{ github.repository }}:${{github.sha}} @@ -19,29 +20,28 @@ jobs: with: fetch-depth: 0 - - name: Install werf - uses: werf/actions/install@v1.2 - - name: Log in to registry # This is where you will update the personal access token to GITHUB_TOKEN - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - - - name: Run echo - run: | - werf version - docker version - echo $GITHUB_REPOSITORY - echo $GITHUB_SHA - - name: Run Build - env: # Or as an environment variable - BASE_URL: "/" - STAGING: "true" run: | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin export URL="https://staging.docs.rarimo.com" export BASE_URL="/" export STAGING="true" - . $(werf ci-env github --as-file) - werf export --dev web --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_SHA + + - name: Cache layers + uses: actions/cache@v3 + with: + path: "${{ github.workspace }}/.skaffold/cache" + key: skaffold-${{ hashFiles('**/cache') }} + restore-keys: | + skaffold- + + - name: Run Skaffold pipeline as command + uses: hiberbee/github-action-skaffold@latest + id: build + with: + command: build --tag ${{ github.sha }} + repository: ghcr.io/${{ github.repository_owner }} deploy: name: Deploy diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 1d8683a5..8d186b13 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -19,26 +19,28 @@ jobs: with: fetch-depth: 0 - - name: Install werf - uses: werf/actions/install@v1.2 - - name: Log in to registry # This is where you will update the personal access token to GITHUB_TOKEN - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - - - name: Run echo - run: | - werf version - docker version - echo $GITHUB_REPOSITORY - echo $GITHUB_REF_NAME - - name: Run Build run: | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin export URL="https://docs.rarimo.com" export BASE_URL="/" export STAGING="false" - . $(werf ci-env github --as-file) - werf export --dev web --tag ghcr.io/$GITHUB_REPOSITORY:$GITHUB_REF_NAME + + - name: Cache layers + uses: actions/cache@v3 + with: + path: "${{ github.workspace }}/.skaffold/cache" + key: skaffold-${{ hashFiles('**/cache') }} + restore-keys: | + skaffold- + + - name: Run Skaffold pipeline as command + uses: hiberbee/github-action-skaffold@latest + id: build + with: + command: build --tag ${{ github.ref_name }} + repository: ghcr.io/${{ github.repository_owner }} deploy: name: Deploy diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..a2f5119a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM node:18-alpine3.18 as builder +RUN apk update && apk --no-cache add git + +ARG BASE_URL +ARG URL +ARG STAGING + +WORKDIR /build +COPY package.json yarn.lock .yarnrc.yml ./ +COPY .yarn .yarn +RUN yarn set version 4.3.1 +RUN yarn + +COPY . . +RUN yarn build + +FROM nginx:1.20.2-alpine +COPY nginx.conf /etc/nginx/nginx.conf +COPY --from=builder /build/dist /usr/share/nginx/html \ No newline at end of file diff --git a/skaffold.yaml b/skaffold.yaml new file mode 100644 index 00000000..11fd8e6d --- /dev/null +++ b/skaffold.yaml @@ -0,0 +1,10 @@ +apiVersion: skaffold/v2beta28 +kind: Config +build: + artifacts: + - image: docs + docker: + buildArgs: + BASE_URL: "{{.BASE_URL}}" + URL: "{{.URL}}" + STAGING: "{{.STAGING}}" \ No newline at end of file diff --git a/werf-giterminism.yaml b/werf-giterminism.yaml deleted file mode 100644 index f95f490e..00000000 --- a/werf-giterminism.yaml +++ /dev/null @@ -1,4 +0,0 @@ -giterminismConfigVersion: 1 -config: - goTemplateRendering: - allowEnvVariables: ["URL", "BASE_URL", "STAGING"] diff --git a/werf.yaml b/werf.yaml deleted file mode 100644 index 83c1df2b..00000000 --- a/werf.yaml +++ /dev/null @@ -1,41 +0,0 @@ -configVersion: 1 -project: "docs" ---- -image: builder -from: node:18-alpine3.18 -git: - - add: / - to: /app - stageDependencies: - install: - - package.json - - yarn.lock - setup: - - "**/*" -shell: - beforeInstall: - # git is required for the showLastUpdate feature in docusaurus - - apk update && apk --no-cache add git - install: - - cd /app - #- yarn autoclean --init - #- yarn autoclean --force - - yarn - setup: - - export BASE_URL={{ env "BASE_URL" }} - - export URL={{ env "URL" }} - - export STAGING={{ env "STAGING" }} - - cd /app - - yarn build - ---- -image: web -from: nginx:alpine -git: - - add: /nginx.conf - to: /etc/nginx/nginx.conf -import: - - image: builder - add: /app/build - to: /usr/share/nginx/html - after: setup From 5c5d387ec477677e83e4add0a9ee309a7c3e3fd9 Mon Sep 17 00:00:00 2001 From: chabanyknikita Date: Wed, 20 Nov 2024 19:38:01 +0200 Subject: [PATCH 3/6] try to fix Dockerfile --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index a2f5119a..da062e9b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,8 +7,6 @@ ARG STAGING WORKDIR /build COPY package.json yarn.lock .yarnrc.yml ./ -COPY .yarn .yarn -RUN yarn set version 4.3.1 RUN yarn COPY . . From 206e59b38d391774ce8b143247d82df2601b98b4 Mon Sep 17 00:00:00 2001 From: chabanyknikita Date: Wed, 20 Nov 2024 19:39:16 +0200 Subject: [PATCH 4/6] delete copy file yarnrc from Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index da062e9b..96ca0b29 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ ARG URL ARG STAGING WORKDIR /build -COPY package.json yarn.lock .yarnrc.yml ./ +COPY package.json yarn.lock ./ RUN yarn COPY . . From e87968d072af5ed68049e64dad525d75d4c28301 Mon Sep 17 00:00:00 2001 From: chabanyknikita Date: Wed, 20 Nov 2024 19:43:07 +0200 Subject: [PATCH 5/6] Change copy directory for build app in Dockerfile --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 96ca0b29..6ea76052 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ ARG BASE_URL ARG URL ARG STAGING -WORKDIR /build +WORKDIR /app COPY package.json yarn.lock ./ RUN yarn @@ -14,4 +14,4 @@ RUN yarn build FROM nginx:1.20.2-alpine COPY nginx.conf /etc/nginx/nginx.conf -COPY --from=builder /build/dist /usr/share/nginx/html \ No newline at end of file +COPY --from=builder /app/build /usr/share/nginx/html \ No newline at end of file From 422b85eef5c3711a7f07459b68b336f21dbb6efa Mon Sep 17 00:00:00 2001 From: chabanyknikita Date: Wed, 20 Nov 2024 20:45:53 +0200 Subject: [PATCH 6/6] try to fix docusaurus base_url --- .github/workflows/actions.yml | 8 +++++--- .github/workflows/actions_onlymain.yml | 5 ++--- .github/workflows/tag.yml | 7 +++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 329671ce..91bdde1d 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -1,6 +1,11 @@ on: workflow_dispatch: +env: + BASE_URL: "/" + URL: "https://staging.docs.rarimo.com" + STAGING: "true" + jobs: converge: name: Converge @@ -16,9 +21,6 @@ jobs: # This is where you will update the personal access token to GITHUB_TOKEN run: | echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - export URL="https://staging.docs.rarimo.com" - export BASE_URL="/" - export STAGING="true" - name: Cache layers uses: actions/cache@v3 diff --git a/.github/workflows/actions_onlymain.yml b/.github/workflows/actions_onlymain.yml index b7cdb688..6bbfab35 100644 --- a/.github/workflows/actions_onlymain.yml +++ b/.github/workflows/actions_onlymain.yml @@ -8,6 +8,8 @@ env: IMAGE_NAME: ghcr.io/${{ github.repository }}:${{github.sha}} URL: "https://staging.docs.rarimo.com" DOMAIN: staging.docs.rarimo.com + BASE_URL: "/" + STAGING: "true" jobs: converge: @@ -24,9 +26,6 @@ jobs: # This is where you will update the personal access token to GITHUB_TOKEN run: | echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - export URL="https://staging.docs.rarimo.com" - export BASE_URL="/" - export STAGING="true" - name: Cache layers uses: actions/cache@v3 diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 8d186b13..dbd3806b 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -5,8 +5,10 @@ on: env: IMAGE_NAME: ghcr.io/${{ github.repository }}:${{github.ref_name}} - URL: "https://staging.docs.rarimo.com" + URL: "https://docs.rarimo.com" DOMAIN: staging.docs.rarimo.com + BASE_URL: "/" + STAGING: "false" jobs: converge: @@ -23,9 +25,6 @@ jobs: # This is where you will update the personal access token to GITHUB_TOKEN run: | echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin - export URL="https://docs.rarimo.com" - export BASE_URL="/" - export STAGING="false" - name: Cache layers uses: actions/cache@v3