Skip to content

Commit 6713d33

Browse files
authored
fix(docker): resolve native module build failures in production dependencies (#572)
fix(docker): resolve build failures for native modules and production deps
1 parent 20923e1 commit 6713d33

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

containers/wetty/Dockerfile

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
1-
FROM node:current-alpine as base
2-
RUN apk add -U build-base python3
3-
ENV PNPM_HOME="/pnpm"
4-
ENV PATH="$PNPM_HOME:$PATH"
5-
RUN corepack enable
6-
RUN npx pnpm i -g pnpm@latest
1+
# ---------- Base image ----------
2+
FROM node:20-alpine as base
3+
RUN apk add -U build-base python3 py3-setuptools make g++ git
74
WORKDIR /usr/src/app
5+
6+
# Install pnpm globally
7+
RUN npm install -g pnpm@latest
8+
89
COPY . /usr/src/app
910

11+
# ---------- Production dependencies ----------
1012
FROM base AS prod-deps
11-
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
13+
RUN --mount=type=cache,id=pnpm,target=/root/.pnpm-store pnpm install --prod --frozen-lockfile --ignore-scripts
14+
# Rebuild only the native modules we need
15+
RUN cd node_modules/node-pty && npm run install && cd ../..
16+
RUN cd node_modules/.pnpm/[email protected]/node_modules/gc-stats && npm run install
1217

18+
# ---------- Build stage ----------
1319
FROM base AS build
14-
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
20+
RUN --mount=type=cache,id=pnpm,target=/root/.pnpm-store pnpm install --frozen-lockfile
1521
RUN pnpm run build
1622

17-
FROM node:current-alpine
23+
# ---------- Final runtime image ----------
24+
FROM base
1825
LABEL maintainer="[email protected]"
1926
WORKDIR /usr/src/app
2027
ENV NODE_ENV=production
21-
EXPOSE 3000
28+
2229
COPY --from=prod-deps /usr/src/app/node_modules /usr/src/app/node_modules
2330
COPY --from=build /usr/src/app/build /usr/src/app/build
2431
COPY package.json /usr/src/app
32+
2533
RUN apk add -U coreutils openssh-client sshpass && \
26-
mkdir ~/.ssh
34+
mkdir -p ~/.ssh
2735

28-
EXPOSE 8000
29-
CMD [ "pnpm", "start" ]
36+
EXPOSE 3000
37+
CMD ["pnpm", "start"]

0 commit comments

Comments
 (0)