chore(enos): Add scenario that uses docker containers for infrastructure (#3073)
Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
This commit is contained in:
1 parent
bbbd6b1e51
commit
acda0c3892
13 files changed
+647
-2
No files matched your search
@@ -0,0 +1,75 @@
|
||||
# Copyright (c) HashiCorp, Inc.
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
docker = {
|
||||
source = "kreuzwerker/docker"
|
||||
version = "3.0.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
variable "network_name" {
|
||||
description = "Name of Docker Network"
|
||||
type = string
|
||||
}
|
||||
variable "container_name" {
|
||||
description = "Name of Docker Container"
|
||||
type = string
|
||||
default = "database"
|
||||
}
|
||||
variable "user" {
|
||||
description = "Postgres Database username"
|
||||
type = string
|
||||
default = "boundary"
|
||||
}
|
||||
variable "password" {
|
||||
description = "Postgres Database password"
|
||||
type = string
|
||||
default = "boundary"
|
||||
}
|
||||
variable "database_name" {
|
||||
description = "Postgres Database name"
|
||||
type = string
|
||||
default = "boundarydb"
|
||||
}
|
||||
|
||||
resource "docker_image" "postgres" {
|
||||
name = "postgres:latest"
|
||||
keep_locally = true
|
||||
}
|
||||
|
||||
resource "docker_container" "postgres" {
|
||||
image = docker_image.postgres.image_id
|
||||
name = var.container_name
|
||||
command = ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]
|
||||
env = [
|
||||
"POSTGRES_DB=${var.database_name}",
|
||||
"POSTGRES_USER=${var.user}",
|
||||
"POSTGRES_PASSWORD=${var.password}",
|
||||
]
|
||||
volumes {
|
||||
host_path = abspath(path.module)
|
||||
container_path = "/etc/postgresql/"
|
||||
}
|
||||
ports {
|
||||
internal = 5432
|
||||
external = 5432
|
||||
}
|
||||
healthcheck {
|
||||
test = ["CMD", "pg_isready", "-U", "${var.user}", "-d", "${var.database_name}"]
|
||||
interval = "3s"
|
||||
timeout = "5s"
|
||||
retries = 5
|
||||
}
|
||||
wait = true
|
||||
must_run = true
|
||||
networks_advanced {
|
||||
name = var.network_name
|
||||
}
|
||||
}
|
||||
|
||||
output "address" {
|
||||
value = "postgres://${var.user}:${var.password}@${var.container_name}:5432/${var.database_name}?sslmode=disable"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
listen_addresses = '*'
|
||||
max_connections = 100
|
||||
work_mem = 50000kB
|
||||
shared_buffers = 64MB
|
||||
log_destination = 'stderr'
|
||||
deadlock_timeout = 100
|
||||
log_min_messages = info
|
||||
log_min_error_statement = error
|
||||
log_error_verbosity = verbose
|
||||
log_lock_waits = true
|
||||
log_statement = all
|
||||
log_duration = on
|
||||
log_min_duration_statement = 0
|
||||
log_line_prefix = '%m [%p] (%x) %i '
|
||||
Reference in new issue
Block a user