Aller au contenu

Docker with Nuxt js

Configure a development container

Create a docker-compose.yml file and add the following content.

docker-compose.yml
version: '3.3'
services:
nuxt:
build:
context: .
image: your-image-name
container_name: your-container-name
command: npm run dev
volumes:
- .:/app
- /app/node_modules
ports:
- "3000:3000"

Create a Dockerfile file and add the following content.

Dockerfile.yml
# The name is `Dockerfile` without extension
FROM node:20-alpine
WORKDIR /app
RUN apk update && apk upgrade
RUN apk add git
COPY ./package*.json /app/
RUN npm install && npm cache clean --force
COPY . .
ENV PATH ./node_modules/.bin/:$PATH

Execute the container :

Command to execute the container
docker-compose up