Unify NAS operations on tracked docker-compose.yaml

This commit is contained in:
2026-10-14 11:08:42 +09:00
parent 46ad429cc7
commit ff89daac8c
10 changed files with 118 additions and 104 deletions

View File

@@ -5,12 +5,10 @@ cd "$(dirname "$0")/.."
umask 077
hop_env_tmp=''
hop_yaml_tmp=''
hop_echo_hidden=false
cleanup() {
if [ "$hop_echo_hidden" = true ]; then stty echo; fi
if [ -n "$hop_env_tmp" ]; then rm -f "$hop_env_tmp"; fi
if [ -n "$hop_yaml_tmp" ]; then rm -f "$hop_yaml_tmp"; fi
}
trap cleanup 0
trap 'exit 130' INT
@@ -114,14 +112,10 @@ if ! grep -Eq '^PROXY_DIAGNOSTIC_TOKEN=.{32,}$' .env; then
unset hop_diagnostic_token
fi
sh scripts/prepare-nas-storage.sh
hop_yaml_tmp=$(mktemp .compose.nas.XXXXXX)
docker compose --project-name hop --project-directory "$PWD" --env-file .env -f compose.yaml config --no-env-resolution > "$hop_yaml_tmp"
mv "$hop_yaml_tmp" compose.nas.yaml
hop_yaml_tmp=''
chmod 600 compose.nas.yaml
# sudo writes configuration as root; return it to the SSH user for Git/Docker app access.
docker compose -f docker-compose.yaml config --no-env-resolution --quiet
# sudo writes .env as root; return it to the SSH user. Never rewrite the tracked Compose file.
if [ "$(id -u)" = 0 ]; then
chown "$hop_run_uid:$hop_run_gid" .env compose.nas.yaml
chown "$hop_run_uid:$hop_run_gid" .env
fi
printf '\n%s\n' '완료. Docker 앱에서 프로젝트 이름 hop으로 아래 YAML을 불러오세요.'
printf '%s/compose.nas.yaml\n' "$PWD"
printf '\n%s\n' '완료. Git에서 관리하는 아래 파일을 Docker 앱과 터미널에서 함께 사용하세요.'
printf '%s/docker-compose.yaml\n' "$PWD"