diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..3ab95cb --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +/build.sh text eol=lf diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..b1a3481 --- /dev/null +++ b/build.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -euo pipefail + +cd -- "$(dirname -- "${BASH_SOURCE[0]}")" + +if [[ $EUID -ne 0 ]]; then + echo 'Run this deployment build as root: sudo ./build.sh' >&2 + exit 1 +fi + +# Check the service account before replacing dist. +sunrise_group=$(id -gn sunrise) +npm run build +install -d -o sunrise -g "$sunrise_group" -m 755 dist/threads-captures + +echo 'Build complete; dist/threads-captures is writable by sunrise.' diff --git a/docs/threads-automation.md b/docs/threads-automation.md index 2acfdcd..2bbee03 100644 --- a/docs/threads-automation.md +++ b/docs/threads-automation.md @@ -41,7 +41,7 @@ root에서 실행합니다. 캡처 저장 위치는 기존 dist/threads-captures cd /opt/sunrise git pull --ff-only npm ci -npm run build +./build.sh install -d -o sunrise -g "$(id -gn sunrise)" -m 755 dist/threads-captures install -d -o sunrise -g "$(id -gn sunrise)" -m 700 data/threads chown -R sunrise:"$(id -gn sunrise)" data/threads dist/threads-captures @@ -88,7 +88,7 @@ sudo -iu sunrise sh -lc 'cd /opt/sunrise && npm run threads:post-now' 별도 브라우저 경로를 사용하면 테스트 터미널에도 동일한 환경변수를 적용하세요. post-now는 실행할 때마다 새 테스트 게시물을 만듭니다. preview 이미지는 확인용으로 보존합니다. -이후 배포는 git pull, 필요 시 npm ci, npm run build, 웹 서버 재시작, `systemctl restart sunrise-threads.service` 순서입니다. 설정/문구는 다시 복사하지 않습니다. root로 빌드한 뒤에는 아래 명령으로 캡처 폴더를 다시 만들고 권한을 맞추세요. +이후 배포는 git pull, 필요 시 npm ci, ./build.sh, 웹 서버 재시작, `systemctl restart sunrise-threads.service` 순서입니다. 설정/문구는 다시 복사하지 않습니다. root에서 ./build.sh를 실행하면 빌드 후 캡처 폴더 생성과 권한 설정까지 처리합니다. npm run build를 직접 실행했다면 아래 명령이 필요합니다. ```bash install -d -o sunrise -g "$(id -gn sunrise)" -m 755 /opt/sunrise/dist/threads-captures