diff --git a/.dockerignore b/.dockerignore index 5ada3f9ea063..38cdf24776aa 100644 --- a/.dockerignore +++ b/.dockerignore @@ -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 diff --git a/.github/workflows/publish-dev.yml b/.github/workflows/publish-dev.yml index 3bb9e3c0fcab..dea77696218f 100644 --- a/.github/workflows/publish-dev.yml +++ b/.github/workflows/publish-dev.yml @@ -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 diff --git a/.github/workflows/publish-rc.yml b/.github/workflows/publish-rc.yml index 6c126a841d6a..e63bd98ab1b5 100644 --- a/.github/workflows/publish-rc.yml +++ b/.github/workflows/publish-rc.yml @@ -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 diff --git a/.github/workflows/publish-stable.yml b/.github/workflows/publish-stable.yml index 3bdc6c4f948e..03473562b4f5 100644 --- a/.github/workflows/publish-stable.yml +++ b/.github/workflows/publish-stable.yml @@ -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 diff --git a/Dockerfile b/Dockerfile index 66674d7f5fe1..7af62750dc33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/docker/from_source.Dockerfile b/docker/from_source.Dockerfile deleted file mode 100644 index 767645a93499..000000000000 --- a/docker/from_source.Dockerfile +++ /dev/null @@ -1,50 +0,0 @@ -####################### -# -# To build from source: -# -# Edit root docker-compose.yml -# ```yaml -# services: -# beacon_node: -# build: -# context: . -# dockerfile: docker/from_source.Dockerfile -# ``` -# -# If you need to see the commit and branch in logs + metrics, -# comment this line from .dockerignore -# ``` -# .git -# ``` -# -####################### - -FROM node:16-alpine as build -WORKDIR /usr/app -RUN apk update && apk add --no-cache g++ make python3 && rm -rf /var/cache/apk/* - -# Installs all deps in the root yarn.lock, which are most of them. To cache before copying the src -COPY package.json yarn.lock ./ -RUN yarn install --non-interactive --frozen-lockfile --ignore-scripts - -COPY . . -RUN yarn install --non-interactive --frozen-lockfile && yarn build - -# 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 . - -# 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", "./packages/cli/bin/lodestar"]