Skip to content

Commit

Permalink
build: Target platform
Browse files Browse the repository at this point in the history
  • Loading branch information
kroese authored Dec 1, 2023
1 parent d221b11 commit 8020004
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
FROM --platform=$BUILDPLATFORM node:alpine as builder

ARG VERSION_ARG="0.0"
ARG TARGETOS TARGETARCH
ENV NODE_ENV=production
WORKDIR /portainer-backup

# INSTALL ADDITIONAL IMAGE DEPENDENCIES AND COPY APPLICATION TO IMAGE
RUN apk update && apk add --no-cache tzdata
RUN mkdir -p /portainer-backup/src
COPY package.json /portainer-backup
COPY src/*.js /portainer-backup/src
RUN sed -i "s/0.0.0-development/${VERSION_ARG}/" /portainer-backup/package.json

RUN npm install --omit=dev
ARG VERSION_ARG="0.0"
ARG TARGETPLATFORM
ENV NODE_ENV=production

RUN case ${TARGETPLATFORM} in \
"linux/amd64") NPM_ARCH="x64" ;; \
"linux/arm64") NPM_ARCH="arm64" ;; \
"linux/arm/v7") NPM_ARCH="arm" ;; \
"linux/arm/v6") NPM_ARCH="arm" ;; \
"linux/386") NPM_ARCH="ia32" ;; \
esac \
&& npm install --cpu=${NPM_ARCH} --os=linux --omit=dev

FROM node:alpine as runner
ENV NODE_ENV=production

Expand Down

0 comments on commit 8020004

Please sign in to comment.