Skip to content

Commit

Permalink
fix: Cleanup Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Dec 1, 2024
1 parent 8aef77e commit 23d8cea
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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 ./

Expand All @@ -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"]

0 comments on commit 23d8cea

Please sign in to comment.