docker compose up.
Scripts ending with .sh are discovered in two directories:
- Startup hooks (
/etc/floci/init/start.d) — run after the HTTP server is ready and accepting connections on port4566. Hooks can safely make AWS API calls back to Floci. - Shutdown hooks (
/etc/floci/init/stop.d) — run when Floci is shutting down, afterdestroy()is triggered.
.sh files, or the path is not a directory, Floci skips it and continues normally.
Setting up hooks in Docker Compose
Create your hook directories
Create the startup and shutdown directories alongside your
docker-compose.yml:Write your hook scripts
Hook scripts must be executable shell scripts. Name them with a numeric prefix to control execution order:
Mount the directories into the container
Add read-only volume mounts for both hook directories in your Compose service definition:
Execution behavior
Scripts run in lexicographical (alphabetical) order, sequentially — one at a time. To control the execution order, prefix script filenames with numbers:01-, 02-, 03-, and so on.
Floci uses a fail-fast strategy:
- If a script exits with a non-zero status, remaining hooks are not executed.
- If a script exceeds the configured timeout, it is terminated and remaining hooks are not executed.
- A shutdown hook failure is logged but does not prevent shutdown from completing.
Example: startup hook
This hook seeds a known SSM parameter so your tests and local services can rely on it being present:./init/start.d/01-seed-parameter.sh.
Example: shutdown hook
This hook removes the parameter during shutdown, leaving the environment clean for the next run:./init/stop.d/01-cleanup-parameter.sh.
AWS CLI in hooks
The published Floci Docker image does not include the AWS CLI. If your hooks call Build and reference your custom image in docker-compose:
aws, you need to extend the image. The apk package manager is available in the base image.jq, curl, psql), add them to the same RUN layer.
Configuration
| Key | Default | Description |
|---|---|---|
floci.init-hooks.shell-executable | /bin/bash | Shell used to run hook scripts |
floci.init-hooks.timeout-seconds | 30 | Max execution time per script before it is terminated |
floci.init-hooks.shutdown-grace-period-seconds | 2 | Time to wait after destroy() before force-stopping the process |
FLOCI_INIT_HOOKS_* environment variables for the same settings:
application.yml when hooks need more time — for example, when seeding large amounts of test data or provisioning many resources: