Skip to content

Commit 52bf6cd

Browse files
committed
feat(all): add 'docker-compose.yaml'
1 parent ada913e commit 52bf6cd

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

docker-compose.yaml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
version: '3.7'
2+
3+
services:
4+
5+
mysql_db:
6+
container_name: mysql_container
7+
image: mysql:8
8+
9+
command: --default-authentication-plugin=mysql_native_password
10+
11+
environment:
12+
LANG: C.UTF-8
13+
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}
14+
MYSQL_USER: ${MYSQL_USER:-admin}
15+
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-admin}
16+
MYSQL_DATABASE: ${MYSQL_DATABASE:-database}
17+
18+
volumes:
19+
- ./initdb:/docker-entrypoint-initdb.d
20+
- ./mysql:/var/lib/mysql/
21+
22+
ports:
23+
- ${MYSQL_PORT:-3306}:3306
24+
25+
restart: unless-stopped
26+
27+
healthcheck:
28+
test: [ 'CMD', 'mysqladmin', 'ping', '-proot' ]
29+
interval: 1m
30+
timeout: 5s
31+
retries: 5
32+
start_period: 3m
33+
34+
deploy:
35+
resources:
36+
limits:
37+
cpus: '1'
38+
memory: 2G
39+
40+
# ============ !!!!! ============
41+
# Start:
42+
# docker-compose --compatibility up -d
43+
# -------------------------------
44+
# Access to MySQL:
45+
# Root password: root
46+
# URL: localhost:3306
47+
# Database: database
48+
# Username: admin
49+
# Password: admin
50+
# -------------------------------
51+
# Stop lifted containers:
52+
# docker-compose --compatibility stop
53+
# -------------------------------
54+
# Start stopped containers
55+
# docker-compose --compatibility start
56+
# -------------------------------
57+
# Stop and delete containers and network:
58+
# docker-compose --compatibility down
59+
# -------------------------------
60+
# Delete 'mysql' directory
61+
# sudo rm -r mysql
62+

initdb/01_init_db.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CREATE TABLE book
2+
(
3+
book_id INT PRIMARY KEY AUTO_INCREMENT,
4+
title VARCHAR(50),
5+
author VARCHAR(30),
6+
price DECIMAL(8, 2),
7+
amount INT
8+
);
9+
10+
INSERT INTO book (title, author, price, amount)
11+
VALUES ('Мастер и Маргарита', 'Булгаков М.А.', 670.99, 3),
12+
('Белая гвардия', 'Булгаков М.А.', 540.50, 5),
13+
('Идиот', 'Достоевский Ф.М.', 460.00, 10),
14+
('Братья Карамазовы', 'Достоевский Ф.М.', 799.01, 2);

0 commit comments

Comments
 (0)