Skip to content

Commit

Permalink
Build from source by default (#4359)
Browse files Browse the repository at this point in the history
* Optimize build from source

* Build from source by default

* Don't remove source

* Print layer history in CI
  • Loading branch information
dapplion authored Aug 5, 2022
1 parent 107a983 commit 7c54815
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 59 deletions.
21 changes: 19 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,26 @@ docker-compose.yml

# Tests
packages/**/test
packages/**/lib

# Tests artifacts
.__testdb
packages/spec-test-runner/spec-tests
packages/validator/spec-tests
packages/*/spec-tests
packages/*/benchmark_data
packages/beacon-node/test-logs/
packages/state-transition/test-cache
benchmark_data
invalidSszObjects/
packages/beacon-node/mainnet_pubkeys.csv

# Autogenerated docs
packages/**/docs
packages/**/typedocs
docs/packages
docs/contributing.md
docs/assets
docs/reference/cli.md
/site

# Lodestar artifacts
.lodestar
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,5 @@ jobs:
- name: Build and push
run: docker buildx build --push --tag chainsafe/lodestar:next --platform linux/amd64,linux/arm64 --build-arg VERSION=${{ needs.npm.outputs.version }} .
- run: docker run chainsafe/lodestar:next --help
# Display history to know byte size of each layer
- run: docker image history chainsafe/lodestar:next
2 changes: 2 additions & 0 deletions .github/workflows/publish-rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,5 @@ jobs:
- name: Build and push
run: docker buildx build --push --tag chainsafe/lodestar:rc --tag chainsafe/lodestar:${{ needs.tag.outputs.tag }} --platform linux/amd64,linux/arm64 --build-arg VERSION=${{ needs.tag.outputs.tag }} .
- run: docker run chainsafe/lodestar:${{ needs.tag.outputs.tag }} --help
# Display history to know byte size of each layer
- run: docker image history chainsafe/lodestar:rc
2 changes: 2 additions & 0 deletions .github/workflows/publish-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,5 @@ jobs:
- name: Build and push
run: docker buildx build --push --tag chainsafe/lodestar:latest --tag chainsafe/lodestar:${{ needs.tag.outputs.tag }} --platform linux/amd64,linux/arm64 --build-arg VERSION=${{ needs.tag.outputs.tag }} .
- run: docker run chainsafe/lodestar:${{ needs.tag.outputs.tag }} --help
# Display history to know byte size of each layer
- run: docker image history chainsafe/lodestar:latest
21 changes: 14 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,27 @@ FROM node:16-alpine as build
WORKDIR /usr/app
RUN apk update && apk add --no-cache g++ make python3 && rm -rf /var/cache/apk/*

ARG VERSION=latest
ENV VERSION=$VERSION
RUN npm install @chainsafe/lodestar@$VERSION
COPY . .

RUN yarn install --non-interactive --frozen-lockfile && \
yarn build && \
yarn install --non-interactive --frozen-lockfile --production

# To have access to the specific branch and commit used to build this source,
# a git-data.json file is created by persisting git data at build time. Then,
# a version string like `v0.35.0-beta.0/HEAD/82219149 (git)` can be shown in
# the terminal and in the logs; which is very useful to track tests better.
RUN cd packages/cli && yarn write-git-data

# Copy built src + node_modules to a new layer to prune unnecessary fs
# Previous layer weights 7.25GB, while this final 488MB (as of Oct 2020)
FROM node:16-alpine
WORKDIR /usr/app
COPY --from=build /usr/app .

# Sanity check
RUN /usr/app/node_modules/.bin/lodestar --help

# NodeJS applications have a default memory limit of 2.5GB.
# This limit is bit tight for a Prater node, it is recommended to raise the limit
# since memory may spike during certain network conditions.
ENV NODE_OPTIONS=--max-old-space-size=4096

ENTRYPOINT ["node", "/usr/app/node_modules/.bin/lodestar"]
ENTRYPOINT ["node", "./packages/cli/bin/lodestar"]
50 changes: 0 additions & 50 deletions docker/from_source.Dockerfile

This file was deleted.

0 comments on commit 7c54815

Please sign in to comment.