devcontainers / cli

A reference implementation for the specification that can create and configure a dev container from a devcontainer.json.
https://containers.dev
MIT License
1.62k stars 227 forks source link

Applying a template affects the checksum of contained image files #599

Open TorbenWetter opened 1 year ago

TorbenWetter commented 1 year ago

I want to express my sincere appreciation for making Dev Containers a reality; I've been a huge fan since its launch! Over the past few months, I've put together my own template, which can be found here: https://github.com/TorbenWetter/iu-latex-container-templates

The Problem

Up until now, everything has been running smoothly. Files with extensions like .tex or .bib have been effortlessly incorporated into my Dev Container. However, today I attempted to add image files to my thesis template, including .jpg and .png files. While loading the template in VS Code using Add Dev Container Configuration Files... from the Dev Containers extension, I observed that the hash/checksum of the image files differed from those in my template's GitHub repository. Regrettably, this discrepancy rendered them incompatible with my LaTeX environment. Although I wasn't able to delve into this issue further, I concentrated on examining the behaviour of the Dev Containers CLI.

Reproduction Process

In an attempt to discern what was occurring with the images, I cloned my repository, applied the template via the Dev Containers CLI, and then compared the checksums of the images:

$ cd /tmp

$ git clone --depth 1 --branch template_thesis_1.0.5 git@github.com:TorbenWetter/iu-latex-container-templates.git

$ mkdir thesis
$ devcontainer templates apply -w thesis -t ghcr.io/torbenwetter/iu-latex-container-templates/thesis:1.0.5

$ shasum iu-latex-container-templates/src/thesis/main.tex thesis/main.tex
cb9d6954c4fafcc143900163dc0006d9b650efc1  iu-latex-container-templates/src/thesis/main.tex
cb9d6954c4fafcc143900163dc0006d9b650efc1  thesis/main.tex

$ shasum iu-latex-container-templates/src/thesis/images/logo.png thesis/images/logo.png
09a00de3136176c036ab9c79583c5b796e9a7085  iu-latex-container-templates/src/thesis/images/logo.png
075e1ec15b02c54b843abf26db272a4f110c1a9e  thesis/images/logo.png

I'm more than willing to further investigate this issue, but so far, my independent attempts to pinpoint the problem with the CLI by scrutinizing the code have been fruitless.

samruddhikhandale commented 1 year ago

Hi 👋

Thanks for opening the issue and for your kind words ✨ @TorbenWetter what's the version of your @devcontainers/cli package? You can find it with devcontainer --version command.

@chrmarti Could this be related to the lockfile changes? or any other recent changes? 🤔

TorbenWetter commented 1 year ago

Hey @samruddhikhandale!

I'm using the most recent version of the CLI:

$ devcontainer --version
0.50.0

Here's the version of VS Code I'm currently using:

What I couldn't confirm is whether the image files (.jpg/.png) undergo modifications during the build process itself, or when the template is applied by either VS Code or the CLI.

TorbenWetter commented 1 year ago

Oh, and not to forget:

Dev Containers VS Code extension version v0.299.0.

chrmarti commented 1 year ago

Found that we convert all files to text and back which does not preserve binary content and created a PR from my investigation.