Files
core/deploy.sh
Mikhail Chusavitin 0e72a1d284 Add production deployment: Dockerfile, docker-compose, deploy script
- Dockerfile: multi-stage build (golang:1.25-alpine → alpine:3.21), linux/amd64
- infra/mariadb: docker-compose + init SQL for reanimator DB/user
- infra/reanimator: docker-compose for reanimator-api (Gitea registry)
- deploy.sh: local build → push to git.mchus.pro → SSH deploy

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 14:00:54 +03:00

56 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
IMAGE="git.mchus.pro/reanimator/core"
TAG="${1:-latest}"
DEPLOY_DIR="/appdata/reanimator"
echo "Deploy target:"
echo " 1) local"
echo " 2) remote (SSH)"
read -rp "Choice [1/2]: " choice
case "$choice" in
1)
TARGET="local"
;;
2)
read -rp "SSH target (login@hostname): " SSH_TARGET
TARGET="ssh"
;;
*)
echo "Invalid choice" >&2
exit 1
;;
esac
echo "==> Building and pushing $IMAGE:$TAG (linux/amd64)..."
docker buildx build --platform linux/amd64 -t "$IMAGE:$TAG" --push .
if [ "$TARGET" = "local" ]; then
echo "==> Deploying locally..."
docker pull "$IMAGE:$TAG"
cd "$DEPLOY_DIR"
docker compose pull
docker compose up -d --remove-orphans
echo "-- Status:"
docker compose ps
echo "==> Done."
else
echo "==> Deploying on $SSH_TARGET..."
ssh "$SSH_TARGET" "
set -euo pipefail
echo '-- Pulling image...'
docker pull $IMAGE:$TAG
echo '-- Restarting container...'
cd $DEPLOY_DIR
docker compose pull
docker compose up -d --remove-orphans
echo '-- Status:'
docker compose ps
"
echo "==> Done."
fi