workspace-images icon indicating copy to clipboard operation
workspace-images copied to clipboard

Changes after imagebuild are not reflected in workspace

Open shaal opened this issue 3 years ago • 6 comments

Bug description

Astro project requires pnpm version 7.9.5, its workspace open with version 7.9.

Running https://gitpod.io/#imagebuild/https://github.com/withastro/astro shows the build process is indeed updated pnpm to version 7.9.5, but opening a new workspace afterwards still have pnpm version 7.9

Steps to reproduce

Build image - https://gitpod.io/#imagebuild/https://github.com/withastro/astro Confirm you can see in the build preview that its updating to version 7.9.5 Open a new workspace of that repo Still stuck in version 7.9 :(

Workspace affected

No response

Expected behavior

After a program (pnpm) was updated during the build of custom docker image, we expect that latest version to be available in every new workspace of that repo.

Example repository

https://github.com/withastro/astro

Anything else?

Related Astro issue - https://github.com/withastro/astro/pull/4120

shaal avatar Aug 31 '22 14:08 shaal

Took a quick look, interestingly pnpm --version reports 7.9.5 when I build the docker container inside my workspace. Have to investigate further.

axonasif avatar Aug 31 '22 16:08 axonasif

For whoever is going to look into that, In the meantime I created a workaround for Astro project, by adding an upgrade-pnpm to before task in gitpod.yml. https://github.com/withastro/astro/pull/4571

But that doesn't fix the actual issue reported here.

shaal avatar Aug 31 '22 17:08 shaal

I did several experiments with Gitpod these days (awesome tool BTW!), and also faced with this issue, after seing https://www.gitpod.io/docs/configure/workspaces/workspace-image#using-a-custom-dockerfile :

Caveat: > COPY instructions in a Dockerfile is only evaluated once and then cached. See this to break the cache and trigger a rebuild.

Is there a known workaround to force the rebuild of an image when we use file: .gitpod.Dockerfile and the main changes are files COPYied inside the container?

erikmd avatar Aug 01 '23 17:08 erikmd

Hi @erikmd,

Didn't this work? If not, maybe the following workaround could work:

  • Have the following line in your .gitpod.Dockerfile:
ARG DOCKER_REBUILD=1
  • Now, when you want to ensure a rebuild, just increment the number in ARG DOCKER_REBUILD=

Let me know if it helps 🙏

axonasif avatar Aug 02 '23 15:08 axonasif

Hi @axonasif, thanks a lot for your feedback!

IIRC, the workaround RUN echo 1 worked, while none of your two workarounds worked (https://gitpod.io/#imagebuild/<your-repo-url> and ARG some_string=1), but I'm not 100% sure (e.g. during my earlier tests, I did not understand well the role of the init task vs. the use of a custom Dockerfile, but now it's fine).

Anyway if I need to force an imagebuild anew, I'll test and let you know!

erikmd avatar Aug 02 '23 15:08 erikmd

That's interesting. Basically the goal is to modify .gitpod.Dockerfile in the Git history (i.e. we push the change to our remote repo) so that Gitpod detects that and performs a rebuild, so if using something like RUN echo 1 works, then that's great! 😄

axonasif avatar Aug 02 '23 15:08 axonasif