-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
67 lines (54 loc) · 1.24 KB
/
main.tf
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = "~> 3.0.1"
}
}
}
provider "docker" {}
resource "docker_image" "mysql" {
name = "mysql:8.0"
keep_locally = true
}
resource "docker_image" "redis" {
name = "redis:7.4.0"
keep_locally = true
}
# Terraform plan
# TODO: Build image: api-server
# TODO: Build image: chat-server
# TODO: BUild image: frontend
# TODO: Add container(api-server)
# TODO: Add 2 containers(chat-server)
# TODO: Add container(frontend)
# TODO: Add container(api-server) for run-migrate cli(instant runner)
resource "docker_container" "mysql" {
image = docker_image.mysql.image_id
name = "mysql"
ports {
internal = 3306
external = 3306
}
env = [
# password for local => root:localhost
"MYSQL_ROOT_PASSWORD=localhost",
"MYSQL_DATABASE=chat",
]
volumes {
host_path = "${abspath(terraform.workspace)}/db/data"
container_path = "/var/lib/mysql"
}
volumes {
host_path = "${abspath(terraform.workspace)}/db/my.cnf"
container_path = "/etc/mysql/my.cnf"
}
}
resource "docker_container" "redis" {
image = docker_image.redis.image_id
name = "redis"
ports {
internal = 6397
external = 6397
}
}