Error when using array of env_file in docker-compose.yml
What happened?
When trying to use multiple env files in docker-compose.yml, DevPod throw an error saying:
[11:40:48] info devcontainer up: load docker compose project: validating /Users/tichael/Projects/test_devcontainer/docker-compose.yml: services.devcontainer.env_file.0 must be a string
[11:40:48] error Try enabling Debug mode under Settings to see a more verbose output
[11:40:48] fatal run agent command: Process exited with status 1
What did you expect to happen instead?
I expected that devpod would have no problem with it since the latest Docker Compose format support this (see official documentation here) and creating a dev container with the same files from VS Code works without issue.
How can we reproduce the bug? (as minimally and precisely as possible)
Create a folder with three files:
.devcontainer.jsondocker-compose.ymldefault.env
File content:
.devcontainer.json:
{
"dockerComposeFile": "docker-compose.yml",
"service": "devcontainer",
"workspaceFolder": "/workspace"
}
docker-compose.yml:
services:
devcontainer:
image: mcr.microsoft.com/devcontainers/base:ubuntu
env_file:
- path: ./default.env
required: true
- path: ./.env
required: false
volumes:
- .:/workspace:cached
default.env:
MY_ENV_VALUE=default
Local Environment:
- DevPod Version: v0.5.16
- Operating System: macOS Sonoma 14.5
- ARCH of the OS: ARM64
DevPod Provider:
Local Docker installation (Docker Desktop v4.31.0, Docker Engine v26.1.4, Docker Compose v2.27.1-desktop.1)
Anything else we need to know?
Like I said earlier, creating the dev container with Visual Studio Code works without any issue. So I don't know what difference DevPod is doing with its Docker Compose implementation.
Hi @Tichael, thanks for opening the issue. We'll take a look but it might take a while as docker-compose based workspaces aren't our focus at the moment
same here.
It seems the cause is used old compose-spec/compose-go package to validate the docker-compose.yaml file.
https://github.com/loft-sh/devpod/blob/main/go.mod#L10
the new env_file spec is supported by compose-go v2.0.0 and later.
https://github.com/compose-spec/compose-go/releases/tag/v2.0.0