Start the Docker service

service docker start

Install and configure Git

Install git

apt install git

Configure git accounts and passwords globally

git config --global user.name "username" git config --global user.email "useremail"

Generate an SSH key and press Enter without setting a password

ssh-keygen -t rsa -C "useremail"

View the generated key files id_rsa and id_rsa.pub

cd ~/.ssh

Select the contents of the public key ID_rsa. pub to copy to gitee

cat id_rsa.pub

Pull the code

CD/Back to the root directory

Mkdir code Creates a code folder

Git clone [email protected]: XXX/cangkumingcheng git pull code, enter yes enter, after completion of execution, will generate folders cangkumingcheng under the current directory

Git checkout — Track feature/1.0.0 Git clone – b feature / 1.0.0 [email protected]: XXX/cangkumingcheng git

Project code configuration

Vue3 project is generated using vuE-CLI tool. Here docker and Nginx configuration is described. The directory structure is as follows

The scripts section of package.json

"name": "fly-manage",
"version": "0.1.0",
"private": true,
"scripts": {
    "serve": "vue-cli-service serve",
    "build-dist": "vue-cli-service build",
    "test:unit": "vue-cli-service test:unit",
    "lint": "vue-cli-service lint",
    "clean-container": "docker rm -f $(docker ps -a | grep \"$npm_package_name\" | awk \"{print \\$1}\") || true",
    "clean-images": "docker rmi -f $(docker images | grep \"$npm_package_name\" | awk \"{print \\$3}\") || true",
    "build-temp": "docker build -t $npm_package_name:$npm_package_version --no-cache .",
    "build": "yarn clean-container && yarn clean-images && yarn build-temp"
  },
Copy the code

Docker/nginx. Conf configuration

user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; ## Default: 1024 } http { include /etc/nginx/mime.types; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" $request_body'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; # gzip on; # include /etc/nginx/conf.d/*.conf; server { listen 80; server_name localhost; client_max_body_size 50M; location / { add_header Cache-Control no-cache; root /web; index index.html; try_files $uri $uri/ /index.html; }}}Copy the code

Dockerfile is a text file used to build the image (set the NPM source in the file), which is used by the Docker build command

FROM node:lts-alpine as builder ADD . /test/ WORKDIR /test RUN npm config set registry https://registry.npm.taobao.org/ \ && npm install --loglevel verbose \ && npm run build-dist FROM nginx:latest COPY --from=builder test/dist /test RUN rm  /etc/nginx/nginx.conf COPY nginx/default.conf /etc/nginx/nginx.confCopy the code

After using Git to pull the code, go to the code directory and run NPM run build to delete the image and container and generate a new image.

Docker-comemage. yml compose is a tool for defining and running multi-container Docker applications. With Compose, you can use YML files to configure all the services your application needs. Then, with a single command, all services can be created and started from the YML file configuration.

Version: "3" services: web: container_name: generated container name image: generated image name Ports: -8001:80 restart: alwaysCopy the code

After the image is generated, execute docker-compose up -d in docker-compose. Yml directory, and start the container in the background. 8001 is the port of the started service