Skip to content

Commit bb73ede

Browse files
committed
Describe pre and post scripts
1 parent 487bf6a commit bb73ede

File tree

1 file changed

+43
-7
lines changed

1 file changed

+43
-7
lines changed

docs/reference/docker-support.mdx

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Docker Support
33
description: Building and running Lingua Franca programs using Docker
44
---
55

6-
:::note
6+
:::tip
77
You will need to [install Docker](https://docs.docker.com/get-docker/) in order to use this feature.
88
:::
99

@@ -137,10 +137,45 @@ If you only want to generated code and configuration files but do not want to th
137137
By default, `no-build` is `false` and hence building is enabled.
138138

139139
### Option `post-build-script`
140+
If any actions need to be performed at the end of the build stage (such as any cleanups or additional installation steps), you can put these in a shell script and pass it as an option in the `docker` target property. Example:
141+
142+
```
143+
docker: {
144+
post-build-script: "path/to/post-build.sh"
145+
}
146+
```
147+
148+
:::note
149+
The given path should either be relative to the package root or relative to the `.lf` file in which the target property is given.
150+
:::
140151

141152
### Option `pre-build-script`
153+
If any actions need to be performed at the beginning of the build stage (such as setting environment variables), you can put these in a shell script and pass it as an option in the `docker` target property. Example:
154+
155+
```
156+
docker: {
157+
pre-build-script: "path/to/pre-build.sh"
158+
}
159+
```
160+
161+
:::note
162+
The given path should either be relative to the package root or relative to the `.lf` file in which the target property is given.
163+
:::
164+
165+
### Option `pre-run-script`
166+
If any actions need to be performed (such as setting environment variables) at the beginning of the entrypoint in the run stage, you can put these in a shell script and pass it as an option in the `docker` target property. Example:
167+
168+
169+
```
170+
docker: {
171+
pre-run-script: "path/to/pre-run.sh"
172+
}
173+
```
174+
175+
:::note
176+
The given path should either be relative to the package root or relative to the `.lf` file in which the target property is given.
177+
:::
142178

143-
### Option `post-run-script`
144179

145180
### Option `runner-base`
146181
To pick a base image for the run stage in the generated `Dockerfile`, use the `runner-base` option:
@@ -153,7 +188,11 @@ To pick a base image for the run stage in the generated `Dockerfile`, use the `r
153188

154189
Note that this will _not_ affect the build stage. To change the base image of the build stage, use the [`builder-base` option](#option-builder-base).
155190

156-
By default, `runner-base` is "`alpine:latest`".
191+
By default, `runner-base` is `"alpine:latest"`. However, if `builder-base` is defined, then `runner-base` defaults to the value that was assigned to `builder-base`.
192+
193+
:::tip
194+
You can also use the builder stage as the base for the running stage (and inherit all the installed dependencies and created build artifacts). To do this, simply use `runner-base: "builder"`.
195+
:::
157196

158197
### Option `rti-image`
159198
To run a federated program, an RTI process must run to support it. By default, an image for the RTI is pulled from DockerHub. An alternative image can be specified using the `rti-image` entry.
@@ -166,10 +205,7 @@ The value of the `builder-base`, `runner-base`, and `rti-image` entry should fol
166205

167206
## Manually building and running
168207
The generated executable simply invokes `docker compose up --abort-on-container-failure`, but this might not be what you want. Here are some guidelines for building and running manually.
169-
170-
:::note
171-
If you instead want to build manually after code generation has completed, you can instruct to Lingua Franca compiler to skip building using the `no-build` option in the `docker` target property. More information can be found [here](#option-no-build)
172-
:::
208+
If you instead want to build manually after code generation has completed, you can instruct to Lingua Franca compiler to skip building using the `no-build` option in the `docker` target property. More information can be found [here](#option-no-build).
173209

174210
### Using `docker build` and `docker run`
175211
You can build images and run containers in separate steps. First, change directory to [the location of the `Dockerfile`](#where-to-find-the-docker-configuration-files).

0 commit comments

Comments
 (0)