rook
rook

Reputation: 1164

Nuxt Docker: Exit code 0

I am building a Dockerfile for my Nuxt app. Whenever the container starts it gets exited with error code 0 immediately.

Here is my Dockerfile:

# Builder image
FROM node:16-alpine as builder

# Set up the working directory
WORKDIR /app

# Copy all files (Nuxt app) into the container
COPY ../frontend .

# Install dependencies
RUN npm install

# Build the app
RUN npm run build

# Serving image
FROM node:16-alpine

# Set up the working directory
WORKDIR /app

# Copy the built app
COPY --from=builder /app ./

# Specify the host variable
ENV HOST 0.0.0.0

# Expose the Nuxt port
ENV NUXT_PORT=3000
EXPOSE 3000

CMD ["npm", "run", "start"]

my docker-compose.yml file has:

  frontend:
    container_name: frontend
    build:
      context: .
      dockerfile: ./docker/nuxt/Dockerfile
    ports:
      - "3000:3000"
    networks:
      - app-network

When I try to see the log file of the container, it only shows this.. which doesn't help me.

> [email protected] start
> nuxt start

Upvotes: 1

Views: 313

Answers (1)

rook
rook

Reputation: 1164

OK, I needed to add .dockerignore file

frontend/.nuxt/
frontend/dist/
frontend/node_modules/

Upvotes: 1

Related Questions