diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 476c80778f..b2fb2070c7 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -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 \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8a5b7ae9bb..d7277a3389 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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