Implementation steps of docker deploying springboot and Vue projects

Time:2021-10-27

A. Docker deploying springboot project

1、 Spring boot project compilation and packaging

2、 Create a dockerfile file at the root of the project


FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD ./target/demo-0.0.1-SNAPSHOT.jar demo.jar
RUN sh -c 'touch /demo.jar'
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /demo.jar"]

Change demo-0.0.1-snapshot.jar to your jar package name

If the running environment of the jar package is Java, use openjdk: 8-jdk-alpine

3、 Execute in the root directory to form a docker image


docker build -t demmo-docker:1.0 .

4、 Run project


docker run docker run -dp 8080:8080 --name demo-docker demo-docker:1.0

B. Docker deployment Vue project

1、 Vue project is compiled and packaged and executed in the root directory of the project


npm run build

After execution, there will be dist folder

2、 Copy dist to an empty folder and create a dockerfile file


FROM nginx
MAINTAINER admin
COPY dist/  /usr/share/nginx/html/

In the dist folder, there are HTML, CSS and other files. You can use nginx to run HTML

3、 Execute in the parent folder of dockerfile to form a docker image


docker build -t demo-vue-docker . 

4、 Run project


docker run --name car-vue -d -p 8080:80 demo-vue-docker

C. Export mirror


docker save -o demo.tar demo-docker:1.0
docker save -o vue-demo.tar demo-vue-docker

D. Copy the tar file to the server

Copy the file to the server. The rar file is in the user directory. For example, the MAC system will be in / users / your user name /. If the file cannot be found, you can use the tool to find the file.

E. Import mirror


docker load -i demo.tar
docker load -i vue-demo.tar

F. Run project

It is consistent with the above description and will not be repeated

This is the end of this article about the implementation steps of docker deploying springboot and Vue projects. For more information about docker deploying springboot and Vue projects, please search the previous articles of developeppaer or continue to browse the relevant articles below. I hope you will support developeppaer in the future!