Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add argument for base image in Dockerfile #161

Merged
merged 4 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/docker_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ 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 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
1 change: 1 addition & 0 deletions .github/workflows/docker_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ 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 \
.

- 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 --tag ghcr.io/hyperledger/firefly-tokens-erc20-erc721 .
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ARG BASE_IMAGE

FROM node:20-alpine3.17 as build
USER node
WORKDIR /home/node
Expand All @@ -23,7 +25,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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like maybe we should use the same base image for the other builder phases above (on lines 3 and 11)?

I don't think binary compatibility will be an issue since those steps are only building for Node and EVM. But if someone used a base image other than Node 20 here, for instance... there could definitely be runtime incompatibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to add a BUILDER_IMAGE here as I think that makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have pushed up this

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 +50,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 --tag hyperledger/firefly-tokens-erc20-erc721 .",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start:dev": "nest start --watch",
Expand Down
Loading