N
Nuxt2mo ago
∂Max

Nitro compressPublicAssets not working in docker image

Hey 👋 I added the following nitro config to my nuxt app:
nitro: {
preset: 'bun',
compressPublicAssets: {
brotli: true,
},
},
nitro: {
preset: 'bun',
compressPublicAssets: {
brotli: true,
},
},
But using compressPublicAssets prevents the nuxt build from correctly finishing in our docker image. There's no error, but there's also no files in .output/ Here's our docker file:
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 AS base
WORKDIR /usr/src/app

# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile

# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production

# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .

# [optional] tests & build
ENV NODE_ENV=production
RUN bun test
RUN bun run build

# copy production dependencies and source code into final image
FROM base AS release
COPY --from=prerelease /usr/src/app/.output .

# run the app
USER bun
EXPOSE 3000/tcp
ENTRYPOINT [ "bun", "run", "./server/index.mjs" ]
# use the official Bun image
# see all versions at https://hub.docker.com/r/oven/bun/tags
FROM oven/bun:1 AS base
WORKDIR /usr/src/app

# install dependencies into temp directory
# this will cache them and speed up future builds
FROM base AS install
RUN mkdir -p /temp/dev
COPY package.json bun.lockb /temp/dev/
RUN cd /temp/dev && bun install --frozen-lockfile

# install with --production (exclude devDependencies)
RUN mkdir -p /temp/prod
COPY package.json bun.lockb /temp/prod/
RUN cd /temp/prod && bun install --frozen-lockfile --production

# copy node_modules from temp directory
# then copy all (non-ignored) project files into the image
FROM base AS prerelease
COPY --from=install /temp/dev/node_modules node_modules
COPY . .

# [optional] tests & build
ENV NODE_ENV=production
RUN bun test
RUN bun run build

# copy production dependencies and source code into final image
FROM base AS release
COPY --from=prerelease /usr/src/app/.output .

# run the app
USER bun
EXPOSE 3000/tcp
ENTRYPOINT [ "bun", "run", "./server/index.mjs" ]
1 Reply
∂Max
∂Max2mo ago
Docker logs:
...
#16 69.84 ℹ ✓ built in 54.59s
#16 69.86 ✔ Client built in 54621ms
#16 69.99 ℹ Building server...
#16 70.05 ℹ vite v5.3.5 building SSR bundle for production...
#16 70.18 ℹ transforming...
#16 70.20 ℹ ✓ 1 modules transformed.
#16 70.25 ℹ rendering chunks...
#16 70.27 ℹ .nuxt/dist/server/styles.mjs 0.07 kB
#16 70.27 ℹ .nuxt/dist/server/server.mjs 0.10 kB │ map: 0.22 kB
#16 70.27 ℹ ✓ built in 204ms
#16 70.30 ✔ Server built in 312ms
#16 70.35 [nitro] ℹ Initializing prerenderer
#16 73.21 [nitro] ℹ Prerendering 1 routes
#16 73.94 [nitro] ├─ /api/_content/cache.1722963454382.json (719ms)
#16 73.94 [nitro] ℹ Prerendered 1 routes in 2.9 seconds
#16 DONE 74.4s
...
#16 69.84 ℹ ✓ built in 54.59s
#16 69.86 ✔ Client built in 54621ms
#16 69.99 ℹ Building server...
#16 70.05 ℹ vite v5.3.5 building SSR bundle for production...
#16 70.18 ℹ transforming...
#16 70.20 ℹ ✓ 1 modules transformed.
#16 70.25 ℹ rendering chunks...
#16 70.27 ℹ .nuxt/dist/server/styles.mjs 0.07 kB
#16 70.27 ℹ .nuxt/dist/server/server.mjs 0.10 kB │ map: 0.22 kB
#16 70.27 ℹ ✓ built in 204ms
#16 70.30 ✔ Server built in 312ms
#16 70.35 [nitro] ℹ Initializing prerenderer
#16 73.21 [nitro] ℹ Prerendering 1 routes
#16 73.94 [nitro] ├─ /api/_content/cache.1722963454382.json (719ms)
#16 73.94 [nitro] ℹ Prerendered 1 routes in 2.9 seconds
#16 DONE 74.4s
I don't think this is normal at all, should I open an issue somewhere? Also, it works builds normally outside of docker
Want results from more Discord servers?
Add your server