Last active
April 21, 2020 01:17
-
-
Save jordanrounds/a2b16fd5753ee7a450b2b5486b8eebaf to your computer and use it in GitHub Desktop.
example secrets from file
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
test |
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
version: "3.7" | |
services: | |
influx: | |
build: . | |
container_name: "influxdb" | |
image: influxdb:secrets | |
restart: unless-stopped | |
environment: | |
INFLUXDB_ADMIN_PASSWORD_FILE: /run/secrets/test | |
secrets: | |
- test | |
ports: | |
- '8086:8086' | |
- '2003:2003' | |
volumes: | |
- ./influxdb.conf:/etc/influxdb/influxdb.conf:ro | |
- influx-storage:/var/lib/influxdb | |
volumes: | |
influx-storage: | |
name: influxdb_storage | |
driver: local-persist | |
driver_opts: | |
mountpoint: ${LOCAL_PERSIST}/influxdb/storage | |
secrets: | |
test: | |
file: ./.password |
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
FROM influxdb:latest | |
COPY pre-entrypoint.sh /usr/local/bin/ | |
ENTRYPOINT ["pre-entrypoint.sh"] | |
CMD ["influxd"] |
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
#!/bin/bash | |
set -e | |
error() { | |
printf '%s [%s] [Entrypoint]: %s\n' "$(date --rfc-3339=seconds)" "ERROR" "$*" | |
} | |
file_env() { | |
local var="$1" | |
local fileVar="${var}_FILE" | |
local def="${2:-}" | |
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then | |
error "Both $var and $fileVar are set (but are exclusive)" | |
fi | |
local val="$def" | |
if [ "${!var:-}" ]; then | |
val="${!var}" | |
elif [ "${!fileVar:-}" ]; then | |
val="$(< "${!fileVar}")" | |
fi | |
export "$var"="$val" | |
printf "$var : $val" | |
unset "$fileVar" | |
} | |
file_env 'INFLUXDB_ADMIN_PASSWORD' | |
file_env 'INFLUXDB_USER_PASSWORD' | |
file_env 'INFLUXDB_READ_USER_PASSWORD' | |
file_env 'INFLUXDB_WRITE_USER_PASSWORD' | |
. /entrypoint.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment