test
Some checks failed
Build & Deploy / Build & Push (push) Has been cancelled
Build & Deploy / Deploy (push) Has been cancelled
Build & Deploy / Docker GC (push) Has been cancelled

This commit is contained in:
AlucardDev
2026-08-29 01:00:53 +03:00
parent 71bb333bee
commit 46ae17d960
6 changed files with 139 additions and 14 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -1,17 +1,20 @@
name: Build & Push Docker Image name: Build & Deploy
on: on:
push: push:
branches: branches:
- main - main
- staging
- dev
env: env:
REGISTRY: git.severostudio.ru REGISTRY: git.severostudio.ru
IMAGE_NAME: ${{ github.repository }} IMAGE_NAME: ${{ github.repository }}
jobs: jobs:
docker: build:
runs-on: ubuntu-latest name: Build & Push
runs-on: master-builder
steps: steps:
- name: Checkout - name: Checkout
@@ -33,5 +36,85 @@ jobs:
context: . context: .
push: true push: true
tags: | tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
deploy:
name: Deploy
runs-on: master-builder
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Encode Docker Stack
id: stack
run: |
echo "content=$(base64 -w 0 docker-stack.yml)" >> "$GITHUB_OUTPUT"
- name: Deploy via SSH
uses: appleboy/ssh-action@v1
env:
BRANCH: ${{ github.ref_name }}
REGISTRY: ${{ env.REGISTRY }}
IMAGE_NAME: ${{ env.IMAGE_NAME }}
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
STACK_FILE: ${{ steps.stack.outputs.content }}
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_SSH_KEY }}
envs: BRANCH,REGISTRY,IMAGE_NAME,REGISTRY_USERNAME,REGISTRY_PASSWORD,STACK_FILE
script: |
set -e
IMAGE="${REGISTRY}/${IMAGE_NAME}:${BRANCH}"
DEPLOY_DIR="/opt/${IMAGE_NAME}/${BRANCH}"
STACK_NAME="$(echo "${IMAGE_NAME}" | tr '/' '-')-${BRANCH}"
echo "=== Deployment ==="
echo "Branch: ${BRANCH}"
echo "Image: ${IMAGE}"
echo "Directory: ${DEPLOY_DIR}"
echo "Stack: ${STACK_NAME}"
mkdir -p "${DEPLOY_DIR}"
echo "${STACK_FILE}" | base64 -d > "${DEPLOY_DIR}/docker-stack.yml"
echo "${REGISTRY_PASSWORD}" | docker login "${REGISTRY}" \
-u "${REGISTRY_USERNAME}" \
--password-stdin
docker pull "${IMAGE}"
export IMAGE="${IMAGE}"
docker stack deploy \
--compose-file "${DEPLOY_DIR}/docker-stack.yml" \
--with-registry-auth \
"${STACK_NAME}"
echo "=== Services ==="
docker stack services "${STACK_NAME}"
gc:
name: Docker GC
runs-on: master-builder
needs:
- build
- deploy
if: always()
steps:
- name: Cleanup builder
run: |
docker container prune -f
docker image prune -af
docker builder prune -af || true
echo "=== Docker disk usage ==="
docker system df
df -h /

2
.npmrc
View File

@@ -1,2 +0,0 @@
shamefully-hoist=true
strict-peer-dependencies=false

View File

@@ -1,15 +1,35 @@
FROM node:22-alpine FROM node:22-alpine AS base
WORKDIR /usr/src/app ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
COPY package*.json ./ RUN corepack enable
RUN npm install --production WORKDIR /app
FROM base AS deps
COPY package.json pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
FROM base AS build
COPY --from=deps /app/node_modules ./node_modules
COPY . . COPY . .
RUN npm run build RUN pnpm build
FROM base AS production
ENV NODE_ENV=production
COPY --from=build /app/.output ./.output
EXPOSE 3000 EXPOSE 3000
CMD [ "npm", "run", "start" ] CMD ["node", ".output/server/index.mjs"]

24
docker-stack.yml Normal file
View File

@@ -0,0 +1,24 @@
services:
app:
image: ${IMAGE_TAG}
environment:
- NODE_ENV=production
- PORT=3000
- NUXT_PUBLIC_API_BASE=${NUXT_PUBLIC_API_BASE:-https://api.main.aeterna.id/v1}
- NUXT_PUBLIC_WS_URL=${NUXT_PUBLIC_WS_URL:-https://api.main.aeterna.id}
- NUXT_PUBLIC_EDITOR_BASE=${NUXT_PUBLIC_EDITOR_BASE:-https://editor.main.aeterna.id}
networks:
- traefik_proxy
deploy:
replicas: 1
labels:
- traefik.enable=true
- traefik.docker.network=traefik_proxy
- traefik.http.routers.dashboard.rule=Host(`dashboard.main.aeterna.id`)
- traefik.http.routers.dashboard.entrypoints=websecure
- traefik.http.services.dashboard.loadbalancer.server.port=3000
- traefik.http.routers.dashboard.tls.certresolver=le
networks:
traefik_proxy:
external: true

4
pnpm-lock.yaml generated
View File

@@ -11449,7 +11449,7 @@ snapshots:
'@petamoriken/float16': 3.9.2 '@petamoriken/float16': 3.9.2
debug: 4.4.3 debug: 4.4.3
env-paths: 3.0.0 env-paths: 3.0.0
semver: 7.7.3 semver: 7.7.4
shell-quote: 1.8.3 shell-quote: 1.8.3
which: 4.0.0 which: 4.0.0
transitivePeerDependencies: transitivePeerDependencies:
@@ -12298,7 +12298,7 @@ snapshots:
node-abi@3.77.0: node-abi@3.77.0:
dependencies: dependencies:
semver: 7.7.3 semver: 7.7.4
optional: true optional: true
node-addon-api@7.1.1: {} node-addon-api@7.1.1: {}