Skip to content

Commit e0301c4

Browse files
Remove duplicate layers
1 parent 434588f commit e0301c4

File tree

3 files changed

+31
-31
lines changed

3 files changed

+31
-31
lines changed

Dockerfile

+8-8
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,19 @@ FROM busybox:latest AS app
9999

100100
COPY --from=base /distroless/ /
101101

102-
# Automatically leverage output traces to reduce image size
103-
# https://nextjs.org/docs/advanced-features/output-file-tracing
104-
COPY --from=builder /app/.next/standalone /app/
105-
106-
# Copy server launcher
107-
COPY --from=builder /app/scripts/serverLauncher/startServer.js /app/startServer.js
108-
109102
RUN \
110103
# Add nextjs:nodejs to run the app
111104
addgroup -S -g 1001 nodejs \
112105
&& adduser -D -G nodejs -H -S -h /app -u 1001 nextjs \
113106
# Set permission for nextjs:nodejs
114-
&& chown -R nextjs:nodejs /app /etc/proxychains4.conf
107+
&& chown nextjs:nodejs /etc/proxychains4.conf
108+
109+
# Automatically leverage output traces to reduce image size
110+
# https://nextjs.org/docs/advanced-features/output-file-tracing
111+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone /app/
112+
113+
# Copy server launcher
114+
COPY --from=builder --chown=nextjs:nodejs /app/scripts/serverLauncher/startServer.js /app/startServer.js
115115

116116
## Production image, copy all the files and run next
117117
FROM app

Dockerfile.database

+15-15
Original file line numberDiff line numberDiff line change
@@ -113,29 +113,29 @@ FROM busybox:latest AS app
113113

114114
COPY --from=base /distroless/ /
115115

116+
RUN \
117+
# Add nextjs:nodejs to run the app
118+
addgroup -S -g 1001 nodejs \
119+
&& adduser -D -G nodejs -H -S -h /app -u 1001 nextjs \
120+
# Set permission for nextjs:nodejs
121+
&& chown nextjs:nodejs /etc/proxychains4.conf
122+
116123
# Automatically leverage output traces to reduce image size
117124
# https://nextjs.org/docs/advanced-features/output-file-tracing
118-
COPY --from=builder /app/.next/standalone /app/
125+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone /app/
119126

120127
# Copy database migrations
121-
COPY --from=builder /app/src/database/migrations /app/migrations
122-
COPY --from=builder /app/scripts/migrateServerDB/docker.cjs /app/docker.cjs
123-
COPY --from=builder /app/scripts/migrateServerDB/errorHint.js /app/errorHint.js
128+
COPY --from=builder --chown=nextjs:nodejs /app/src/database/migrations /app/migrations
129+
COPY --from=builder --chown=nextjs:nodejs /app/scripts/migrateServerDB/docker.cjs /app/docker.cjs
130+
COPY --from=builder --chown=nextjs:nodejs /app/scripts/migrateServerDB/errorHint.js /app/errorHint.js
124131

125132
# copy dependencies
126-
COPY --from=builder /deps/node_modules/.pnpm /app/node_modules/.pnpm
127-
COPY --from=builder /deps/node_modules/pg /app/node_modules/pg
128-
COPY --from=builder /deps/node_modules/drizzle-orm /app/node_modules/drizzle-orm
133+
COPY --from=builder --chown=nextjs:nodejs /deps/node_modules/.pnpm /app/node_modules/.pnpm
134+
COPY --from=builder --chown=nextjs:nodejs /deps/node_modules/pg /app/node_modules/pg
135+
COPY --from=builder --chown=nextjs:nodejs /deps/node_modules/drizzle-orm /app/node_modules/drizzle-orm
129136

130137
# Copy server launcher
131-
COPY --from=builder /app/scripts/serverLauncher/startServer.js /app/startServer.js
132-
133-
RUN \
134-
# Add nextjs:nodejs to run the app
135-
addgroup -S -g 1001 nodejs \
136-
&& adduser -D -G nodejs -H -S -h /app -u 1001 nextjs \
137-
# Set permission for nextjs:nodejs
138-
&& chown -R nextjs:nodejs /app /etc/proxychains4.conf
138+
COPY --from=builder --chown=nextjs:nodejs /app/scripts/serverLauncher/startServer.js /app/startServer.js
139139

140140
## Production image, copy all the files and run next
141141
FROM app

Dockerfile.pglite

+8-8
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,19 @@ FROM busybox:latest AS app
100100

101101
COPY --from=base /distroless/ /
102102

103-
# Automatically leverage output traces to reduce image size
104-
# https://nextjs.org/docs/advanced-features/output-file-tracing
105-
COPY --from=builder /app/.next/standalone /app/
106-
107-
# Copy server launcher
108-
COPY --from=builder /app/scripts/serverLauncher/startServer.js /app/startServer.js
109-
110103
RUN \
111104
# Add nextjs:nodejs to run the app
112105
addgroup -S -g 1001 nodejs \
113106
&& adduser -D -G nodejs -H -S -h /app -u 1001 nextjs \
114107
# Set permission for nextjs:nodejs
115-
&& chown -R nextjs:nodejs /app /etc/proxychains4.conf
108+
&& chown nextjs:nodejs /etc/proxychains4.conf
109+
110+
# Automatically leverage output traces to reduce image size
111+
# https://nextjs.org/docs/advanced-features/output-file-tracing
112+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone /app/
113+
114+
# Copy server launcher
115+
COPY --from=builder --chown=nextjs:nodejs /app/scripts/serverLauncher/startServer.js /app/startServer.js
116116

117117
## Production image, copy all the files and run next
118118
FROM app

0 commit comments

Comments
 (0)