SovietChicken
SovietChicken
NNuxt
Created by SovietChicken on 12/1/2024 in #❓・help
Nuxt app to production using docker
Hey guys, I am trying to deploy my nuxt app to production using docker. I have already found countless articles about that topic but they dont actually deploy to production but rather the development version. I tried coming up with my own solution but I am unsure if this is actually correct or if this introduces a few security concerns:
ARG NODE_VERSION=22.11.0

# Create build stage
FROM node:${NODE_VERSION}-slim AS build

# Set the working directory inside the container
WORKDIR /app

# Installing dependencies
COPY yarn.lock package.json ./
RUN yarn install

# Copying remaining contents
COPY . .

EXPOSE 3000

#CMD ["yarn", "build", "--host", "0.0.0.0"]
RUN yarn build
CMD ["node", ".output/server/index.mjs"]
ARG NODE_VERSION=22.11.0

# Create build stage
FROM node:${NODE_VERSION}-slim AS build

# Set the working directory inside the container
WORKDIR /app

# Installing dependencies
COPY yarn.lock package.json ./
RUN yarn install

# Copying remaining contents
COPY . .

EXPOSE 3000

#CMD ["yarn", "build", "--host", "0.0.0.0"]
RUN yarn build
CMD ["node", ".output/server/index.mjs"]
I would really appreciate any sort of feedback and issues you guys might see with my Dockerfile Articles: - https://mokkapps.de/blog/dockerizing-a-nuxt-app - https://nuxt.com/docs/getting-started/deployment - https://shipyard.build/blog/how-to-yarn-project-with-docker/
5 replies