Introduction: a new server (Centos8.1)

1. Install Node and Docker.

Install ngxin

1, Docker pull nginx

2, docker run – d – name XXX – v/nginx/HTML: / usr/share/nginx/HTML – v/nginx/conf/nginx. Conf: / etc/nginx/nginx. Conf – v /nginx/log:/var/log/nginx -v /nginx/conf.d:/etc/nginx/conf.d -p 80:80 nginx

Ps: the first -v means to map the host file directory to the docker nginx container. The other meaning is the same, but the host file overwrites the corresponding file in the Docker nginx container

Docker ps -a check whether the container is running successfully

4, Docker logs XXX check the container running status (if there is an error can be viewed here)

Docker restart XXX restarts the container image

Docker stop XXX stops the container running

Docker start XXX starts the container

Install nuxt

1, first package the project, then upload. Nuxt, static, nuxt.config.js, package.json files to the specified folder

2. Create Dockerfile

# set ENV NODE_ENV=production # set IP ENV HOST 0.0.0.0 # create folder RUN mkdir -p /app WORKDIR /app # Expose the app port Expose 3000 #If the environment in China Build both please open the following comments # if environment building in China please open the following comments RUN NPM config set registry at https://registry.npm.taobao.org  RUN npm install #RUN npm run build CMD ["npm", "start"]Copy the code

3. Place the Dockerfile and the packaged files in a folder

4, execute docker build -t XXX. (-t set the last dot of the generated image name must be added)

Docker run-dt –name XXX -p 320:3000 XXX (-p set the host port to be the same as the mirror port, or the mirror will not work properly)

Docker ps -a check the running status

7, if the operation fails, see nginx view error log to repair