Current location - Health Preservation Learning Network - Slimming men and women - Docker deploys SpringBoot, Mysql, Redis, Nginx and Vue under Ubuntu 16.04.
Docker deploys SpringBoot, Mysql, Redis, Nginx and Vue under Ubuntu 16.04.
This paper takes the open source projects SpringBlade and Saber as examples.

1. Create a custom network

The purpose is to put all the services used in the same network segment to facilitate communication with each other.

Docker network creation-subnet172.19.0.0/16mynetwork

2.Docker installs MySQL, Redis and Nginx.

(1) Install MySQL

Docker pulls mysql:5.7.30

cd ~

mkdir docker/mysql/{conf,logs,data} -p

cd docker/mysql

docker run-name MySQL _ blade-network = my network-IP = 172. 19 . 0 . 6-p 3307:3306-v PWD/logs:/var/log/MySQL-v PWD/data:/ data:rw-v $ PWD/conf/redis . conf:/etc/redis/redis . conf:ro-privileged = true-name redis-6389-d redis redis-server/etc/redis

(3) install Nginx

You need to publish Saber to Nginx.

Docker pull nginx

2. dockers pack springboks.

3.Docker packages and publishes Saber.

(1) write nginx.conf

Cd saber

Touch nginx.conf and write the following:

//nginx.conf start

User root

worker _ process 1;

error _ log/var/log/nginx/error . log warn;

PID/var/run/nginx . PID;

Event {

Worker _ connection1024;

}

. spotify & lt/groupId & gt;

& ltartifactId & gtdocker file-maven-plugin & lt; /artifact id & gt;

& lt version & gt {project. basedir}</context directory >

& ltuseMavenSettingsForAuth & gttrue & lt/useMavenSettingsForAuth & gt;

& lt knowledge base & gt {docker.registry.name}/{docker.image.tag} < /tag & gt;

& ltbuildArgs & gt

& ltJAR _ FILE & gttarget/{ Java . version } & lt; /source & gt;

& lttarget & gt$ { java.version } & lt/target & gt;

& lt encoding & gtUTF-8 & lt;; /encoding & gt;

& lt compiler parameters & gt

& ltarg & gt- parameter & lt/arg >

& lt/compiler args & gt;

& lt/configuration & gt;

& lt/plugin & gt;

& lt/plugins & gt;

& lt/build & gt;

(2)yml configuration

When creating the container, Redis and mysql should have the same configuration as before:

(3) Creating private warehouses (using seaports)

Create a project blade in the harbor management interface, and add the project path when uploading the following picture.

(4) packaging

Mvn newly installed Dockerfile: build-d maven.test.skip = true.

(5) upload to private warehouse

Two ways:

Mvn dockerfile file: pushing

Or docker push10.10.0. 1 27:10080/blade/spring leaf: 0.0.1.

Then you can see the mirror backstage in the harbor management.

To pull down:

Dockworkers pull10.10.0. 1 27:10080/blade/jumping blade: 0.0.1

(6) release

cd ~

mkdir docker/blade/app -p

cd docker/blade

docker run-itd-name blade-network = my network-IP = 172. 19.0 . 7-p 900 1:900 1-v $ PWD/app:/mnt/ 10. 1 0.0 . 127: 1080/blade/spring blade:0.65448

At this point, you can access Saber through localhost: 1889.

In addition, I distinguish multi-tenants through URIs. For example, localhost: 1889 is an administrative tenant, and localhost: 1889/test is a tenant named test. This avoids filling in the tenant id in the login interface.