You can import two types of remote repositories with Garden:
Remote source: A repository that contains one or more Garden modules and their corresponding
Remote module: The source code for a single Garden module. In this case, the
garden.ymlconfig file is stored in the main project repository while the module code itself is in the remote repository.
The code examples below are from our remote sources example.
You can import remote sources via the
sources directive in the project-level
garden.yml like so:
# examples/remote-sources/garden.ymlkind: Projectname: remote-sourcessources:- name: web-servicesrepositoryUrl: https://github.com/garden-io/garden-example-remote-sources-web-services.git#v0.1.0- name: db-servicesrepositoryUrl: https://github.com/garden-io/garden-example-remote-sources-db-services.git#v0.1.0
Note that the URL must point to a specific branch or tag.
Use this when you want to import Garden modules from another repository. The repository can contain one or more modules along with their
garden.yml config files. For example, this is the file tree for the remote
# From the root of the garden-example-remote-sources-web-services repository$ tree ..├── README.md├── result│ ├── Dockerfile│ ├── garden.yml│ └── ...└── vote├── Dockerfile├── garden.yml└── ...
You can imagine that this file tree gets merged into the parent project.
services:vote:version: v-201abc4d2e...result:version: v-c36f4f09d0...redis:version: v-e5c48b9089...db:version: v-7bca8577d2...
You can import the source code for a single Garden module from another repository via the
repositoryUrl directive in the module-level
garden.yml like so:
# examples/remote-sources/worker/garden.ymlkind: Moduledescription: Java Workertype: containerrepositoryUrl: https://github.com/garden-io/garden-example-remote-module-jworker.git#v0.1.0name: workerservices:- name: worker...
As with remote sources, the URL must point to a specific branch or tag.
Use this when you want to configure the module within your main project but import the source from another repository. In this case, the module in the main project simply looks like this:
# examples/remote-sources$ tree ..├── garden.yml└── worker└── garden.yml
Notice that it only contains the
garden.yml file, all the source code is in the
garden-example-remote-module-jworker repository. If the remote module also contains a
garden.yml file it is ignored.
You can also import sources and modules from your local file system by setting the
repositoryUrl to a local file path:
As usual, the URL must point to a specific branch or tag.
Local paths work just the same remote URLs and you'll still need to link the repository if you want to edit it locally.
In general we don't recommend using local paths except for testing purposes. The
garden.yml files should be checked into your version control system and therefore shouldn't contain anything specific to a particular user's setup.
If you have a local copy of your external source and want to be able to work on it and make changes, you can use the
link module|source command. To link the
web-services source from above, you would run:
garden link source web-services /local/path/to/web-services
Now you can edit the local version of the
web-services repository and it will work just the same as when you edit the main project. For example, if you run Garden in watch mode in the main project and update the local version of
web-services, you'll see Garden pick up the changes and re-build and re-deploy the services from
To unlink a remote source or module, simply run
garden unlink source|module <name-of-source>. For example:
garden unlink source web-services
Garden will only update a remote source if explicitly asked to do so via the
update-remote sources|modules command.
For example, if we had pointed the repository URL of the
web-services source from above to something like a
master branch, and we now wanted to pull the latest code from the remote, we would run:
garden update-remote source web-services
To update all remote sources and modules, you can run:
garden update-remote all
Garden git clones the remote repositories to the
.garden/sources/projects are handled like any other directory in the main project. They're scanned for
garden.yml files and the modules found are synced to the
In the case of remote modules, Garden first finds the module
garden.yml file in the main project and then knows to looks for the source code for that module under
./garden/sources/modules. As for other modules, the code gets synced to the
Linked sources and modules are handled similarly except Garden uses the local path instead of the
./garden/sources paths. Additionally, Garden watches the local paths when in watch mode.
Garden keeps track of the repository URL so that it can remove stale sources from the
.garden/sources directory if the URL changes.