소스 검색

initial commit

Chris Mague 8 년 전
커밋
3ce425a25b
4개의 변경된 파일72개의 추가작업 그리고 0개의 파일을 삭제
  1. 4 0
      .gitignore
  2. 1 0
      .terraform-version
  3. 23 0
      README.md
  4. 44 0
      main.tf

+ 4 - 0
.gitignore

@@ -0,0 +1,4 @@
+.terraform.tfstate.lock.info
+postgres_data
+terraform.tfstate
+terraform.tfstate.backup

+ 1 - 0
.terraform-version

@@ -0,0 +1 @@
+0.9.2

+ 23 - 0
README.md

@@ -0,0 +1,23 @@
+# Keycloak
+
+Runs a keycloak docker container, postgres container and sets up a database
+
+
+## Prerequisites
+
+1. Install [tfenv](https://github.com/kamatama41/tfenv)
+
+
+## Setting Up
+
+```
+tfenv install `cat .terraform-version`
+```
+
+## Running
+
+```
+terraform plan
+terraform apply
+```
+

+ 44 - 0
main.tf

@@ -0,0 +1,44 @@
+resource "docker_image" "postgres" {
+  name         = "postgres:9.6"
+  keep_locally = true
+}
+
+resource "docker_image" "keycloak" {
+  name         = "jboss/keycloak-postgres"
+  keep_locally = true
+}
+
+resource "docker_container" "postgres" {
+  name  = "postgres"
+  image = "${docker_image.postgres.latest}"
+
+  env = [
+    "POSTGRES_PASSWORD=winning",
+    "PGDATA=/postgres_data",
+  ]
+
+  volumes {
+    container_path = "/postgres_data"
+    host_path      = "${path.module}/postgres_data"
+  }
+}
+
+resource "docker_container" "keycloak" {
+  name  = "keycloak"
+  image = "${docker_image.keycloak.latest}"
+
+  ports {
+    internal = 8080
+    external = 8080
+  }
+
+  links = [
+    "${docker_container.postgres.name}",
+  ]
+
+  env = [
+    "POSTGRES_DATABASE=local",
+    "POSTGRES_PORT_5432_TCP_ADDR=${docker_container.postgres.name}",
+    "KEYCLOAK_USER=local",
+  ]
+}