Skip to content

Instantly share code, notes, and snippets.

@xtenduke
Last active May 3, 2022 02:26
Show Gist options
  • Save xtenduke/2400b0005661230f2c05d72cd32ee4d9 to your computer and use it in GitHub Desktop.
Save xtenduke/2400b0005661230f2c05d72cd32ee4d9 to your computer and use it in GitHub Desktop.
Dockerx build multiarch node - multistage
echo "Prepare docker buildx"
docker run --rm --privileged docker/binfmt:820fdd95a9972a5308930a2bdfb8573dd4447ad3
rev=$(git log -1 --format=%h)
name="$DOCKER_USERNAME/defiant:$rev"
echo "building $name"
docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag "$name" .
FROM node:14.17.0 AS install
WORKDIR /app
COPY ["package.json", "yarn.lock", "./"]
COPY . .
RUN yarn install
RUN yarn build
ENV NODE_ENV=production
FROM node:14.17.0-alpine as run
WORKDIR /app
COPY --from=install ./app/dist ./dist
COPY --from=install ./app/node_modules ./node_modules
COPY ["package.json", "yarn.lock", "./"]
EXPOSE 3000
CMD [ "yarn", "start" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment