From 81a4f71bc3c4b15ae320f118d96cb1ea845b750b Mon Sep 17 00:00:00 2001 From: Tatsuya Sato Date: Thu, 28 Sep 2023 05:34:07 +0000 Subject: [PATCH] Move publishing of REST sample Image from AZP to GHA This patch moves publishing of REST sample image from AZP to GHA. This was the last job running on AZP. Also, this patch fixes an error encounterd during the image build. Publishing of REST sample image is now only executed when pushing to main. Signed-off-by: Tatsuya Sato --- .github/workflows/rest-sample.yaml | 11 +++++ .../rest-api-typescript/Dockerfile | 6 +-- ci/azure-pipelines.yml | 46 ------------------- 3 files changed, 14 insertions(+), 49 deletions(-) delete mode 100644 ci/azure-pipelines.yml diff --git a/.github/workflows/rest-sample.yaml b/.github/workflows/rest-sample.yaml index 71f768375e..9e331c502a 100644 --- a/.github/workflows/rest-sample.yaml +++ b/.github/workflows/rest-sample.yaml @@ -45,3 +45,14 @@ jobs: - name: Test REST Sample Application run: npm test working-directory: asset-transfer-basic/rest-api-typescript + + - name: Build REST Sample Docker Image + run: docker build -t ghcr.io/hyperledger/fabric-rest-sample . + working-directory: asset-transfer-basic/rest-api-typescript + + - name: Publish REST Sample Docker Image + if: github.event_name == 'push' && (github.ref == 'refs/heads/main') + run: | + echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin + docker push ghcr.io/hyperledger/fabric-rest-sample:latest + working-directory: asset-transfer-basic/rest-api-typescript diff --git a/asset-transfer-basic/rest-api-typescript/Dockerfile b/asset-transfer-basic/rest-api-typescript/Dockerfile index d6e87bd0fe..289a7ba912 100644 --- a/asset-transfer-basic/rest-api-typescript/Dockerfile +++ b/asset-transfer-basic/rest-api-typescript/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14-alpine3.14 AS build +FROM node:18-alpine3.14 AS build RUN apk add --no-cache g++ make python3 dumb-init @@ -10,14 +10,14 @@ RUN npm ci RUN npm run build RUN npm prune --production -FROM node:14-alpine3.14 +FROM node:18-alpine3.14 ENV NODE_ENV production WORKDIR /app COPY --from=build /usr/bin/dumb-init /usr/bin/dumb-init COPY --chown=node:node --from=build /app . -EXPOSE 3000 +EXPOSE 3000 USER node diff --git a/ci/azure-pipelines.yml b/ci/azure-pipelines.yml deleted file mode 100644 index 0752b33d95..0000000000 --- a/ci/azure-pipelines.yml +++ /dev/null @@ -1,46 +0,0 @@ -# -# SPDX-License-Identifier: Apache-2.0 -# - -trigger: - - main - - release-1.4 - - release-2.2 - -variables: - - name: NODE_VER - value: 16.x - - group: credentials - -jobs: - - job: REST_Sample - displayName: REST Server Sample - pool: - vmImage: ubuntu-20.04 - steps: - - task: NodeTool@0 - inputs: - versionSpec: $(NODE_VER) - displayName: Install Node.js - - script: npm install - workingDirectory: asset-transfer-basic/rest-api-typescript - displayName: Install REST Sample Dependencies - - script: npm run build - workingDirectory: asset-transfer-basic/rest-api-typescript - displayName: Build REST Sample Application - - script: npm test - workingDirectory: asset-transfer-basic/rest-api-typescript - displayName: Test REST Sample Application - - script: | - docker build -t ghcr.io/hyperledger/fabric-rest-sample . - workingDirectory: asset-transfer-basic/rest-api-typescript - displayName: Build REST Sample Docker Image - - script: | - echo ${GITHUB_PAT} | docker login ghcr.io -u ${GITHUB_USER} --password-stdin - docker push ghcr.io/hyperledger/fabric-rest-sample:latest - condition: and(succeeded(),eq(variables['Build.Reason'], 'IndividualCI')) - workingDirectory: asset-transfer-basic/rest-api-typescript - displayName: Publish REST Sample Docker Image - env: - GITHUB_USER: $(GITHUB_USER) - GITHUB_PAT: $(GITHUB_PAT) \ No newline at end of file