From 14f833ab87df908169062ee20e5691498207b582 Mon Sep 17 00:00:00 2001 From: Edwin Betancourt Date: Fri, 30 Jul 2021 12:55:55 -0400 Subject: [PATCH] feat: Push docker image github package registry. (#1014) * feat: Push docker image github package registry. * Docker image in Github Package * change npm ci to npm i * Add docker file. * remove docs lock files --- .github/workflows/docs.yml | 7 +- .github/workflows/publish.yml | 175 ++++++++++++++++++++++++++++------ build/Dockerfile.prod | 15 +++ build/start.sh | 10 ++ docs/package.json | 6 +- 5 files changed, 181 insertions(+), 32 deletions(-) create mode 100644 build/Dockerfile.prod create mode 100644 build/start.sh diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index ece15f4d..22d298aa 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -19,6 +19,7 @@ on: jobs: # This workflow contains a single job called "build" build: + name: Build and deploy ADempiere-Vue docs # The type of runner that the job will run on runs-on: ubuntu-latest @@ -28,9 +29,11 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: - - uses: actions/checkout@v2 + - name: Check out the repo + uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - name: Node configuration + uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e9523907..b2397138 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,47 +6,168 @@ name: Publish Project on: release: - types: [created] + types: + - created + - edited jobs: - build: + + # Build dist application ADempiere-Vue + build-app: + name: Build dist ADempiere-Vue runs-on: ubuntu-latest strategy: matrix: - node-version: [10.x, 12.x, 13.x, 14.x] - + node-version: [12.x] steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Node configuration + uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - - run: npm i - - run: npm test - - run: npm run build:prod --if-present - - run: set -e - - run: | - cd docs - npm i - npm run build + cache: 'npm' - publish-dist: - needs: build + - name: Set tag version into config file + run: sed -i "s|releaseNoForDocumentation|${{ github.event.release.tag_name }}|g" config/default.json + - name: Install packages + run: npm ci + - name: Run test + run: npm test + - name: Compile dist + run: npm run build:prod --if-present + + - name: Upload dist app + uses: actions/upload-artifact@v2 + with: + name: adempiere-vue + path: dist + + + # Publish dist binaries to application + publish-app-dist: + name: Upload ADempiere-Vue binaries + needs: + - build-app runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 + - name: Download build dist app + uses: actions/download-artifact@v2 with: - node-version: 12 - registry-url: https://registry.npmjs.org/ - - run: npm i - - run: sed -i "s|releaseNoForDocumentation|${{ github.event.release.tag_name }}|g" config/default.json - - run: npm run build:prod --if-present - - uses: TheDoctor0/zip-release@0.4.1 + name: adempiere-vue + + - name: Compress files for application dist + uses: TheDoctor0/zip-release@0.6.0 with: filename: 'Adempiere-Vue.zip' - path: 'dist/' - - uses: skx/github-action-publish-binaries@master + path: './' + + - name: Publish application binary in repository + uses: skx/github-action-publish-binaries@master env: - GITHUB_TOKEN: ${{ secrets.TOKEN_ACCESS }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: args: 'Adempiere-Vue.zip' + + + # Publish docker image to application + push-imame-gpr: + name: Push Docker image to GitHub Packages + needs: + - build-app + runs-on: ubuntu-latest + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Download build dist app + uses: actions/download-artifact@v2 + with: + name: adempiere-vue + path: dist + + - name: Log in to GitHub Docker Registry + uses: docker/login-action@v1 + with: + registry: docker.pkg.github.com + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: set lower case owner name + run: | + echo "OWNER_LC=${OWNER,,}" >> ${GITHUB_ENV} + echo "REPO_LC=${REPO,,}" >> ${GITHUB_ENV} + echo "IMAGE_NAME=adempiere-vue" >> ${GITHUB_ENV} + env: + OWNER: '${{ github.repository_owner }}' + REPO: '${{ github.repository }}' + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + file: ./build/Dockerfile.prod + push: true + tags: | + docker.pkg.github.com/${{ env.REPO_LC }}/${{ env.IMAGE_NAME }}:${{ github.sha }} + docker.pkg.github.com/${{ env.REPO_LC }}/${{ env.IMAGE_NAME }}:${{ github.event.release.tag_name }} + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} + + + # Build dist documentation ADempiere-Vue + build-docs: + name: Build dist ADempiere-Vue docs + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [12.x] + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Node configuration + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Generate dist docs + run: | + cd docs + npm i + npm run build --if-present + + - name: Upload dist docs + uses: actions/upload-artifact@v2 + with: + name: adempiere-vue-docs + path: docs/.vuepress/dist + + + # Publish dist binaries to documentation + publish-docs-dist: + name: Upload ADempiere-Vue docs binaries + needs: + - build-docs + runs-on: ubuntu-latest + steps: + - name: Download build dist docs + uses: actions/download-artifact@v2 + with: + name: adempiere-vue-docs + + - name: Compress files for documentation dist + uses: TheDoctor0/zip-release@0.6.0 + with: + filename: 'Adempiere-Vue-Documentation.zip' + path: './' + + - name: Publish documentation binary in repository + uses: skx/github-action-publish-binaries@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + args: 'Adempiere-Vue-Documentation.zip' diff --git a/build/Dockerfile.prod b/build/Dockerfile.prod new file mode 100644 index 00000000..f0912907 --- /dev/null +++ b/build/Dockerfile.prod @@ -0,0 +1,15 @@ +FROM nginx:1.19.9-alpine + + +LABEL maintainer="EdwinBetanc0urt@outlook.com" \ + description="ADempiere-Vue" + + +ENV API_URL="https://api.erpya.com" + + +COPY build/start.sh . +COPY dist/* /usr/share/nginx/html/ + + +CMD 'sh' 'start.sh' diff --git a/build/start.sh b/build/start.sh new file mode 100644 index 00000000..0a925c05 --- /dev/null +++ b/build/start.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# folder with dist app files +cd /usr/share/nginx/html/static/js + +# Set API Proxy connection +find -name 'app.*.js' -exec sed -i "s|https://api.erpya.com|$API_URL|g" {} \; + +# Start nginx web server +nginx && tail -f /dev/null diff --git a/docs/package.json b/docs/package.json index 6926d777..8c7b1b4e 100644 --- a/docs/package.json +++ b/docs/package.json @@ -23,10 +23,10 @@ "author": "PanJiaChen", "license": "ISC", "devDependencies": { - "prettier": "1.14.2", - "vuepress": "0.14.9", "husky": "0.14.3", - "lint-staged": "7.2.2" + "lint-staged": "7.2.2", + "prettier": "1.14.2", + "vuepress": "0.14.9" }, "dependencies": { "axios": ">=0.21.1",