-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from desci-labs/m0ar/ceramic-config-interpola…
…tion Ceramic Dockerfile with config interpolation
- Loading branch information
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"anchor": { }, | ||
"http-api": { | ||
"cors-allowed-origins": [ | ||
".*" | ||
], | ||
"admin-dids": [ | ||
"did:key:z6MktbKJrMnhVJ37QFTo12911ycm2juKDUzWHDVETu9s5a9T" | ||
] | ||
}, | ||
"ipfs": { | ||
"mode": "remote", | ||
"host": "@DOCKER_HOST@" | ||
}, | ||
"logger": { | ||
"log-level": 2 | ||
}, | ||
"metrics": { | ||
"metrics-exporter-enabled": false, | ||
"metrics-port": 9090 | ||
}, | ||
"network": { | ||
"name": "inmemory" | ||
}, | ||
"node": {}, | ||
"state-store": { | ||
"mode": "fs", | ||
"local-directory": "/root/.ceramic/statestore" | ||
}, | ||
"indexing": { | ||
"db": "@POSTGRES_URI@", | ||
"allow-queries-before-historical-sync": true, | ||
"models": [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM ceramicnetwork/js-ceramic:3.2.0 | ||
|
||
COPY interpolateConfigVars.sh . | ||
COPY .ceramicTemplate.config.json . | ||
|
||
ENTRYPOINT [ \ | ||
"bash", "-c", \ | ||
"./interpolateConfigVars.sh .ceramicTemplate.config.json | jq > daemon.config.json && ./packages/cli/bin/ceramic.js daemon --config daemon.config.json" \ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#! /usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# Send output to stderr | ||
echoerr() { | ||
echo "$@" 1>&2; | ||
} | ||
|
||
TEMPLATE_FILE=$1 | ||
if [[ -z "$TEMPLATE_FILE" ]]; then | ||
echoerr "Template file not passed as first argument, exiting." | ||
exit 1 | ||
fi | ||
|
||
# Get all variables needing substitution | ||
TEMPLATE_VARS=$(grep --only-matching "@.*@" "$TEMPLATE_FILE" | tr --delete "@") | ||
|
||
# Check that each template var exists in env | ||
while read -r templateVar; do | ||
if ! printenv "$templateVar" &>/dev/null; then | ||
echoerr "$templateVar is not set in environment, exiting." | ||
exit 1 | ||
fi | ||
done <<<"$TEMPLATE_VARS" | ||
|
||
|
||
# For each line in the template file | ||
while read -r line; do | ||
# If we got a variable in the line... | ||
if var=$(grep --only-matching "@.*@" <<<"$line" | tr --delete "@"); then | ||
# ...replace it with the env variable | ||
sed "s/@$var@/$(printenv "$var")/" <<<"$line" | ||
else | ||
# ...else just re-print the line | ||
echo "$line" | ||
fi | ||
done < "$TEMPLATE_FILE" |