Skip to content

Commit

Permalink
Docker: add TEMPLATES_DIR argument
Browse files Browse the repository at this point in the history
  • Loading branch information
pierky committed Jul 15, 2024
1 parent 0885c77 commit 50633b1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ docker run \
pierky/arouteserver:latest
```

In case custom templates are used to generate the final configurations, it's possible to pass the `TEMPLATES_DIR` environment variable to the container and set it to a custom path (on the container side) where the local directory containing the customized files is mounted:

```bash
docker run \
...
-e TEMPLATES_DIR="/custom_templates" \
-v /path/to/local/templates/directory:/custom_templates:ro
```

The local directory (*/path/to/local/templates/directory* in the example above) must have the same structure of the official *templates* directory (so, with sub-directories like *bird*, *openbgpd*, *html*, *md*, ...).

### Textual representation

A [textual representation](https://arouteserver.readthedocs.io/en/latest/USAGE.html#textual-representation) of the route server's options and policies will be generated automatically before the route server configuration is generated if the directory `/root/arouteserver_html` exists on the container.
Expand Down
15 changes: 15 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ LOCAL_PREFIXES="${LOCAL_PREFIXES}"
IP_VER="${IP_VER}"
LOCAL_FILES="${LOCAL_FILES}"
LOCAL_FILES_DIR="${LOCAL_FILES_DIR}"
TEMPLATES_DIR="${TEMPLATES_DIR}"
EURO_IX_URL="${EURO_IX_URL}"
EURO_IX_IXP_ID="${EURO_IX_IXP_ID}"

Expand All @@ -42,6 +43,13 @@ if [[ ! -e "${OUTPUT_DIR}" && ! -d "${OUTPUT_DIR}" ]]; then
You can run the container passing the '-v PATH_OF_DIRECTORY_ON_THE_HOST:${OUTPUT_DIR}' argument."
fi

if [[ -n "${TEMPLATES_DIR}" ]]; then
if [[ ! -e "${TEMPLATES_DIR}" ]]; then
error "Couldn't find the directory ${TEMPLATES_DIR} on the container.\n
Please mount the local directory where the templates are stored using '-v PATH_OF_TEMPLATES_DIR_ON_THE_HOST:${TEMPLATES_DIR}:ro' argument."
fi
fi

TEST_WRITABLE_FILE="${OUTPUT_DIR}/.test_dir_is_writable"

set +e
Expand Down Expand Up @@ -193,10 +201,17 @@ if [[ -n "${LOCAL_FILES}" ]]; then
fi
fi

TEMPLATES_DIR_ARG=""

if [[ -n "${TEMPLATES_DIR}" ]]; then
TEMPLATES_DIR_ARG="--templates-dir ${TEMPLATES_DIR}"
fi

OUTPUT_PATH="${OUTPUT_DIR}/${OUTPUT_FILE}"

arouteserver \
"${DAEMON}" \
${TEMPLATES_DIR_ARG} \
--target-version "${VERSION}" \
${IP_VER_ARG} \
--clients "${CLIENTS_FILE_PATH}" \
Expand Down

0 comments on commit 50633b1

Please sign in to comment.