-
Notifications
You must be signed in to change notification settings - Fork 0
/
compose.yaml
45 lines (42 loc) · 1.57 KB
/
compose.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
services:
mysql:
image: mysql:8.0
volumes:
- mysql-data:/var/lib/mysql
- ./certs:/etc/mysql/certs
environment:
- MYSQL_ROOT_PASSWORD=secret
ports:
- "3307:3306"
command:
- --ssl-ca=/etc/mysql/certs/ca-cert.pem
- --ssl-cert=/etc/mysql/certs/server-cert.pem
- --ssl-key=/etc/mysql/certs/server-key.pem
- --ssl=1
- --require_secure_transport=ON
cert-gen:
build: .
image: test-cert-gen
volumes:
- ./certs:/certs
entrypoint:
- /bin/sh
- -c
- |
rm -rf /certs/* &&
openssl genrsa 2048 > /certs/ca-key.pem &&
openssl req -new -x509 -nodes -days 3650 -key /certs/ca-key.pem -subj "/CN=mysql/O=myorg/C=US" > /certs/ca-cert.pem &&
openssl req -newkey rsa:2048 -days 3650 -nodes -keyout /certs/server-key.pem -subj "/CN=mysql/O=myorg/C=US" > /certs/server-req.pem &&
openssl x509 -req -in /certs/server-req.pem -days 3650 -CA /certs/ca-cert.pem -CAkey /certs/ca-key.pem -set_serial 01 > /certs/server-cert.pem &&
openssl rsa -in /certs/server-key.pem -out /certs/server-key.pem &&
openssl req -newkey rsa:2048 -days 3650 -nodes -keyout /certs/client-key.pem -subj "/CN=mysql/O=myorg/C=US" > /certs/client-req.pem &&
openssl x509 -req -in /certs/client-req.pem -days 3650 -CA /certs/ca-cert.pem -CAkey /certs/ca-key.pem -set_serial 01 > /certs/client-cert.pem &&
openssl rsa -in /certs/client-key.pem -out /certs/client-key.pem
chmod 644 /certs/*
restart: "no"
#
# client:
# image: alpine:latest
# restart: unless-stopped
volumes:
mysql-data: