Docker-compose is used for front-end (C) and back-end (R) deployment

  • Front-end stack: Angular8+ ng-Zorro-ANTD
  • Back-end technology stack: Flask+MySQL

CentOS 7 is used as an example

Ready to step

Install the docker – compose

sudo curl -L "https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Copy the code

Modify the permissions

sudo chmod +x /usr/local/bin/docker-compose
Copy the code

Soft connection

sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
Copy the code

Check out the Docker-compose version

The body of the

The directory structure is as follows

Deploy ├ ─ ─ data │ └ ─ ─ mysql │ ├ ─ ─ the conf. D │ │ └ ─ ─ mysql. The CNFMySQL configuration file│ ├ ─ garbage, ├ ─ trashCopy the code

docker-compose.yml

version: '3'
services:
  mysql:                                            # service name
    image: Mysql: 5.7                                # image
    restart: always   
    volumes:
      - ./data/mysql/conf.d:/etc/mysql/conf.d       # config file mount
      - ./data/mysql/data:/var/lib/mysql            # Data mount
    environment:
      MYSQL_DATABASE: demo                          # database name
      MYSQL_ROOT_PASSWORD: whoami                   # root password
      TZ: Asia/Shanghai                             # time zone
    ports:
      - 53306: 3306                                  # port mapping
  friend_frontend:
    image: isplaying/friend_frontend:dev_20200222   # Front-end image
    restart: always
    depends_on:
      - friend_backend                              # Start after friend_backend is started
    links:
      - friend_backend                              Connect containers
    ports:
      - 10011: 80                                    # port mapping
  friend_backend:
    image: isplaying/friend_backend:dev_20200222
    restart: always
    environment:                                    # Environment variables
      MODE: DEVELOPMENT                             
      MYSQL_DATABASE: demo
      MYSQL_PASSWORD: whoami
      TZ: Asia/Shanghai
    depends_on:
      - mysql                                       Start after mysql is started
    links:
      - mysql
    ports:
      - 10001: 10001

Copy the code

Execute docker-compose up to start the container

docker-compose up
Copy the code

Enter localhost:10011 in the browser

Add a piece of data

TIPS: About MySQL connection parameter configuration

This section uses this configuration as an example

You can directly enter the service name host= through links"mysql", port=3306 for external access, enter host IP host="Host IP", port=53306
Copy the code

Install Docker Compose

The front-end warehouse

The back-end warehouse