While I know that the course was meant for backend apps, I've tried making a docker-compose.yml and Dockerfile for a frontend Nuxt.js app. My docker-compose.yml file looks like this:
version: '2.4'
services:
web:
build: .
volumes:
- .:/app
- /app/node_modules/
ports:
- 3000:3000
Any my Dockerfile:
FROM node:13.0-alpine
ENV NODE_ENV=development
WORKDIR /app
EXPOSE 3000
COPY package.json yarn.lock* ./
RUN apk add --no-cache --virtual .build-deps alpine-sdk python \
&& yarn && yarn cache clean \
&& apk del .build-deps
ENV PATH=./node_modules/.bin/:$PATH
COPY . .
CMD ["nuxt"]
When I run this with docker-compose up
, my application builds and starts properly though the nuxt
CMD, but when I go to http://localhost:3000 the app isn't online.
What am I doing wrong here?
your cmd should be
CMD ["yarn", "dev"]
in docker compose you can add the line command and use it for apply dev or start when you need.
version: '3'
services:
web:
build: .
volumes:
- .:/app
- /app/node_modules/
ports:
- 3000:3000
command: yarn dev
# or
# command: yarn build && yarn start
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.