From 1b9a5e03953085724775e2fcd887d69a732b72d1 Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Wed, 23 Feb 2022 23:10:43 +0700 Subject: [PATCH] Enable hardcoreeng docker hub (#1048) Signed-off-by: Andrey Sobolev --- .github/workflows/main.yml | 59 +++++++++++++++++++++++++++- common/config/rush/command-line.json | 10 +++++ common/scripts/docker_tag.sh | 18 +++++++++ dev/docker-compose.yaml | 6 +-- dev/tool/package.json | 6 +-- models/all/src/__bumpversion.ts | 2 +- models/all/src/__showversion.ts | 2 +- models/all/src/version.json | 2 +- pods/account/kube/deployment.yml | 2 +- pods/account/package.json | 5 ++- server/front/Dockerfile | 2 +- server/front/kube/front.yml | 2 +- server/front/package.json | 7 ++-- server/server/Dockerfile | 2 +- server/server/kube/transactor.yml | 2 +- server/server/package.json | 5 ++- tests/docker-compose.yaml | 6 +-- 17 files changed, 113 insertions(+), 25 deletions(-) create mode 100755 common/scripts/docker_tag.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a515c4b701..3a8dbe462c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,6 +9,9 @@ on: branches: [ main, develop ] pull_request: branches: [ main, develop ] + create: + tags: + - v* # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -239,4 +242,58 @@ jobs: uses: actions/upload-artifact@v2 with: name: playwright-results - path: ./tests/sanity/playwright-report/ \ No newline at end of file + path: ./tests/sanity/playwright-report/ + docker-build: + if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }} + needs: [ build, uitest, test, linting, svelte-check ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Cache build results + uses: actions/cache@v2 + env: + cache-name: cache-build-results + with: + path: | + cloud + common + deploy + dev + models + packages + plugins + pods + server + server-plugins + templates + tests + rush.json + .prettierrc + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }} + restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.sha }} + + - name: Installing... + run: node common/scripts/install-run-rush.js install + - name: Setting model version from git release... + run: node common/scripts/install-run-rush.js bump-model-version + - name: Bundle + run: node common/scripts/install-run-rush.js bundle + - name: Docker build + run: node common/scripts/install-run-rush.js docker:build + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: hardcoreeng + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + + - name: Docker push staging + if: ${{ github.ref == 'refs/heads/main' }} + run: node common/scripts/install-run-rush.js docker:staging + - name: Docker push tag + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + run: | + echo Pushing release of tag ${{ github.ref }} + node common/scripts/install-run-rush.js docker:push diff --git a/common/config/rush/command-line.json b/common/config/rush/command-line.json index 60ed00aeb1..28e6e5e0a0 100644 --- a/common/config/rush/command-line.json +++ b/common/config/rush/command-line.json @@ -228,6 +228,16 @@ "ignoreDependencyOrder": false, "ignoreMissingScript": true }, + { + "commandKind": "bulk", + "name": "docker:staging", + "summary": "docker:staging", + "description": "Push docker staging images", + "enableParallelism": true, + "incremental": true, + "ignoreDependencyOrder": false, + "ignoreMissingScript": true + }, { "commandKind": "bulk", "name": "bundle", diff --git a/common/scripts/docker_tag.sh b/common/scripts/docker_tag.sh new file mode 100755 index 0000000000..ec0574be47 --- /dev/null +++ b/common/scripts/docker_tag.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +version=$(git describe --tags --abbrev=0) + +if [ "x$2" = "xstaging" ] +then + a=( ${version//./ } ) + ((a[2]++)) + version="${a[0]}.${a[1]}.${a[2]}-staging" + echo "Tagging stating $1 with version ${version}" + docker tag "$1" "$1:$version" + docker push "$1:$version" +else + echo "Tagging release $1 with version ${version}" + docker tag "$1" "$1:$version" + docker push "$1:$version" + docker push "$1:latest" +fi diff --git a/dev/docker-compose.yaml b/dev/docker-compose.yaml index 17fe333a99..0cf34f621d 100644 --- a/dev/docker-compose.yaml +++ b/dev/docker-compose.yaml @@ -40,7 +40,7 @@ services: retries: 10 test: curl -s http://localhost:9200/_cluster/health | grep -vq '"status":"red"' account: - image: anticrm/account + image: hardcoreeng/account links: - mongodb - minio @@ -55,7 +55,7 @@ services: - MINIO_ACCESS_KEY=minioadmin - MINIO_SECRET_KEY=minioadmin front: - image: anticrm/front + image: hardcoreeng/front links: - mongodb - minio @@ -73,7 +73,7 @@ services: - MINIO_ACCESS_KEY=minioadmin - MINIO_SECRET_KEY=minioadmin transactor: - image: anticrm/transactor + image: hardcoreeng/transactor links: - mongodb - elastic diff --git a/dev/tool/package.json b/dev/tool/package.json index c07d303abc..e110f3a966 100644 --- a/dev/tool/package.json +++ b/dev/tool/package.json @@ -10,10 +10,10 @@ "lint:fix": "eslint --fix src", "start": "ts-node src/index.ts", "bundle": "esbuild src/index.ts --bundle --minify --platform=node > bundle.js", - "docker:build": "docker build -t anticrm/tool .", - "docker:push": "docker push anticrm/tool", + "docker:build": "docker build -t hardcoreeng/tool .", + "docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/tool staging", + "docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/tool", "run-local": "cross-env MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost MONGO_URL=mongodb://localhost:27017 TRANSACTOR_URL=ws:/localhost:3333 TELEGRAM_DATABASE=telegram-service ELASTIC_URL=http://localhost:9200 REKONI_URL=http://localhost:4004 ts-node ./src/index.ts", - "run-local-node": "cross-env MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost MONGO_URL=mongodb://localhost:27017 TRANSACTOR_URL=ws:/localhost:3333 TELEGRAM_DATABASE=telegram-service ELASTIC_URL=http://localhost:9200 node ./bundle.js", "lint": "eslint src", "format": "prettier --write src && eslint --fix src" }, diff --git a/models/all/src/__bumpversion.ts b/models/all/src/__bumpversion.ts index 961feb42b1..d5377baaa6 100644 --- a/models/all/src/__bumpversion.ts +++ b/models/all/src/__bumpversion.ts @@ -27,7 +27,7 @@ exec('git describe --tags --abbrev=0', (err, stdout, stderr) => { const version = { major: parseInt(rawVersion[0]), minor: parseInt(rawVersion[1]), - patch: parseInt(rawVersion[2]) + 1 // Always use +1 version from released already. + patch: parseInt(rawVersion[2]) } const newVersion = JSON.stringify(version) if (JSON.stringify(currentVersion) !== newVersion) { diff --git a/models/all/src/__showversion.ts b/models/all/src/__showversion.ts index 842c4ac0d7..0e0dc614c6 100644 --- a/models/all/src/__showversion.ts +++ b/models/all/src/__showversion.ts @@ -13,5 +13,5 @@ // limitations under the License. // -import { version } from '.' +import version from './version.json' console.log(`"${version.major}.${version.minor}.${version.patch}"`) diff --git a/models/all/src/version.json b/models/all/src/version.json index 95b0c5c8f6..a6b742608d 100644 --- a/models/all/src/version.json +++ b/models/all/src/version.json @@ -1 +1 @@ -{"major":0,"minor":6,"patch":0} \ No newline at end of file +{"major":0,"minor":6,"patch":4} \ No newline at end of file diff --git a/pods/account/kube/deployment.yml b/pods/account/kube/deployment.yml index 83dace4687..508c94e47a 100644 --- a/pods/account/kube/deployment.yml +++ b/pods/account/kube/deployment.yml @@ -14,7 +14,7 @@ spec: spec: containers: - name: app - image: anticrm/account + image: hardcoreeng/account ports: - containerPort: 3000 imagePullPolicy: Always diff --git a/pods/account/package.json b/pods/account/package.json index d08aff0825..ab6cebea7b 100644 --- a/pods/account/package.json +++ b/pods/account/package.json @@ -10,8 +10,9 @@ "build:watch": "tsc", "lint:fix": "eslint --fix src", "bundle": "esbuild src/index.ts --bundle --minify --platform=node > bundle.js", - "docker:build": "docker build -t anticrm/account .", - "docker:push": "docker push anticrm/account", + "docker:build": "docker build -t hardcoreeng/account .", + "docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/account staging", + "docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/account", "run-local": "cross-env MONGO_URL=mongodb://localhost:27017 MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin MINIO_ENDPOINT=localhost TRANSACTOR_URL=ws:/localhost:3333 ts-node src/index.ts", "lint": "eslint src", "format": "prettier --write src && eslint --fix src" diff --git a/server/front/Dockerfile b/server/front/Dockerfile index 0b1661b029..8200f83b83 100644 --- a/server/front/Dockerfile +++ b/server/front/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14 +FROM node:16 WORKDIR /usr/src/app diff --git a/server/front/kube/front.yml b/server/front/kube/front.yml index 75997fd0f2..752e1521a2 100644 --- a/server/front/kube/front.yml +++ b/server/front/kube/front.yml @@ -15,7 +15,7 @@ spec: spec: containers: - name: app - image: anticrm/front + image: hardcoreeng/front ports: - containerPort: 8080 imagePullPolicy: Always diff --git a/server/front/package.json b/server/front/package.json index 2dad8469c2..d40e7d28ec 100644 --- a/server/front/package.json +++ b/server/front/package.json @@ -8,9 +8,10 @@ "build": "heft build", "build:watch": "tsc", "lint:fix": "eslint --fix src", - "bundle": "esbuild src/__start.ts --define:process.env.MODEL_VERSION=$(rush model-version | tail -1) --bundle --minify --platform=node > bundle.js & rm -rf ./dist && cp -r ../../dev/prod/dist . && cp -r ../../dev/prod/public/* ./dist/ && rm ./dist/config.json", - "docker:build": "docker build -t anticrm/front .", - "docker:push": "docker push anticrm/front", + "bundle": "esbuild src/__start.ts --define:process.env.MODEL_VERSION=$(node ../../models/all/lib/__showversion.js) --bundle --minify --platform=node > bundle.js & rm -rf ./dist && cp -r ../../dev/prod/dist . && cp -r ../../dev/prod/public/* ./dist/ && rm ./dist/config.json", + "docker:build": "docker build -t hardcoreeng/front .", + "docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/front staging", + "docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/front", "lint": "eslint src", "format": "prettier --write src && eslint --fix src" }, diff --git a/server/server/Dockerfile b/server/server/Dockerfile index e2471add48..c554be8135 100644 --- a/server/server/Dockerfile +++ b/server/server/Dockerfile @@ -1,4 +1,4 @@ -FROM node +FROM node:16 WORKDIR /usr/src/app diff --git a/server/server/kube/transactor.yml b/server/server/kube/transactor.yml index 3ca628f3f1..1cb61397d2 100644 --- a/server/server/kube/transactor.yml +++ b/server/server/kube/transactor.yml @@ -15,7 +15,7 @@ spec: spec: containers: - name: app - image: anticrm/transactor + image: hardcoreeng/transactor ports: - containerPort: 3333 imagePullPolicy: Always diff --git a/server/server/package.json b/server/server/package.json index 3316b701e4..fa0cfb19d9 100644 --- a/server/server/package.json +++ b/server/server/package.json @@ -9,8 +9,9 @@ "build": "heft build", "lint:fix": "eslint --fix src", "bundle": "esbuild src/__start.ts --bundle --platform=node > bundle.js", - "docker:build": "docker build -t anticrm/transactor .", - "docker:push": "docker push anticrm/transactor", + "docker:build": "docker build -t hardcoreeng/transactor .", + "docker:staging": "../../common/scripts/docker_tag.sh hardcoreeng/transactor staging", + "docker:push": "../../common/scripts/docker_tag.sh hardcoreeng/transactor", "build:watch": "tsc", "lint": "eslint src", "format": "prettier --write src && eslint --fix src" diff --git a/tests/docker-compose.yaml b/tests/docker-compose.yaml index a5db1eb5f5..fc46692104 100644 --- a/tests/docker-compose.yaml +++ b/tests/docker-compose.yaml @@ -35,7 +35,7 @@ services: retries: 10 test: curl -s http://localhost:9200/_cluster/health | grep -vq '"status":"red"' account: - image: anticrm/account + image: hardcoreeng/account links: - mongodb - minio @@ -51,7 +51,7 @@ services: - MINIO_ACCESS_KEY=minioadmin - MINIO_SECRET_KEY=minioadmin front: - image: anticrm/front + image: hardcoreeng/front links: - account - mongodb @@ -70,7 +70,7 @@ services: - MINIO_ACCESS_KEY=minioadmin - MINIO_SECRET_KEY=minioadmin transactor: - image: anticrm/transactor + image: hardcoreeng/transactor links: - mongodb - elastic