Compare commits

...

3 Commits

3 changed files with 23 additions and 22 deletions

1
abra.sh Normal file
View File

@ -0,0 +1 @@
export CROC_ENTRYPOINT_VERSION=v1

View File

@ -2,15 +2,24 @@ version: '3.8'
services:
app:
image: schollz/croc
image: schollz/croc:master
ports:
- 9009-9013:9009-9013
environment:
- CROC_PASS_FILE=/run/secrets/croc_pass
secrets:
- croc_pass
configs:
- source: croc_entrypoint
target: /croc-entrypoint.sh
mode: 0555
secrets:
croc_pass:
name: ${STACK_NAME}_croc_pass_${SECRET_CROC_PASS_VERSION}
external: true
configs:
croc_entrypoint:
name: ${STACK_NAME}_croc_entrypoint_${CROC_ENTRYPOINT_VERSION}
file: entrypoint.sh

View File

@ -1,24 +1,15 @@
#!/usr/bin/env bash
#!/bin/ash
set -e
file_env() {
local var="$1"
local fileVar="${var}_FILE"
local def="${2:-}"
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
if test -f "/run/secrets/croc_pass"; then
pwd=`cat /run/secrets/croc_pass`
if [ -z $pwd ]; then
echo >&2 "error: /run/secrets/croc_pass is empty"
exit 1
fi
local val="$def"
if [ "${!var:-}" ]; then
val="${!var}"
elif [ "${!fileVar:-}" ]; then
val="$(< "${!fileVar}")"
fi
export "$var"="$val"
unset "$fileVar"
}
export "CROC_PASS"="$pwd"
unset "pwd"
else
echo >&2 "error: /run/secrets/croc_pass does not exist"
exit 1
fi
file_env "CROC_PASS"