Skip to content

Commit a767759

Browse files
committed
fix: modified dockerfile
1 parent d915aa3 commit a767759

File tree

1 file changed

+7
-47
lines changed

1 file changed

+7
-47
lines changed

Dockerfile

Lines changed: 7 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ ENV NODE_ENV=production \
88
UID=1001 \
99
GID=1001
1010

11-
WORKDIR /usr/src/app/
11+
# 1️⃣ Copy package.json before setting WORKDIR
12+
COPY package.json /tmp/package.json
1213

13-
# Copy package manifests first for caching
14-
COPY package.json ./
14+
# 2️⃣ Now switch to your working directory
15+
WORKDIR /usr/src/app/
1516

1617
# Copy custom plugin early so npm can resolve "file:./nodebb-plugin-mailgun-delivery"
1718
COPY nodebb-plugin-mailgun-delivery ./nodebb-plugin-mailgun-delivery
@@ -32,52 +33,11 @@ RUN groupadd --gid ${GID} ${USER} \
3233
USER ${USER}
3334

3435
# Install all dependencies (root + plugin deps, including mailgun.js)
36+
COPY /tmp/package.json ./package.json
3537
RUN npm install --omit=dev
3638

37-
# Copy source but don't overwrite package.json
38-
COPY . /usr/src/app/
39-
COPY package.json /usr/src/app/
39+
# Copy everything else
40+
COPY . .
4041

4142
# Cleanup npm cache
4243
RUN rm -rf .npm
43-
44-
45-
# ---------- Final Runtime Stage ----------
46-
FROM node:lts-slim AS final
47-
48-
ENV NODE_ENV=production \
49-
DAEMON=false \
50-
SILENT=false \
51-
USER=nodebb \
52-
UID=1001 \
53-
GID=1001
54-
55-
WORKDIR /usr/src/app/
56-
57-
# Enable corepack + create user
58-
RUN corepack enable \
59-
&& groupadd --gid ${GID} ${USER} \
60-
&& useradd --uid ${UID} --gid ${GID} --home-dir /usr/src/app/ --shell /bin/bash ${USER} \
61-
&& mkdir -p /usr/src/app/logs/ /opt/config/ \
62-
&& chown -R ${USER}:${USER} /usr/src/app/ /opt/config/
63-
64-
# Copy entrypoint and tini
65-
COPY --from=build --chown=${USER}:${USER} /usr/src/app/install/docker/setup.json /usr/src/app/install/docker/setup.json
66-
COPY --from=build --chown=${USER}:${USER} /usr/src/app/install/docker/entrypoint.sh /usr/local/bin/entrypoint.sh
67-
COPY --from=build --chown=${USER}:${USER} /usr/bin/tini /usr/local/bin/tini
68-
69-
# Copy everything built (app + node_modules + plugin)
70-
COPY --from=build --chown=${USER}:${USER} /usr/src/app/ /usr/src/app/
71-
72-
# Permissions
73-
RUN chmod +x /usr/local/bin/entrypoint.sh \
74-
&& chmod +x /usr/local/bin/tini
75-
76-
USER ${USER}
77-
78-
EXPOSE 4567
79-
80-
# Protect critical paths
81-
VOLUME ["/usr/src/app/node_modules", "/usr/src/app/build", "/usr/src/app/public/uploads", "/opt/config/"]
82-
83-
ENTRYPOINT ["tini", "--", "entrypoint.sh"]

0 commit comments

Comments
 (0)