Skip to content

Commit

Permalink
fix: use default node image to build docker (#7004)
Browse files Browse the repository at this point in the history
* fix: use default node image instead of alpine

* fix: use apt-get

* Apply suggestions from code review

---------

Co-authored-by: Cayman <caymannava@gmail.com>
  • Loading branch information
twoeths and wemeetagain committed Aug 6, 2024
1 parent 703249c commit 30a13f9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

# --platform=$BUILDPLATFORM is used build javascript source with host arch
# Otherwise TS builds on emulated archs and can be extremely slow (+1h)
FROM --platform=${BUILDPLATFORM:-amd64} node:22.4-alpine as build_src
FROM --platform=${BUILDPLATFORM:-amd64} node:22.4-slim as build_src
ARG COMMIT
WORKDIR /usr/app
RUN apk update && apk add --no-cache g++ make python3 py3-setuptools && rm -rf /var/cache/apk/*
RUN apt-get update && apt-get install -y g++ make python3 python3-setuptools && apt-get clean && rm -rf /var/lib/apt/lists/*

COPY . .

Expand All @@ -21,21 +21,21 @@ RUN cd packages/cli && GIT_COMMIT=${COMMIT} yarn write-git-data

# Copy built src + node_modules to build native packages for archs different than host.
# Note: This step is redundant for the host arch
FROM node:22.4-alpine as build_deps
FROM node:22.4-slim as build_deps
WORKDIR /usr/app
RUN apk update && apk add --no-cache g++ make python3 py3-setuptools && rm -rf /var/cache/apk/*
RUN apt-get update && apt-get install -y g++ make python3 python3-setuptools && apt-get clean && rm -rf /var/lib/apt/lists/*

COPY --from=build_src /usr/app .

# Do yarn --force to trigger a rebuild of the native packages
# Emmulates `yarn rebuild` which is not available in v1 https://yarnpkg.com/cli/rebuild
# Emmulates `yarn rebuild` which is not available in v1 https://yarnpkg.com/cli/rebuild
RUN yarn install --non-interactive --frozen-lockfile --production --force
# Rebuild leveldb bindings (required for arm64 build)
RUN cd node_modules/classic-level && yarn rebuild

# 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:22.4-alpine
FROM node:22.4-slim
WORKDIR /usr/app
COPY --from=build_deps /usr/app .

Expand Down

0 comments on commit 30a13f9

Please sign in to comment.