Docker Deployment Project - Demo vueblog
Foreword
Bilibili: https://www.bilibili.com/video/BV17A411E7aE
Github: https://github.com/MarkerHub/vueblog
Docker Documentation: https://docs.docker.com/
Deploy in Linux environment
Use docker-compose
for orchestration, one-time deployment.
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration. To learn more about all the features of Compose, see the list of features.
Compose works in all environments: production, staging, development, testing, as well as CI workflows. You can learn more about each case in Common Use Cases.
Using Compose is basically a three-step process:
1. Define your app’s environment with a Dockerfile
so it can be reproduced anywhere.
2. Define the services that make up your app in docker-compose.yml so they can be run together in an isolated environment.
3. Run docker compose up
and the Docker compose command starts and runs your entire app. You can alternatively run docker-compose up
using the docker-compose binary.
A docker-compose.yml
looks like this:
1 |
|
1. Install docker
https://docs.docker.com/engine/install/
2. Install docker compose
3. Write Dockerfile
1 |
|
4. Write the docker-compose.yml file
1 |
|
6. Prepare the mount directory and configuration of nginx
Host mount directory: /root/nginx/html
Mount configuration: /root/nginx/nginx.conf
Write nginx.conf
, the specific configuration is as follows:
1 |
|
7. Upload frontend
Modify the interface
First modify the interface of the front-end to call the back-end, and then package:axios.js
in/src
folder:1
axios.defaults.baseURL='http://yourServerIp:8085'
Package
Thennpm run build
packs thedist
folder and uploads it to theroot/nginx/html
directory of linux.
8. Deploy backend
Update vue-springboot-blog-0.0.1-SNAPSHOT.jar
, docker-compose.yml
, Dockerfile
to linux server.
1 |
|
Where -d means start in the form of a background service.