Refactor entrypoint script to use Python and streamline environment variable handling
All checks were successful
Publish Twitch Archive Container / publish (push) Successful in 1m24s
All checks were successful
Publish Twitch Archive Container / publish (push) Successful in 1m24s
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
parent
4083fb4d78
commit
708464bd86
2 changed files with 33 additions and 29 deletions
|
|
@ -27,8 +27,12 @@ services:
|
||||||
- ${TWITCH_ARCHIVE_CONFIG_BIND:-./config}:/app/config
|
- ${TWITCH_ARCHIVE_CONFIG_BIND:-./config}:/app/config
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test:
|
test:
|
||||||
- CMD-SHELL
|
- CMD
|
||||||
- python twitch-archive.py --healthcheck -u ${TWITCH_ARCHIVE_HEALTHCHECK_STREAMER:-vinesauce}
|
- python
|
||||||
|
- twitch-archive.py
|
||||||
|
- --healthcheck
|
||||||
|
- -u
|
||||||
|
- ${TWITCH_ARCHIVE_HEALTHCHECK_STREAMER:-vinesauce}
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 3
|
retries: 3
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,27 @@
|
||||||
#!/bin/sh
|
#!/usr/bin/env python3
|
||||||
set -eu
|
import os
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
mkdir -p /app/archive /app/config /app/bin/temp
|
|
||||||
|
|
||||||
if [ -z "${CLIENT_ID:-}" ]; then
|
for path in ('/app/archive', '/app/config', '/app/bin/temp'):
|
||||||
client_id_from_hyphenated="$(printenv 'CLIENT-ID' 2>/dev/null || true)"
|
Path(path).mkdir(parents=True, exist_ok=True)
|
||||||
if [ -n "$client_id_from_hyphenated" ]; then
|
|
||||||
export CLIENT_ID="$client_id_from_hyphenated"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "${CLIENT_SECRET:-}" ]; then
|
|
||||||
client_secret_from_hyphenated="$(printenv 'CLIENT-SECRET' 2>/dev/null || true)"
|
|
||||||
if [ -n "$client_secret_from_hyphenated" ]; then
|
|
||||||
export CLIENT_SECRET="$client_secret_from_hyphenated"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "${OAUTH_PRIVATE_TOKEN:-}" ]; then
|
env_aliases = {
|
||||||
oauth_token_from_hyphenated="$(printenv 'OAUTH-PRIVATE-TOKEN' 2>/dev/null || true)"
|
'CLIENT-ID': 'CLIENT_ID',
|
||||||
if [ -n "$oauth_token_from_hyphenated" ]; then
|
'CLIENT-SECRET': 'CLIENT_SECRET',
|
||||||
export OAUTH_PRIVATE_TOKEN="$oauth_token_from_hyphenated"
|
'OAUTH-PRIVATE-TOKEN': 'OAUTH_PRIVATE_TOKEN',
|
||||||
fi
|
}
|
||||||
fi
|
|
||||||
|
|
||||||
exec "$@"
|
for source_name, target_name in env_aliases.items():
|
||||||
|
source_value = os.environ.get(source_name)
|
||||||
|
if source_value and not os.environ.get(target_name):
|
||||||
|
os.environ[target_name] = source_value
|
||||||
|
|
||||||
|
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
raise SystemExit('twitch-archive-entrypoint requires a command to run')
|
||||||
|
|
||||||
|
|
||||||
|
os.execvpe(sys.argv[1], sys.argv[1:], os.environ)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue