From 1b5434f2498e1c5346764828b518fa1715c86f2c Mon Sep 17 00:00:00 2001 From: Niklas van Schrick Date: Sat, 26 Oct 2024 15:40:04 +0200 Subject: [PATCH] Add protection against non-existing docker images with data sources --- modules/docker/plane/images.tf | 56 +++++++++++++++++++++++++++++----- modules/docker/proxy/main.tf | 7 ++++- 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/modules/docker/plane/images.tf b/modules/docker/plane/images.tf index ed12090..eaf74b9 100644 --- a/modules/docker/plane/images.tf +++ b/modules/docker/plane/images.tf @@ -1,31 +1,71 @@ -resource "docker_image" "plane_frontend" { +data "docker_registry_image" "plane_frontend" { name = "makeplane/plane-frontend:v0.22-dev" } -resource "docker_image" "plane_space" { +resource "docker_image" "plane_frontend" { + name = data.docker_registry_image.plane_frontend.name + pull_triggers = [data.docker_registry_image.plane_frontend.sha256_digest] +} + +data "docker_registry_image" "plane_space" { name = "makeplane/plane-space:v0.22-dev" } -resource "docker_image" "plane_admin" { +resource "docker_image" "plane_space" { + name = data.docker_registry_image.plane_space.name + pull_triggers = [data.docker_registry_image.plane_space.sha256_digest] +} + +data "docker_registry_image" "plane_admin" { name = "makeplane/plane-admin:v0.22-dev" } -resource "docker_image" "plane_backend" { +resource "docker_image" "plane_admin" { + name = data.docker_registry_image.plane_admin.name + pull_triggers = [data.docker_registry_image.plane_admin.sha256_digest] +} + +data "docker_registry_image" "plane_backend" { name = "makeplane/plane-backend:v0.22-dev" } -resource "docker_image" "plane_proxy" { +resource "docker_image" "plane_backend" { + name = data.docker_registry_image.plane_backend.name + pull_triggers = [data.docker_registry_image.plane_backend.sha256_digest] +} + +data "docker_registry_image" "plane_proxy" { name = "makeplane/plane-proxy:v0.22-dev" } -resource "docker_image" "postgres" { +resource "docker_image" "plane_proxy" { + name = data.docker_registry_image.plane_proxy.name + pull_triggers = [data.docker_registry_image.plane_proxy.sha256_digest] +} + +data "docker_registry_image" "postgres" { name = "postgres:15.7-alpine" } -resource "docker_image" "valkey" { +resource "docker_image" "postgres" { + name = data.docker_registry_image.postgres.name + pull_triggers = [data.docker_registry_image.postgres.sha256_digest] +} + +data "docker_registry_image" "valkey" { name = "valkey/valkey:7.2.5-alpine" } -resource "docker_image" "minio" { +resource "docker_image" "valkey" { + name = data.docker_registry_image.valkey.name + pull_triggers = [data.docker_registry_image.valkey.sha256_digest] +} + +data "docker_registry_image" "minio" { name = "minio/minio:RELEASE.2024-07-10T18-41-49Z" } + +resource "docker_image" "minio" { + name = data.docker_registry_image.minio.name + pull_triggers = [data.docker_registry_image.minio.sha256_digest] +} diff --git a/modules/docker/proxy/main.tf b/modules/docker/proxy/main.tf index 4219887..889fd8f 100644 --- a/modules/docker/proxy/main.tf +++ b/modules/docker/proxy/main.tf @@ -11,10 +11,15 @@ terraform { } } -resource "docker_image" "proxy" { +data "docker_registry_image" "proxy" { name = "nginxproxy/nginx-proxy:1.6.3" } +resource "docker_image" "proxy" { + name = data.docker_registry_image.proxy.name + pull_triggers = [data.docker_registry_image.proxy.sha256_digest] +} + resource "docker_network" "proxy" { name = "proxy" attachable = true