From 23d8cea4e243429bf5a376db94d09f535776de49 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Fri, 22 Nov 2024 22:54:00 +0100 Subject: [PATCH] fix: Cleanup Dockerfile --- docker/Dockerfile | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 369e430c8b..3634363ae9 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,22 +1,19 @@ -FROM alpine:3.18.4 as base +FROM alpine:3.18.4 AS base +ENV NODE_ENV=production WORKDIR /app RUN apk add --no-cache tzdata eudev tini nodejs # Dependencies and build -FROM base as dependencies_and_build +FROM base AS deps -COPY package*.json tsconfig.json index.js ./ -COPY lib ./lib - -RUN apk add make gcc g++ python3 linux-headers git npm && \ +COPY package.json pnpm-lock.yaml ./ +RUN apk add npm && \ npm install -g pnpm && \ - pnpm install --frozen-lockfile --no-optional && \ - # Serialport needs to be rebuild for Alpine https://serialport.io/docs/9.x.x/guide-installation#alpine-linux - pnpm rebuild + pnpm install --frozen-lockfile --no-optional # Release -FROM base as release +FROM base AS release LABEL org.opencontainers.image.authors="Koen Kanters" LABEL org.opencontainers.image.title="zigbee2mqtt" @@ -25,7 +22,7 @@ LABEL org.opencontainers.image.url="https://github.com/Koenkk/zigbee2mqtt" LABEL org.opencontainers.image.documentation="https://www.zigbee2mqtt.io/" LABEL org.opencontainers.image.source="https://github.com/Koenkk/zigbee2mqtt" -COPY --from=dependencies_and_build /app/node_modules ./node_modules +COPY --from=deps /app/node_modules ./node_modules COPY dist ./dist COPY package.json LICENSE index.js data/configuration.yaml data/configuration.example.yaml ./ @@ -37,7 +34,5 @@ RUN mkdir /app/data ARG COMMIT RUN echo "$COMMIT" > dist/.hash -ENV NODE_ENV production - ENTRYPOINT ["docker-entrypoint.sh"] CMD [ "/sbin/tini", "--", "node", "index.js"]