Skip to content

Commit 77b2409

Browse files
authored
feat: Cherry-picking notes on monorepos from Franta (#591)
1 parent 6fea3f2 commit 77b2409

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

sources/platform/actors/development/source_code.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ To help you get started quickly, you can use the [apify/quick-start](https://api
3131

3232
To specify a Git branch or tag to check out, add a URL fragment to the URL. For example, to check out the **develop** branch, specify a URL such as `https://github.com/jancurn/some-actor.git#develop`.
3333

34-
Optionally, the second part of the fragment in the Git URL (separated by a colon) specifies the context directory for the Docker build. For example, `https://github.com/jancurn/some-actor.git#develop:some/dir` will check out the **develop** branch and set **some/dir** as a context directory for the Docker build.
35-
34+
Optionally, the second part of the fragment in the Git URL (separated by a colon) specifies the directory from which the Actor will be built (and where the `.actor`) folder is located. For example, `https://github.com/jancurn/some-actor.git#develop:some/dir` will check out the **develop** branch and set **some/dir** as the root directory of the Actor.
3635
Note that you can easily set up an integration where the actor is automatically rebuilt on every commit to the Git repository. For more details, see [GitHub integration](./source_code.md).
3736

3837
### [](#private-repositories)Private repositories
@@ -41,6 +40,14 @@ If your source code is hosted in a private Git repository then you need to confi
4140

4241
To obtain the key click at the **deployment key** link under the **Git URL** text input and follow the instructions there.
4342

43+
### [](#actor-monorepos)Actor monorepos
44+
45+
By default, the context directory for the Docker build is the directory pointed to by the **Git URL** (or the repository root if no directory is specified). If you want to use a different directory for the Docker context, you can use the `dockerContextDir` property in the [Actor definition](./actor_config.md). This is useful for example for sharing code between multiple actors in the same repository.
46+
47+
If you want to have multiple actors in a single repository that use shared code also located in the repository, you can set `dockerContextDir` to the path to the folder which contains the actor's source and the shared code, and then copy both the actor's source and shared code to the Docker image in the Dockerfile.
48+
49+
An example actor monorepo is shown in the [`apify/actor-monorepo-example`](https://github.com/apify/actor-monorepo-example) repository. To build actors from this monorepo, you would set the source URL to `https://github.com/apify/actor-monorepo-example#main:actor_1` and `https://github.com/apify/actor-monorepo-example#main:actor_2` respectively.
50+
4451
## [](#zip-file)Zip file
4552

4653
The source code for the actor can also be located in a Zip archive hosted on an external URL. This option enables integration with arbitrary source code or continuous integration systems. Similarly, as with the [Git repository](#git-repository), the source code can consist of multiple files and directories, can contain a custom **Dockerfile** and the actor description is taken from **README.md**. If you don't use a [custom Dockerfile](#custom-dockerfile), the root file of your application must be named `main.js`.

0 commit comments

Comments
 (0)