1. UseDockeR to the frontvueProject Deployment

1.1 Environment Preparations

Install the server or VM firstNginxAnd related configurations

  1. docker pull nginxPull the latest versionnginx
  2. runnginx.docker run --name=mynginx -d -p 8080:80 nginx
  3. Then develop port 80 in the server security group or firewall and type in the browserip:8080If this screen logo appearsnginx Successful installation

1.2 Vue project preparation

  1. Package the VUE project by specifyingnpm run buildPackage the project to generate the DIST folder
  2. Create files in the root directory of your projectDockerfileThere is no file suffix. The file configuration is as follows
Step 1 has installed the latest version of nginx
FROM nginx
# define author name
MAINTAINER xiongchao
Copy the dist folder to /usr/share/nginx/html/
COPY dist/   /usr/share/nginx/html/ 

Copy the code
  1. Upload the files, create a folder on the server in a location you specify (easy to deploy yourself), and upload the dist folder and Dockerfile files to a directory
  2. Build the mirrordocker build -t myvueproject .
  3. throughdocker images To check whether the mirror is successfully constructed
  4. Boot imagedocker run --name=dockervue -d -p 8001:8080 myvueproject
  5. throughip:8001To see the successful deployment of the project

2. UseDockerfileforspringbootApplication of buildingdockerThe mirror

2.1 DockerCommon instructions

ADD

Used to copy files

ADD < SRC > <dest> # ADD test.jar /test.jar to docker container/directoryCopy the code
ENTRYPOINT

Specifies the command to start docker

ENTRYPOINT [" Java ","-jar","/test.jar"]Copy the code
ENV

Used to set environment variables in the following format

ENV MYSQL_ROOT_PASSWORD rootCopy the code
EXPOSE

Declare exposed ports

EXPOSE <port> <port2> # example EXPOSE 8080Copy the code
FROM

Specify the base image that you want to rely on

FROM <image>:<tag> #Copy the code
MAINTAINER

Specify the name of the maintainer

MAINTAINER <name> # Example MAINTAINER XiongcCopy the code
RUN

Commands executed during container construction, such as installing other related dependencies or as required by the environment

RUN <command> # example RUN bash -c 'touch /test.jar'Copy the code

2.2 Detailed Configuration file and Description

FROM java:8
ADD test.jar /test.jar
RUN bash -c 'touch /test.jar'
EXPOSE 8080
ENTRYPOINT ['java'.'-jar'.'/test.jar']
MAINTAINER xiongchao

Copy the code

2.3 Starting Construction

  1. Will be packagedjaranddockerfileUpload to the specified path of the server
  2. Build the mirror
Docker build -t javaproject/javaprojectCopy the code
  1. Start the project
docker run --name=tomcatA01 -d -p 8002:8080 javaproject 
Copy the code