Skip to content

Commit

Permalink
Merge pull request #161 from hyperledger/base_image
Browse files Browse the repository at this point in the history
Add argument for base image in Dockerfile
  • Loading branch information
EnriqueL8 committed May 23, 2024
2 parents 2ec0fa0 + 6e654ab commit b5077cb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/docker_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
--label commit=$GITHUB_SHA \
--label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
--label tag=${{ steps.build_tag_generator.outputs.BUILD_TAG }} \
--build-arg BUILD_IMAGE=node:20-alpine3.17 \
--build-arg BASE_IMAGE=node:20-alpine3.17 \
--tag ghcr.io/hyperledger/firefly-tokens-erc20-erc721:${{ steps.build_tag_generator.outputs.BUILD_TAG }} .
- name: Tag release
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/docker_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ jobs:
--label tag=${GITHUB_REF##*/} \
--tag ghcr.io/hyperledger/firefly-tokens-erc20-erc721:${GITHUB_REF##*/} \
--tag ghcr.io/hyperledger/firefly-tokens-erc20-erc721:head \
--build-arg BASE_IMAGE=node:20-alpine3.17 \
--build-arg BUILD_IMAGE=node:20-alpine3.17 \
.
- name: Tag release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Docker build
run: docker build --tag ghcr.io/hyperledger/firefly-tokens-erc20-erc721 .
run: docker build --build-arg BASE_IMAGE=node:20-alpine3.17 --build-arg BUILD_IMAGE=node:20-alpine3.17 --tag ghcr.io/hyperledger/firefly-tokens-erc20-erc721 .
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
FROM node:20-alpine3.17 as build
ARG BASE_IMAGE
ARG BUILD_IMAGE

FROM ${BUILD_IMAGE} as build
USER node
WORKDIR /home/node
ADD --chown=node:node package*.json ./
RUN npm install
ADD --chown=node:node . .
RUN npm run build

FROM node:20-alpine3.17 as solidity-build
FROM ${BUILD_IMAGE} as solidity-build
RUN apk add python3=3.10.14-r1 alpine-sdk=1.0-r1
USER node
WORKDIR /home/node
Expand All @@ -23,7 +26,7 @@ RUN curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/
RUN trivy fs --format spdx-json --output /sbom.spdx.json /SBOM
RUN trivy sbom /sbom.spdx.json --severity UNKNOWN,HIGH,CRITICAL --exit-code 1

FROM node:20-alpine3.17
FROM $BASE_IMAGE
RUN apk add curl=8.5.0-r0 jq=1.6-r2
RUN mkdir -p /app/contracts/source \
&& chgrp -R 0 /app/ \
Expand All @@ -48,4 +51,4 @@ COPY --from=SBOM /sbom.spdx.json /sbom.spdx.json

RUN npm install --production
EXPOSE 3000
CMD ["node", "dist/src/main"]
CMD ["node", "dist/src/main"]
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"docker": "docker build --build-arg BASE_IMAGE=node:20-alpine3.17 --build-arg BUILD_IMAGE=node:20-alpine3.17 --tag hyperledger/firefly-tokens-erc20-erc721 .",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
Expand Down

0 comments on commit b5077cb

Please sign in to comment.