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

Remove gitData script from docker build #2815

Merged
merged 1 commit into from
Jul 6, 2021
Merged
Changes from all 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
Remove gitData script from docker build
dapplion committed Jul 6, 2021
commit a7000023fa5c9f35348b004e8cac505ed5dbf3b7
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
node_modules
# Comment out if you build from source and need to see the commit and branch in logs + metrics
.git
# ^^^

node_modules

# Docs
assets
28 changes: 22 additions & 6 deletions docker/from_source.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
#######################
#
# 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:14-alpine as build
WORKDIR /usr/app
RUN apk update && apk add --no-cache git g++ make python && rm -rf /var/cache/apk/*
RUN apk update && apk add --no-cache g++ make python && 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 ./
@@ -9,15 +30,10 @@ RUN yarn install --non-interactive --frozen-lockfile --ignore-scripts
COPY . .
RUN yarn install --non-interactive --frozen-lockfile

# rm .git afterwards to prevent copying it to the final layer (~350MB)
RUN node ./scripts/getGitData /usr/app/.git-data.json && rm -r .git


# 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:14-alpine
WORKDIR /usr/app
COPY --from=build /usr/app .
ENV DOCKER_LODESTAR_GIT_DATA_FILEPATH /usr/app/.git-data.json

ENTRYPOINT ["node", "--max-old-space-size=8192", "./packages/cli/bin/lodestar"]
2 changes: 1 addition & 1 deletion packages/cli/src/util/gitData.ts
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ function getGitData(): Partial<GitData> {

function getPersistedGitData(): Partial<GitData> {
try {
const gitDataFilepath = process?.env?.DOCKER_LODESTAR_GIT_DATA_FILEPATH || LOCAL_GIT_DATA_FILEPATH;
const gitDataFilepath = LOCAL_GIT_DATA_FILEPATH;

// eslint-disable-next-line
const gitData = JSON.parse(fs.readFileSync(gitDataFilepath, "utf8"));
14 changes: 0 additions & 14 deletions scripts/getGitData.js

This file was deleted.