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

Cannot build images on Windows #663

Open
wadamek65 opened this issue Dec 14, 2024 · 0 comments
Open

Cannot build images on Windows #663

wadamek65 opened this issue Dec 14, 2024 · 0 comments

Comments

@wadamek65
Copy link

wadamek65 commented Dec 14, 2024

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

2024-12-14T20:09:21.233+0100 [INFO]  Terraform version: 1.10.2
2024-12-14T20:09:21.234+0100 [DEBUG] using github.com/hashicorp/go-tfe v1.70.0
2024-12-14T20:09:21.234+0100 [DEBUG] using github.com/hashicorp/hcl/v2 v2.23.0
2024-12-14T20:09:21.234+0100 [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2024-12-14T20:09:21.234+0100 [DEBUG] using github.com/zclconf/go-cty v1.15.1-0.20241111215639-63279be090d7
2024-12-14T20:09:21.234+0100 [INFO]  Go runtime version: go1.23.3
2024-12-14T20:09:21.234+0100 [INFO]  CLI args: []string{"terraform", "-v"}
2024-12-14T20:09:21.237+0100 [DEBUG] Attempting to open CLI config file: C:\Users\wadam\AppData\Roaming\terraform.rc
2024-12-14T20:09:21.237+0100 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2024-12-14T20:09:21.238+0100 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2024-12-14T20:09:21.238+0100 [DEBUG] ignoring non-existing provider search directory C:\Users\wadam\AppData\Roaming\terraform.d\plugins
2024-12-14T20:09:21.239+0100 [DEBUG] ignoring non-existing provider search directory C:\Users\wadam\AppData\Roaming\HashiCorp\Terraform\plugins
2024-12-14T20:09:21.239+0100 [INFO]  CLI command args: []string{"version", "-v"}
Terraform v1.10.2
on windows_386
+ provider registry.terraform.io/digitalocean/digitalocean v2.46.0
+ provider registry.terraform.io/hashicorp/null v3.2.3
+ provider registry.terraform.io/kreuzwerker/docker v3.0.2

Affected Resource(s)

  • docker_image

Terraform Configuration Files

I've tried a lot of different options and nothing was working properly.

The image builds just fine if I run a manual build.

terraform {
  required_providers {
    digitalocean = {
      source  = "digitalocean/digitalocean"
      version = "~> 2.0"
    }
    docker = {
      source  = "kreuzwerker/docker"
      version = "3.0.2"
    }
  }
}

# Configure the DigitalOcean Provider
provider "digitalocean" {
  token = local.do_token
}

provider "docker" {
  host = "npipe:////.//pipe//docker_engine"

  registry_auth {
    address  = "registry.digitalocean.com"
    username = local.do_token
    password = local.do_token
  }
}

data "digitalocean_container_registry" "sky_scout" {
  name = "sky-scout"
}

resource "docker_image" "rabbitmq" {
  name = "${data.digitalocean_container_registry.sky_scout.server_url}/rabbitmq:latest"
  build {
    context    = ".."
    dockerfile = abspath("${path.module}/Dockerfile.rabbitmq")
    no_cache   = true
  }
  lifecycle {
    create_before_destroy = true
  }
  # triggers = {
  #   dockerfile = filemd5("${path.module}/Dockerfile.rabbitmq")
  # }
}

resource "docker_image" "worker" {
  name = "${data.digitalocean_container_registry.sky_scout.server_url}/worker:latest"
  build {
    context    = ".."
    dockerfile = abspath("${path.module}/Dockerfile.worker")
    no_cache   = true
  }
  lifecycle {
    create_before_destroy = true
  }
  # triggers = {
  #   dockerfile = filemd5("${path.module}/Dockerfile.worker")
  # }
}

resource "docker_image" "orchestrator" {
  name = "${data.digitalocean_container_registry.sky_scout.server_url}/orchestrator:latest"
  build {
    context    = ".."
    dockerfile = abspath("${path.module}/Dockerfile.orchestrator")
    no_cache   = true
  }
  lifecycle {
    create_before_destroy = true
  }
  # triggers = {
  #   dockerfile = filemd5("${path.module}/Dockerfile.orchestrator")
  # }
}

resource "docker_registry_image" "rabbitmq" {
  name          = docker_image.rabbitmq.name
  keep_remotely = true
}

resource "docker_registry_image" "worker" {
  name          = docker_image.worker.name
  keep_remotely = true
}

resource "docker_registry_image" "orchestrator" {
  name          = docker_image.orchestrator.name
  keep_remotely = true
}

resource "null_resource" "deploy_containers" {
  triggers = {
    rabbitmq_image     = docker_registry_image.rabbitmq.name
    worker_image       = docker_registry_image.worker.name
    orchestrator_image = docker_registry_image.orchestrator.name
  }

  connection {
    type        = "ssh"
    user        = "root"
    private_key = file(local.ssh_private_key_path)
    host        = local.droplet_ip
  }

  provisioner "file" {
    source      = "${path.module}/docker-compose.yml"
    destination = "/opt/docker-deployments/docker-compose.yml"
  }

  provisioner "remote-exec" {
    inline = [
      "mkdir -p /opt/docker-deployments",
      "cd /opt/docker-deployments",
      "export REGISTRY_URL=${data.digitalocean_container_registry.sky_scout.server_url}",
      "docker network create sky-scout 2>/dev/null || true",
      "doctl auth init -t ${local.do_token}",
      "doctl registry login",
      "docker-compose pull",
      "docker-compose up -d --scale worker=10"
    ]
  }
}

output "rabbitmq_management_url" {
  value       = "http://${local.droplet_ip}:15672"
  description = "RabbitMQ Management Interface URL"
}

Debug Output

The same error happens for every single file in the repo. This is just an example as the whole log is too long.

Link to full logs

2024-12-14T20:05:58.664+0100 [DEBUG] provider.terraform-provider-docker_v3.0.2.exe: time="2024-12-14T20:05:58+01:00" level=error msg="Can't add file \\\\?\\C:\\MyFiles\\code\\sky-scout\\packages\\sky-scout-worker\\src\\supabaseTypes.ts to tar: archive/tar: missed writing 999 bytes"

Expected Behaviour

Build works

Actual Behaviour

A lot of errors related to sending files to context:

2024-12-14T20:05:58.664+0100 [DEBUG] provider.terraform-provider-docker_v3.0.2.exe: time="2024-12-14T20:05:58+01:00" level=error msg="Can't add file \\\\?\\C:\\MyFiles\\code\\sky-scout\\tsconfig.base.json to tar: archive/tar: missed writing 999 bytes"
2024-12-14T20:05:58.664+0100 [DEBUG] provider.terraform-provider-docker_v3.0.2.exe: time="2024-12-14T20:05:58+01:00" level=error msg="Can't close tar writer: archive/tar: missed writing 999 bytes"
2024-12-14T20:05:58.904+0100 [ERROR] provider.terraform-provider-docker_v3.0.2.exe: Response contains error diagnostic: diagnostic_severity=ERROR tf_provider_addr=provider tf_req_id=ff885e42-175b-7292-3c2d-66168c826371 @module=sdk.proto diagnostic_detail="" tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:55
  diagnostic_summary=
  | failed to read dockerfile: unexpected EOF
  |
   tf_proto_version=5.3 tf_resource_type=docker_image timestamp="2024-12-14T20:05:58.904+0100"
2024-12-14T20:05:58.907+0100 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2024-12-14T20:05:58.907+0100 [ERROR] vertex "docker_image.orchestrator" error: failed to read dockerfile: unexpected EOF
2024-12-14T20:05:58.920+0100 [ERROR] provider.terraform-provider-docker_v3.0.2.exe: Response contains error diagnostic: tf_req_id=dee4074f-a8fc-aa0d-6893-8927b60befb2 tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:55 @module=sdk.proto diagnostic_severity=ERROR tf_proto_version=5.3 diagnostic_detail=""
  diagnostic_summary=
  | failed to read dockerfile: unexpected EOF
  |
   tf_provider_addr=provider tf_resource_type=docker_image timestamp="2024-12-14T20:05:58.920+0100"
2024-12-14T20:05:58.923+0100 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2024-12-14T20:05:58.923+0100 [ERROR] vertex "docker_image.worker" error: failed to read dockerfile: unexpected EOF
2024-12-14T20:05:58.932+0100 [ERROR] provider.terraform-provider-docker_v3.0.2.exe: Response contains error diagnostic: tf_proto_version=5.3 tf_rpc=ApplyResourceChange
  diagnostic_summary=
  | failed to read dockerfile: unexpected EOF
  |
   tf_provider_addr=provider @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:55 @module=sdk.proto diagnostic_detail="" diagnostic_severity=ERROR tf_req_id=c2e6be00-6bc2-9706-6b18-1094b4476421 tf_resource_type=docker_image timestamp="2024-12-14T20:05:58.932+0100"
2024-12-14T20:05:58.935+0100 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2024-12-14T20:05:58.935+0100 [ERROR] vertex "docker_image.rabbitmq" error: failed to read dockerfile: unexpected EOF
╷
│ Error: failed to read dockerfile: unexpected EOF
│
│
│
│   with docker_image.rabbitmq,
│   on main.tf line 33, in resource "docker_image" "rabbitmq":
│   33: resource "docker_image" "rabbitmq" {
│
╵
╷
│ Error: failed to read dockerfile: unexpected EOF
│
│
│
│   with docker_image.worker,
│   on main.tf line 48, in resource "docker_image" "worker":
│   48: resource "docker_image" "worker" {
│
╵
╷
│ Error: failed to read dockerfile: unexpected EOF
│
│
│
│   with docker_image.orchestrator,
│   on main.tf line 63, in resource "docker_image" "orchestrator":
│   63: resource "docker_image" "orchestrator" {
│
╵
2024-12-14T20:05:58.941+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-12-14T20:05:58.941+0100 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = error reading from server: EOF"
2024-12-14T20:05:58.942+0100 [INFO]  provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/hashicorp/null/3.2.3/windows_386/terraform-provider-null_v3.2.3_x5.exe id=18092
2024-12-14T20:05:58.942+0100 [DEBUG] provider: plugin exited
2024-12-14T20:05:58.943+0100 [INFO]  provider: plugin process exited: plugin=.terraform/providers/registry.terraform.io/kreuzwerker/docker/3.0.2/windows_386/terraform-provider-docker_v3.0.2.exe id=47340
2024-12-14T20:05:58.943+0100 [DEBUG] provider: plugin exited

Steps to Reproduce

  1. terraform apply

Important Factoids

I'm running this on Windows OS.

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