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

when using dockerComposeFile prebuilds are ignored #867

Open
sarj21 opened this issue Aug 1, 2024 · 1 comment
Open

when using dockerComposeFile prebuilds are ignored #867

sarj21 opened this issue Aug 1, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@sarj21
Copy link

sarj21 commented Aug 1, 2024

We have the following devcontainers.json file at .devcontainers/flask/devcontainers.json:

{
	"name": "flask",
	"dockerComposeFile": [
		"../../docker-compose.app.yaml",
		"../docker-compose.app.dev.yaml"
	],
	"service": "flask",
	"workspaceFolder": "/home/jan",
	"features": {},
	"customizations": {
		"vscode": {
			"settings": {
				...
			},
			"extensions": [
				...
			]
		}
	}
}

Running devcontainer up --workspace-folder . --config .devcontainer/flask/devcontainer.json works fine, it builds the image and stands up the docker compose service.

I want to utilize prebuilding with our docker compose stack so I take the resulting built images and push them to our repository. If anyone pulls those images and runs devcontainer up --workspace-folder . --config .devcontainer/flask/devcontainer.json it rebuilds the entire image from scratch

If in the devcontainers.json I use the image field then it doesn't rebuild but there's no good way to use something like VS Code's > Reopen in Container since it doesn't know it part of the docker compose stack.

Does devcontainers support using prebuilt images with docker compose files? Is there somethings special I need to do to get it to recognize the image is fully built or to point directly at the cache?

To me it seems like it seems to be running docker compose build instead of docker compose up when running devcontainers up. If I run docker compose up myself and then attach VS Code it seems to work as intended.

@chrmarti
Copy link
Contributor

chrmarti commented Sep 3, 2024

I recommend building the image with a separate configuration (this can be just a Dockerfile or a devcontainer.json) and then reference the resulting image in the docker-compose.yml without referencing a Dockerfile. This avoids relying on Docker's cache hits across machines and potentially architectures.

@chrmarti chrmarti self-assigned this Sep 3, 2024
@chrmarti chrmarti added the under-discussion Issue is under discussion for relevance, priority, approach label Sep 3, 2024
@chrmarti chrmarti added bug Something isn't working and removed under-discussion Issue is under discussion for relevance, priority, approach labels Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants