ci: multi-platform docker image (#11479)

* ci: multi-platform build

* ci: remove riscv as node doesn't support it

* ci: correct step name

it's no longer logging in to docker hub

* ci: remove less common architectures

* ci: github actions cache for docker builds

* fix: use `--omit` flag to actually avoid installing dev dependencies

* feat: two-stage build

* feat: add platform-specific rebuild

* fix: run install if target arch is different from build arch

* fix: whitespace

* fix: correct build order

* fix: remove unnecessary conditional

* fix: remove unnecessary platofm specifier

* fix: correct copy
isekai-main
Opliko 2 years ago committed by GitHub
parent 2bfdd76180
commit 0417e5f16c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -30,7 +30,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
@ -54,3 +54,6 @@ jobs:
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
cache-from: type=gha
cache-to: type=gha,mode=max

@ -1,3 +1,19 @@
FROM --platform=$BUILDPLATFORM node:lts as npm
RUN mkdir -p /usr/src/build && \
chown -R node:node /usr/src/build
WORKDIR /usr/src/build
ARG NODE_ENV
ENV NODE_ENV $NODE_ENV
COPY --chown=node:node install/package.json /usr/src/build/package.json
USER node
RUN npm install --omit=dev
FROM node:lts
RUN mkdir -p /usr/src/app && \
@ -7,11 +23,11 @@ WORKDIR /usr/src/app
ARG NODE_ENV
ENV NODE_ENV $NODE_ENV
COPY --chown=node:node install/package.json /usr/src/app/package.json
COPY --chown=node:node --from=npm /usr/src/build /usr/src/app
USER node
RUN npm install --only=prod && \
RUN npm rebuild && \
npm cache clean --force
COPY --chown=node:node . /usr/src/app

Loading…
Cancel
Save