diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..f2c1396 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,33 @@ +name: Deploy Nexus + +on: + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Deploy to production + # SSH into the host and redeploy via docker compose. + # Set DEPLOY_HOST, DEPLOY_USER, and DEPLOY_SSH_KEY in repo secrets. + env: + SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }} + HOST: ${{ secrets.DEPLOY_HOST }} + USER: ${{ secrets.DEPLOY_USER }} + REPO_DIR: ${{ secrets.DEPLOY_REPO_DIR || '/opt/nexus' }} + run: | + if [ -z "$SSH_KEY" ] || [ -z "$HOST" ] || [ -z "$USER" ]; then + echo "Deploy secrets not configured — skipping remote deploy." + echo "Set DEPLOY_HOST, DEPLOY_USER, DEPLOY_SSH_KEY in repo settings." + exit 0 + fi + echo "$SSH_KEY" > /tmp/deploy_key + chmod 600 /tmp/deploy_key + ssh -o StrictHostKeyChecking=no -i /tmp/deploy_key "$USER@$HOST" \ + "cd $REPO_DIR && git pull origin main && docker compose up -d --build nexus" + rm /tmp/deploy_key diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..492a161 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,6 @@ +FROM node:20-alpine +WORKDIR /app +COPY . . +RUN npm install -g serve +EXPOSE 3000 +CMD ["serve", ".", "-l", "3000", "--no-clipboard"] diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..5a0b3a3 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# ◈ Nexus — quick deploy helper +# Usage: +# ./deploy.sh # deploy main to production (port 4200) +# ./deploy.sh staging # deploy current branch to staging (port 4201) + +set -euo pipefail + +BRANCH=$(git rev-parse --abbrev-ref HEAD) +MODE=${1:-production} + +echo "◈ Nexus deploy — branch: $BRANCH mode: $MODE" + +if [ "$MODE" = "staging" ]; then + docker compose --profile staging up -d --build nexus-staging + echo "✓ Staging live at http://localhost:4201 (branch: $BRANCH)" +else + docker compose up -d --build nexus + echo "✓ Production live at http://localhost:4200" +fi diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..7081a90 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,36 @@ +version: '3.9' + +# ◈ The Nexus — staging deployments +# +# Production (main): +# docker compose up -d nexus +# → http://:4200 +# +# Branch staging: +# BRANCH=my-feature docker compose up -d nexus-staging +# → http://:4201 +# +# To update production after a git pull: +# docker compose up -d --build nexus + +services: + nexus: + build: . + container_name: nexus-main + restart: unless-stopped + ports: + - "4200:3000" + labels: + - "nexus.branch=main" + + nexus-staging: + build: + context: . + container_name: nexus-staging + restart: unless-stopped + ports: + - "4201:3000" + labels: + - "nexus.branch=staging" + profiles: + - staging diff --git a/index.html b/index.html index 3a2c6ea..89c927f 100644 --- a/index.html +++ b/index.html @@ -118,5 +118,52 @@ + + + +