-
Notifications
You must be signed in to change notification settings - Fork 273
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
Allow specifying a different docker build context #853
Comments
Hey @diasjorge! That's good feedback. We've done some work to make placement of code+configs more flexible, but we do currently assume source files for a module to be within the directory where the config is. The reason we do that is that we "stage" builds by copying source files into a temporary directory, and allowing arbitrary locations makes that quite a bit more complex to do. We have wanted to add a That said, there might be a good solution for this already. Only issue would be that you wouldn't structure the configs the same way you had in mind, but rather put multiple configs into a single So your combined kind: Project
name: my-project
...
---
kind: Module
type: container
name: module1
...
---
kind: Module
type: container
name: module2
include: ["other-module-sources/**/*"]
dockerfile: other.Dockerfile
... How exactly is your current code structured? There might be other approaches needed if I'm guessing your structure wrong. |
hi @edvald thanks for such a quick reply. I'll try your proposal and report back. |
We add a `path` rule, with options to disallow absolute paths or parent paths, i.e. stepping up a directory tree, in order to ensure that some paths are sub-paths of a project or module. This required a refactor where we use a custom Joi instance across our codebase, hence the size of the change. This is done both for general hardening, and in preparation of #853 and other similar configuration options.
We add a `path` rule, with options to disallow absolute paths or parent paths, i.e. stepping up a directory tree, in order to ensure that some paths are sub-paths of a project or module. This required a refactor where we use a custom Joi instance across our codebase, hence the size of the change. This is done both for general hardening, and in preparation of #853 and other similar configuration options.
We add a `path` rule, with options to disallow absolute paths or parent paths, i.e. stepping up a directory tree, in order to ensure that some paths are sub-paths of a project or module. This required a refactor where we use a custom Joi instance across our codebase, hence the size of the change. This is done both for general hardening, and in preparation of #853 and other similar configuration options.
We add a `path` rule, with options to disallow absolute paths or parent paths, i.e. stepping up a directory tree, in order to ensure that some paths are sub-paths of a project or module. This required a refactor where we use a custom Joi instance across our codebase, hence the size of the change. This is done both for general hardening, and in preparation of #853 and other similar configuration options.
We add a `path` rule, with options to disallow absolute paths or parent paths, i.e. stepping up a directory tree, in order to ensure that some paths are sub-paths of a project or module. This required a refactor where we use a custom Joi instance across our codebase, hence the size of the change. This is done both for general hardening, and in preparation of #853 and other similar configuration options.
We add a `path` rule, with options to disallow absolute paths or parent paths, i.e. stepping up a directory tree, in order to ensure that some paths are sub-paths of a project or module. This required a refactor where we use a custom Joi instance across our codebase, hence the size of the change. This is done both for general hardening, and in preparation of #853 and other similar configuration options.
@edvald I tried your approach and I was able to build the project that way. I see you're working on this issue so looking forward to the upcoming changes to facilitate this :) |
Closing since it's possible to workaround this by "hoisting" the module configuration to a common parent directory and using the |
I'd love to re-open this issue if possible - I am working on a project whose repo has several I want to use Example structure:
|
For this case, the advised approach is to place the
Would that cover your case? |
Sorry, I skipped a layer. The
I understand that this is probably pushing the bounds of the scenario |
Aaah I see. That makes sense then. Sure, we can reopen. Meanwhile, you might be able to use remote module sources for this scenario, which may be a good approach if the external code is not something you're editing much: https://docs.garden.io/guides/using-remote-sources#remote-modules |
I run into this same issue. Specifically, the "correct" way of building dotnetcore projects in containers must have the context of the whole repo to deal with project dependencies. Defining all of the modules in the garden project file seems very messy |
Here is an example dockerfile, scrubbed of personal information, that is the standard template for dotnetcore projects in a visual studio solution:
|
This issue has been automatically marked as stale because it hasn't had any activity in 60 days. It will be closed in 14 days if no further activity occurs (e.g. changing labels, comments, commits, etc.). Please feel free to tag a maintainer and ask them to remove the label if you think it doesn't apply. Thank you for submitting this issue and helping make Garden a better product! |
This issue has been automatically marked as stale because it hasn't had any activity in 60 days. It will be closed in 14 days if no further activity occurs (e.g. changing labels, comments, commits, etc.). Please feel free to tag a maintainer and ask them to remove the label if you think it doesn't apply. Thank you for submitting this issue and helping make Garden a better product! |
I also would like the ability to specify the build context. I have a project that looks like this:
Where kind: Module
type: container
name: service-image
include: [services/myservice/**/*]
dockerfile: services/myservice/Dockerfile But the resulting build context is not at I.e. garden is building the image like this: But I want it to build like this: I don't want to put a Is there a workaround for this? |
The original issue has already been resolved in Bonsai (garden 0.13). Feel free to reopen if it's still an issue in Bonsai. |
Bug
Current Behavior
The Dockerfiles must be at the root of the project
Expected behavior
A user is able to specify a context pointing to another directory like with docker-compose
I can't change our project layout to have different structure like in your examples.
I'd like to be able to specify all garden configuration in a subdirectory like:
garden/garden.yml
garden/module1/garden.yml
garden/module2/garden.yml
And have module1 and module2 build from a parent directory.
Currently with docker-compose we specify the context like: ../../
Your environment
garden version
0.9.12
kubectl version
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.3", GitCommit:"5e53fd6bc17c0dec8434817e69b04a25d8ae0ff0", GitTreeState:"clean", BuildDate:"2019-06-07T09:55:27Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"12+", GitVersion:"v1.12.7-gke.10", GitCommit:"8d9b8641e72cf7c96efa61421e87f96387242ba1", GitTreeState:"clean", BuildDate:"2019-04-12T22:59:24Z", GoVersion:"go1.10.8b4", Compiler:"gc", Platform:"linux/amd64"}
docker version
Client: Docker Engine - Community
Version: 18.09.2
API version: 1.39
Go version: go1.10.8
Git commit: 6247962
Built: Sun Feb 10 04:12:39 2019
OS/Arch: darwin/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.2
API version: 1.39 (minimum version 1.12)
Go version: go1.10.6
Git commit: 6247962
Built: Sun Feb 10 04:13:06 2019
OS/Arch: linux/amd64
Experimental: false
The text was updated successfully, but these errors were encountered: