deploy scripts

This commit is contained in:
azykov@mail.ru
2026-07-01 10:42:49 +03:00
parent 5e234d9d61
commit 820ea95f26
4 changed files with 114 additions and 0 deletions
+66
View File
@@ -0,0 +1,66 @@
name: Build & Deploy
on:
push
env:
REGISTRY: git.aggtaa.com
IMAGE_PREFIX: ${{ gitea.repository }}
jobs:
# ── BUILD SERVER ──────────────────────────────────────────────────────────────
build-app:
runs-on: docker1
defaults:
run:
shell: sh
working-directory: /workspace
steps:
- name: Checkout
working-directory: /
run: |
mkdir -p /workspace
if [ -d /workspace/.git ]; then
cd /workspace && git fetch origin && git reset --hard origin/${{ gitea.ref_name }}
else
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git /workspace
fi
- name: Build & push app
run: |
echo "${{ secrets.REGISTRY_PASSWORD }}" | \
docker login ${{ env.REGISTRY }} -u ${{ secrets.REGISTRY_USER }} --password-stdin
/data/tools/docker-buildx build \
--cache-from type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/app:cache \
--cache-to type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/app:cache,mode=max \
--tag ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/app:latest \
--tag ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/app:${{ gitea.sha }} \
--file Dockerfile \
--push \
.
# ── DEPLOY ────────────────────────────────────────────────────────────────────
deploy:
runs-on: docker1
needs: [build-app]
if: always() && !failure() && !cancelled()
defaults:
run:
shell: sh
steps:
- name: Deploy
run: |
mkdir -p "/app-cache/${{ gitea.repository }}"
cd "/app-cache/${{ gitea.repository }}"
if [ ! -d .git ]; then
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git .
else
git pull origin main
fi
printf 'REGISTRY=%s\nIMAGE_PREFIX=%s\n' \
'${{ env.REGISTRY }}' \
'${{ env.IMAGE_PREFIX }}' > .env
docker compose pull
docker compose up -d --remove-orphans
docker image prune -f
+2
View File
@@ -1 +1,3 @@
node_modules node_modules
dist
.env
+33
View File
@@ -0,0 +1,33 @@
# syntax=docker/dockerfile:1
FROM node:22.22.3-alpine AS base
RUN corepack enable && corepack prepare pnpm@latest --activate
# ── deps ──────────────────────────────────────────────────────────────────────
FROM base AS deps
WORKDIR /app
COPY package.json pnpm-workspace.yaml pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
# ── build ─────────────────────────────────────────────────────────────────────
FROM deps AS builder
WORKDIR /app
COPY tsconfig.json ./
COPY src ./src
RUN pnpm build
# ── runtime ───────────────────────────────────────────────────────────────────
FROM node:22.22.3-alpine AS runner
RUN corepack enable && corepack prepare pnpm@latest --activate
WORKDIR /app
COPY package.json pnpm-workspace.yaml pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile --prod
COPY --from=builder /app/dist ./dist
EXPOSE 3000
CMD ["node", "dist/index.js"]
+13
View File
@@ -0,0 +1,13 @@
services:
server:
image: ${CI_REGISTRY_IMAGE:-claudemcp}/app:${CI_COMMIT_SHA:-latest}
container_name: ${CI_REGISTRY_IMAGE:-claudemcp}
restart: unless-stopped
ports:
- "${APP_PORT:-3000}:3000"
networks:
- local
networks:
local:
driver: bridge