Skip to content

coder templates create using the template docker-image-builds and derivatives fails to build #2815

Closed

Description

@wale

Problem

The images folder is seemingly not pushed to the host when running coder templates create on Windows clients. The second validation rule in the below template snippet seemingly always fails regardless of the availability of the relevant images folder:

variable "docker_image" {
  description = "What Docker image would you like to use for your workspace?"
  default     = "alpine"

  # List of images available for the user to choose from.
  # Delete this condition to give users free text input.
  validation {
    condition = contains([
      "alpine",
      "ubuntu"
    ], var.docker_image)
    error_message = "Invalid Docker image!"
  }

  # Prevents admin errors when the image is not found
  validation {
    condition     = fileexists("images/${var.docker_image}.Dockerfile")
    error_message = "Invalid Docker image. The file does not exist in the images directory."
  }
}

Logs:
Logs
Directory tree:
Tree

This is also reproducible with the default docker-image-builds template without any changes.

Coder version (on both host and client): Coder v0.7.6+a494489

Activity

  1. changed the title [-]`coder templates create` using the template `docker-image-builds` fails to build[/-] [+]`coder templates create` using the template `docker-image-builds` and derivatives fails to build[/+] on Jul 4, 2022
  2. wale commented on Jul 6, 2022

    @wale
    Author

    Apparently this is a bug that doesn't import Dockerfiles in a given directory, but importing them from the template root works fine?

  3. phorcys420 commented on Jul 20, 2022

    @phorcys420
    Member

    Apparently this is a bug that doesn't import Dockerfiles in a given directory, but importing them from the template root works fine?

    Can confirm, the same error is occuring in a template of mine.
    Maybe this issue should be re-named to something more generic ? Also, the weird part is that it doesn't seem to come from the docker provider itself, since even fileexists fails.

  4. bpmct commented on Jul 25, 2022

    @bpmct
    Member

    @wale @phorcys420 Are you on Windows clients? I was only able to reproduce this when trying the docker-image-builds using coder on Windows. This appears to be a Coder bug as it's not recursively uploading the folder and subfolders to Coder.t

    I also confirmed moving the images/ to root on WIndows fixed it.

  5. phorcys420 commented on Jul 25, 2022

    @phorcys420
    Member

    Are you on Windows clients?

    Yeah.

    This appears to be a Coder bug as it's not recursively uploading the folder and subfolders to Coder

    Maybe, but doing coder templates pull still contains my subfolders.

  6. bpmct commented on Jul 25, 2022

    @bpmct
    Member

    @phorcys420 You're able to make it through coder templates create and pull the template? Mine is failing at the create step because of the validation rule.

  7. phorcys420 commented on Jul 25, 2022

    @phorcys420
    Member

    @phorcys420 You're able to make it through coder templates create and pull the template? Mine is failing at the create step because of the validation rule.

    No, I had to remove that one, and it still didn't work afterwards. I'm just pointing out that it does upload them because I can pull the subfolders afterwards.

  8. phorcys420 commented on Aug 1, 2022

    @phorcys420
    Member

    image
    Stumbled across this today while pulling my template (v0.8.2+00c5116), maybe this has something to do with this issue?

  9. misskniss commented on Aug 9, 2022

    @misskniss
  10. phorcys420 commented on Oct 2, 2022

    @phorcys420
    Member

    any news ?

  11. matifali commented on Oct 8, 2022

    @matifali
    Contributor

    I also faced this when trying to ADD files in my Dockerfile. Somehow docker provider doesn't see other files in the images subdirectory

  12. added
    s0Major regression, all-hands-on-deck to fix
    on Oct 10, 2022
  13. 15 remaining items

  14. matifali commented on Oct 14, 2022

    @matifali
    Contributor

    What about Dockerfile unable to use any ADD commands because it can not see the external files?

  15. mafredri commented on Oct 14, 2022

    @mafredri
    Member

    @matifali that should also be fixed by this since the files will now be in the correct folder.

  16. matifali commented on Oct 14, 2022

    @matifali
    Contributor

    @matifali that should also be fixed by this since the files will now be in the correct folder.

    but I faced that on Linux client. so a path fix. I will test again after you merge.

  17. mafredri commented on Oct 14, 2022

    @mafredri
    Member

    @matifali if the archive was created on Windows, then it would affect a Linux client as well. But if the flow was Linux -> Linux then this change would have no effect. If that's still a problem for you we should perhaps move it to a new separate issue?

  18. bpmct commented on Oct 14, 2022

    @bpmct
    Member

    I originally thought this was a Windows-only issue but I may have missed something!

  19. mafredri commented on Oct 14, 2022

    @mafredri
    Member

    @bpmct I would agree with that assessment. However, it can affect other OS-es via Windows systems.

    So let's say you have the following structure:

    data/bootstrap.sh
    Dockerfile
    main.tf
    

    Relevant directive in Dockerfile would be ADD data/bootstrap.sh.

    Iff this template is uploaded by Windows, then it would succeed (assuming main.tf doesn't do any special checks) but the tar file will not contain data/bootstrap.sh, instead it will be named data\\bootstrap.sh (single file, no folder).

    Now when a Linux client tries to create the workspace and triggers the Docker build, it can't find the file.

    ^ This is the only way I see this issue affecting other operating systems.

  20. jsjoeio commented on Oct 14, 2022

    @jsjoeio
    Contributor

    Nice find @mafredri 🙌🏼

    Once it's merged and a new release is cut, I'll re-test and verify the fix.

  21. added a commit that references this issue on Oct 14, 2022
    19d7281
  22. phorcys420 commented on Oct 17, 2022

    @phorcys420
    Member

    I can confirm this is a Windows-only issue, just tried this on a Linux host and it worked just fine.
    I will confirm whether it works or not on windows with the next release.

  23. jsjoeio commented on Oct 17, 2022

    @jsjoeio
    Contributor
  24. phorcys420 commented on Oct 18, 2022

    @phorcys420
    Member

    Work for me on Windows with v0.10.1 !

  25. jsjoeio commented on Oct 18, 2022

    @jsjoeio
    Contributor

    Woohoo! Thanks for confirming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

s0Major regression, all-hands-on-deck to fix

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions