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

Devpod build fails when using Multi-Stage build with a Feature #1433

Open
joshbrooks opened this issue Nov 29, 2024 · 1 comment
Open

Devpod build fails when using Multi-Stage build with a Feature #1433

joshbrooks opened this issue Nov 29, 2024 · 1 comment

Comments

@joshbrooks
Copy link

What happened?

In my dev environment I use a multistage build, like this

FROM mcr.microsoft.com/devcontainers/python:1-3.12-bookworm AS builder
# ...
FROM builder AS final
# ...

I also have in my devcontainer.json a features clause to add node

	"features": {
		"ghcr.io/devcontainers/features/node:1": {
			"installYarnUsingApt": true,
			"version": "lts",
			"nvmVersion": "latest"
		}
	},

When I try to start a workspace (debug on) it fails. this debug log indicates that an incorrect dockerfile is generated:
Note line 3 FROM AS final.


{"type":"data","data":{"time":"2024-11-29T11:14:54.363901867+09:00","message":"Creating extended Dockerfile /var/home/josh/.devpod/agent/contexts/default/workspaces/education-git-rc-2-0/content/.devcontainer/python/.devpod-internal/Dockerfile-with-features with content: 
 # syntax=docker.io/docker/dockerfile:1.4
ARG _DEV_CONTAINERS_BASE_IMAGE=placeholder
FROM  AS final

FROM $_DEV_CONTAINERS_BASE_IMAGE AS dev_containers_target_stage

USER root

COPY ./.devpod-internal/ /tmp/build-features/
RUN chmod -R 0755 /tmp/build-features && ls /tmp/build-features

RUN \\
echo \"_CONTAINER_USER_HOME=$(getent passwd root | cut -d: -f6)\" >> /tmp/build-features/devcontainer-features.builtin.env && \\
echo \"_REMOTE_USER_HOME=$(getent passwd vscode | cut -d: -f6)\" >> /tmp/build-features/devcontainer-features.builtin.env

ENV NVM_DIR=/usr/local/share/nvm
ENV NVM_SYMLINK_CURRENT=true
ENV PATH=/usr/local/share/nvm/current/bin:${PATH}
RUN cd /tmp/build-features/0 \\
&& chmod +x ./devcontainer-features-install.sh \\
&& ./devcontainer-features-install.sh



ARG _DEV_CONTAINERS_IMAGE_USER=root
USER $_DEV_CONTAINERS_IMAGE_USER","level":"debug"}}
{"type":"data","data":{"time":"2024-11-29T11:14:54.365453753+09:00","message":"Creating docker-compose build /var/home/josh/.devpod/agent/contexts/default/workspaces/education-git-rc-2-0/.docker-compose/docker-compose.devcontainer.build-54.yml with content:
 services:
  django:
    build:
      context: /var/home/josh/.devpod/agent/contexts/default/workspaces/education-git-rc-2-0/content/.devcontainer/python
      dockerfile: /var/home/josh/.devpod/agent/contexts/default/workspaces/education-git-rc-2-0/content/.devcontainer/python/.devpod-internal/Dockerfile-with-features
      args:
        _DEV_CONTAINERS_BASE_IMAGE: final
        _DEV_CONTAINERS_IMAGE_USER: root
        BUILDKIT_INLINE_CACHE: \"1\"","level":"debug"}}

What did you expect to happen instead?

Multistage builds work correctly with features. I tested

How can we reproduce the bug? (as minimally and precisely as possible)

  • Create a multistage dockerfile
  • Add a feature to a devcontainer.json referencing that dockerfile

My devcontainer.json:

{
	"name": "Education",
	"dockerComposeFile": ["../compose.yml"],
	"service": "django",
	"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
	"shutdownAction": "none",
	"customizations": {
		"vscode": {
			"extensions": [
				"ms-python.python",
				"ms-python.debugpy",
				"charliermarsh.ruff",
				"Vue.volar",
				"eamodio.gitlens",
				"ms-python.vscode-pylance"
			]
		}
	},
	// Make npm features available in this python dev container
	"features": {
		"ghcr.io/devcontainers/features/node:1": {
			"installYarnUsingApt": true,
		        "version": "lts",
	 		"nvmVersion": "latest"
	 	}
	 }
}

Local Environment:

  • DevPod Version: 0.6.0
  • Operating System: linux
  • ARCH of the OS: AMD64

DevPod Provider:

  • Local/remote provider: docker

Anything else we need to know?

As workarounds, commenting out features or removing the multistage build requirement both work.

@pascalbreuninger
Copy link
Member

pascalbreuninger commented Nov 29, 2024

Hey @joshbrooks, thanks for opening the issue. We'll look into it.
Just to get the complete picture here, could you also provide your compose.yml file please?

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

No branches or pull requests

3 participants