fix: Cleanup Dockerfile

This commit is contained in:
Koen Kanters
2024-12-01 20:11:34 +01:00
parent 8aef77e57e
commit 23d8cea4e2
+8 -13
View File
@@ -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"]