Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing quotes in RUN step when building image #659

Open
LucasDemea opened this issue Nov 15, 2024 · 0 comments
Open

Missing quotes in RUN step when building image #659

LucasDemea opened this issue Nov 15, 2024 · 0 comments

Comments

@LucasDemea
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and docker Provider) Version

terraform v1.9.8
kreuzwerker/docker v3.0.2

Affected Resource(s)

  • docker_image

Terraform Configuration Files

terraform {

  backend "s3" {}

  required_version = ">= 1.0.0"

  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = ">= 5.76"
    }
    docker = {
      source  = "kreuzwerker/docker"
      version = ">= 3.0.2"
    }
  }
}

variable "name" {
  type        = string
  description = "name for the resources"
}

variable "environment" {
  type        = string
  description = "environment for the resources"
}

variable "image_tag" {
  type        = string
  description = "container image tag"
}

variable "project" {
  type        = string
  description = "project name in monorepo"
}

locals {
  ns = "${var.name}-${var.environment}"
}

data "aws_region" "current" {}

data "aws_caller_identity" "current" {}

data "aws_ecr_authorization_token" "token" {}

provider "aws" {}

provider "docker" {
  registry_auth {
    address  = format("%v.dkr.ecr.%v.amazonaws.com", data.aws_caller_identity.current.account_id, data.aws_region.current.name)
    username = data.aws_ecr_authorization_token.token.user_name
    password = data.aws_ecr_authorization_token.token.password
  }
}

module "docker_image" {
  source = "terraform-aws-modules/lambda/aws//modules/docker-build"

  docker_file_path = "Dockerfile.frontend"
  create_ecr_repo  = true
  ecr_repo         = trim(replace(local.ns, "--" , "-"), "-") # replace double dash with simple dash and trim ending dash
  image_tag        = var.image_tag
  source_path      = "../../"
  build_args = {
    NODE_VERSION    = "20"
    PROJECT         =  var.project
    PORT            =  "8080"
  }
}

module "lambda_function_from_container_image" {
  source = "terraform-aws-modules/lambda/aws"

  function_name              = local.ns
  description                = "Ephemeral preview environment for: ${local.ns}"
  create_package             = false
  package_type               = "Image"
  image_uri                  = module.docker_image.image_uri
  architectures              = ["x86_64"]
  create_lambda_function_url = true
  timeout                    = 30
  memory_size                = 1024
}

output "endpoint_url" {
  value = module.lambda_function_from_container_image.lambda_function_url
}

Debug Output

https://gist.github.com/LucasDemea/6c7cb9c86285450283069ef08b50f18c

Expected Behaviour

Docker image should build

Actual Behaviour

Build fails on step RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile.

The error is : Error: process "/bin/sh -c pnpm install --frozen-lockfile" did not complete successfully: exit code: 1

It seems the generated command is missing quotes, and should be instead: /bin/sh -c "pnpm install --frozen-lockfile".

Steps to Reproduce

  1. terraform apply
  • #0000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant