Skip to content

Commit

Permalink
refactor: prepare for migration to kube
Browse files Browse the repository at this point in the history
  • Loading branch information
dd84ai committed Mar 3, 2024
1 parent 9885b5f commit c01ffa9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,36 +1,18 @@
# Create a docker image resource
# -> docker pull nginx:latest
resource "docker_image" "darkbot" {
count = var.mode == "docker" ? 1 : 0
name = "darkwind8/darkbot:${var.tag_version}"
keep_locally = true
}

variable "tag_version" {
type = string
}

variable "configurator_dbname" {
type = string
}

variable "consoler_prefix" {
type = string
}

variable "debug" {
type = bool
default = false
}

variable "secrets" {
type = map(string)
}

# # Create a docker container resource
# # -> same as 'docker run --name nginx -p8080:80 -d nginx:latest'
resource "docker_container" "darkbot" {
count = var.mode == "docker" ? 1 : 0

name = "darkbot"
image = docker_image.darkbot.image_id
image = docker_image.darkbot[0].image_id

env = [
"SCRAPPY_PLAYER_URL=${var.secrets["SCRAPPY_PLAYER_URL"]}",
Expand Down
29 changes: 29 additions & 0 deletions infra/tf/modules/darkbot/input.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
variable "tag_version" {
type = string
}

variable "configurator_dbname" {
type = string
}

variable "consoler_prefix" {
type = string
}

variable "debug" {
type = bool
default = false
}

variable "secrets" {
type = map(string)
}

variable "mode" {
type = string

validation {
condition = contains(["kubernetes", "docker"], var.mode)
error_message = "Valid mode. should be docker or kubernetes"
}
}
Empty file.
3 changes: 2 additions & 1 deletion infra/tf/production/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ locals {
}

provider "docker" {
host = "ssh://root@${module.stack.cluster_ip}:22"
host = "ssh://root@${module.stack.ipv4_address}:22"
ssh_opts = ["-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "-i", "~/.ssh/id_rsa.darklab"]
}

Expand All @@ -31,4 +31,5 @@ module "darkbot" {
consoler_prefix = "."
secrets = local.secrets
tag_version = "v1.5.1"
mode = "docker"
}
1 change: 1 addition & 0 deletions infra/tf/staging/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ module "darkbot" {
secrets = local.secrets
tag_version = "v1.5.1-arm"
debug = false
mode = "docker"
}

0 comments on commit c01ffa9

Please sign in to comment.