Skip to content

Commit e34cbc3

Browse files
marwinhormizMarwin Hormiz
andauthored
examples: add Dockerfile to Remix (#11429)
Remix application was missing a Dockerfile while Payload had one. This also takes issue [#11276](#11276) into consideration to avoid CPU issues. --------- Co-authored-by: Marwin Hormiz <marwinhormiz@duobit.se>
1 parent e49c224 commit e34cbc3

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

examples/remix/website/Dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM node:22.14.0-alpine AS base
2+
3+
FROM base AS builder
4+
RUN apk add --no-cache libc6-compat
5+
WORKDIR /app
6+
7+
RUN npm install -g pnpm@latest-10
8+
9+
COPY . .
10+
11+
RUN apk update \
12+
apk add --no-cache libc6-compat
13+
14+
WORKDIR /app
15+
16+
ENV NODE_ENV=production
17+
RUN pnpm install --no-frozen-lockfile
18+
RUN pnpm --filter website build
19+
20+
FROM base AS runner
21+
22+
RUN npm install -g @remix-run/serve@latest
23+
WORKDIR /app
24+
COPY --from=builder /app/website/build/ ./build
25+
26+
# We need to install sharp again to avoid copying node_modules into the final image.
27+
# Sharp can't be bundled into the server file since it will throw an
28+
# __dirname is not defined error
29+
RUN npm install sharp@0.32.6
30+
31+
# These files are required by Payload to avoid file opening errors
32+
# https://github.com/payloadcms/payload/issues/11276
33+
COPY --from=builder /app/website/package.json ./package.json
34+
COPY --from=builder /app/payload/src/payload.config.ts ./payload.config.ts
35+
ENV PAYLOAD_CONFIG_PATH=./payload.config.ts
36+
37+
EXPOSE 3000
38+
ENV PORT=3000
39+
ENV NODE_ENV=production
40+
41+
CMD HOSTNAME="0.0.0.0" remix-serve build/server/index.js

examples/remix/website/vite.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ export default defineConfig({
2121
}),
2222
tsconfigPaths(),
2323
],
24+
ssr: {
25+
external: ['sharp'],
26+
// Reduces Docker image size
27+
// https://github.com/remix-run/remix/discussions/8878
28+
noExternal: process.env.NODE_ENV === 'production' ? [/.*/] : [],
29+
},
2430
optimizeDeps: {
2531
exclude: ['sharp', 'file-type'],
2632
},

0 commit comments

Comments
 (0)