feat: add platform frontend deployment

This commit is contained in:
wlx committed 2026-08-07 13:06:10 +08:00
1 parent 7eb0e5186d
commit bd3d409836
12 files changed
+219 -6

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -Eeuo pipefail
env_file="${1:-compose/.env}"
source_directory="${2:-/srv/ai-soulmate/sources/ai-soulmate-server}"
for required_command in docker git sed; do
if ! command -v "$required_command" >/dev/null 2>&1; then
printf 'Required command is unavailable: %s\n' "$required_command" >&2
exit 1
fi
done
if [[ ! -r "$env_file" ]]; then
printf 'Environment file not found: %s\n' "$env_file" >&2
exit 1
fi
if [[ ! -r "$source_directory/frontend-vue/Dockerfile" ]]; then
printf 'Frontend Dockerfile not found under: %s\n' "$source_directory" >&2
exit 1
fi
source_branch="$(git -C "$source_directory" branch --show-current)"
source_commit="$(git -C "$source_directory" rev-parse HEAD)"
source_short_commit="${source_commit:0:12}"
image="$(sed -n 's/^FRONTEND_IMAGE=//p' "$env_file" | head -n 1)"
if [[ "$source_branch" != "local-deployment" ]]; then
printf 'Expected source branch local-deployment, found: %s\n' "$source_branch" >&2
exit 1
fi
if [[ -n "$(git -C "$source_directory" status --short --untracked-files=no)" ]]; then
printf 'Tracked source changes are present; refusing to build an uncommitted image.\n' >&2
exit 1
fi
if [[ "$image" != "ai-soulmate-frontend:${source_short_commit}" ]]; then
printf 'FRONTEND_IMAGE does not match source commit; rerun configure-backend-env.sh.\n' >&2
exit 1
fi
docker build \
--label "org.opencontainers.image.revision=${source_commit}" \
--tag "$image" \
"$source_directory/frontend-vue"
docker image inspect "$image" \
--format 'Frontend image built: {{index .RepoTags 0}} id={{.Id}} size={{.Size}}'