Deployment via docker

I'm going to deploy a nuxt application + a custom server in dotnet via docker and docker compose on my homelab. That will be for my dev deployment while the production deployment will happen via Azure. In the deployment section of nuxt I cannot see anything about docker deployment specifically so I guess it is just a normal node js image and run nuxt build and then run it?
2 Replies
kapa.ai
kapa.ai2w ago
Hi @LordGhandi. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Yes, you are correct: deploying a Nuxt application with Docker is a common approach, and the official Nuxt documentation provides guidance for this scenario. The typical process involves using a Node.js Docker image, running the build command (such as pnpm run build, yarn build, or npm run build), and then running the production server using the generated output. Here’s a standard example Dockerfile for Nuxt (using Node.js and pnpm, but you can adapt it for npm or yarn):
# Build Stage 1
FROM node:22-alpine AS build
WORKDIR /app

RUN corepack enable

# Copy package.json and your lockfile
COPY package.json pnpm-lock.yaml .npmrc ./

# Install dependencies
RUN pnpm i

# Copy the entire project
COPY . ./

# Build the project
RUN pnpm run build

# Build Stage 2
FROM node:22-alpine
WORKDIR /app

# Only `.output` folder is needed from the build stage
COPY --from=build /app/.output/ ./

# Change the port and host
ENV PORT=80
ENV HOST=0.0.0.0

EXPOSE 80

CMD ["node", "/app/server/index.mjs"]
# Build Stage 1
FROM node:22-alpine AS build
WORKDIR /app

RUN corepack enable

# Copy package.json and your lockfile
COPY package.json pnpm-lock.yaml .npmrc ./

# Install dependencies
RUN pnpm i

# Copy the entire project
COPY . ./

# Build the project
RUN pnpm run build

# Build Stage 2
FROM node:22-alpine
WORKDIR /app

# Only `.output` folder is needed from the build stage
COPY --from=build /app/.output/ ./

# Change the port and host
ENV PORT=80
ENV HOST=0.0.0.0

EXPOSE 80

CMD ["node", "/app/server/index.mjs"]
This approach is confirmed in the Nuxt Content documentation, which describes how to build and run your Nuxt app in a Docker container. You only need to copy the .output directory from the build stage to the production image and run the server entrypoint as shown above. You can use this pattern alongside your custom .NET server in a docker-compose setup for your homelab or dev environment. For production on Azure, you can use a similar approach or leverage Azure-specific deployment options as needed Deploy with Docker. If you use a different package manager (npm or yarn), just adjust the install and build commands accordingly. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2w ago
<@358749735323959308> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?