Skip to content

Commit

Permalink
Merge pull request #73 from kaleido-io/build-enhancements
Browse files Browse the repository at this point in the history
Reduce docker image size
  • Loading branch information
nguyer authored Apr 26, 2022
2 parents ec538c7 + 1c93717 commit d966ae7
Show file tree
Hide file tree
Showing 4 changed files with 12,269 additions and 3,064 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/docker_release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker
name: Docker Release Build

on:
release:
Expand All @@ -9,21 +9,35 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Build
run: docker build -t ghcr.io/hyperledger/firefly-tokens-erc1155:${GITHUB_REF##*/} .

run: |
docker build \
--label commit=$GITHUB_SHA \
--label build_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \
--label tag=${GITHUB_REF##*/} \
--tag ghcr.io/hyperledger/firefly-tokens-erc1155:${GITHUB_REF##*/} \
--tag ghcr.io/hyperledger/firefly-tokens-erc1155:head \
.
- name: Tag release
if: github.event.action == 'released'
run: docker tag ghcr.io/hyperledger/firefly-tokens-erc1155:${GITHUB_REF##*/} ghcr.io/hyperledger/firefly-tokens-erc1155:latest

- name: Push docker image
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
docker push ghcr.io/hyperledger/firefly-tokens-erc1155:${GITHUB_REF##*/}
- name: Push head tag
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
docker push ghcr.io/hyperledger/firefly-tokens-erc1155:head
- name: Push latest tag
if: github.event.action == 'released'
run: |
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
docker push ghcr.io/hyperledger/firefly-tokens-erc1155:latest
docker push ghcr.io/hyperledger/firefly-tokens-erc1155:latest
15 changes: 10 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
FROM node:14-alpine3.11 AS solidity-builder
RUN apk add python make
FROM node:16-alpine3.15 AS solidity-builder
RUN apk add python3 alpine-sdk
WORKDIR /root
ADD solidity/package*.json ./
RUN npm install
RUN npm config set user 0
ADD solidity/ ./
RUN npx truffle compile

FROM node:14-alpine3.11
RUN apk add curl
FROM node:16-alpine3.15 as builder
WORKDIR /root
ADD package*.json ./
RUN npm install
ADD . .
RUN npm run build
COPY --from=solidity-builder /root/build/contracts contracts

FROM node:16-alpine3.15
RUN apk add curl
WORKDIR /root
ADD package*.json ./
RUN npm install --production
COPY --from=solidity-builder /root/build/contracts contracts
COPY --from=builder /root/dist dist
EXPOSE 3000
CMD ["npm", "run", "start:prod"]
Loading

0 comments on commit d966ae7

Please sign in to comment.