Compare commits
4
Commits
8a867d04a3
...
v1.0.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6108885c5d | ||
|
|
b283696cd7 | ||
|
|
22c0bf7697 | ||
|
|
be4f492314 |
+94
-13
@@ -8,8 +8,12 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: code.kruzya.dev
|
REGISTRY: code.kruzya.dev
|
||||||
|
# backend: api + bot + migrator (единый образ, разные CMD)
|
||||||
BACKEND_IMAGE: code.kruzya.dev/crazyhackgut/telegrammemevault/backend
|
BACKEND_IMAGE: code.kruzya.dev/crazyhackgut/telegrammemevault/backend
|
||||||
MINIAPP_IMAGE: code.kruzya.dev/crazyhackgut/telegrammemevault/miniapp
|
# frontend: miniapp nginx (для docker-compose)
|
||||||
|
FRONTEND_IMAGE: code.kruzya.dev/crazyhackgut/telegrammemevault/frontend
|
||||||
|
# frontend-static: FROM scratch, используется как image volume в k8s
|
||||||
|
FRONTEND_STATIC_IMAGE: code.kruzya.dev/crazyhackgut/telegrammemevault/frontend-static
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# ─────────────────────────────── TESTS ──────────────────────────────────────
|
# ─────────────────────────────── TESTS ──────────────────────────────────────
|
||||||
@@ -33,6 +37,36 @@ jobs:
|
|||||||
--no-restore \
|
--no-restore \
|
||||||
--logger "console;verbosity=normal"
|
--logger "console;verbosity=normal"
|
||||||
|
|
||||||
|
# ─────────────────────────────── HELM ───────────────────────────────────────
|
||||||
|
build-helm:
|
||||||
|
name: Build & push Helm chart
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && github.ref_type == 'tag'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Compute chart version
|
||||||
|
id: meta
|
||||||
|
run: |
|
||||||
|
VERSION="${GITHUB_REF_NAME#v}"
|
||||||
|
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Install Helm
|
||||||
|
uses: azure/setup-helm@v4
|
||||||
|
|
||||||
|
- name: Log in to registry
|
||||||
|
run: |
|
||||||
|
helm registry login ${{ env.REGISTRY }} \
|
||||||
|
--username CrazyHackGUT \
|
||||||
|
--password ${{ secrets.IMAGE_PUSH_TOKEN }}
|
||||||
|
|
||||||
|
- name: Package and push
|
||||||
|
run: |
|
||||||
|
helm package helm/memevault --version ${{ steps.meta.outputs.version }}
|
||||||
|
helm push memevault-${{ steps.meta.outputs.version }}.tgz \
|
||||||
|
oci://${{ env.REGISTRY }}/crazyhackgut/telegrammemevault
|
||||||
|
|
||||||
# ─────────────────────────────── BACKEND ────────────────────────────────────
|
# ─────────────────────────────── BACKEND ────────────────────────────────────
|
||||||
build-backend:
|
build-backend:
|
||||||
name: Build & push backend
|
name: Build & push backend
|
||||||
@@ -44,10 +78,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
# Вычисляем теги образа:
|
|
||||||
# sha-<короткий хеш> — всегда
|
|
||||||
# <ветка / git-тег> — всегда (слеши заменяются дефисами)
|
|
||||||
# latest — только при пуше git-тега
|
|
||||||
- name: Compute image tags
|
- name: Compute image tags
|
||||||
id: meta
|
id: meta
|
||||||
run: |
|
run: |
|
||||||
@@ -79,16 +109,64 @@ jobs:
|
|||||||
file: Dockerfile
|
file: Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
# Кэш хранится в самом реджистри — BuildKit достаёт его при следующей сборке
|
|
||||||
cache-from: type=registry,ref=${{ env.BACKEND_IMAGE }}:cache
|
cache-from: type=registry,ref=${{ env.BACKEND_IMAGE }}:cache
|
||||||
cache-to: type=registry,ref=${{ env.BACKEND_IMAGE }}:cache,mode=max
|
cache-to: type=registry,ref=${{ env.BACKEND_IMAGE }}:cache,mode=max
|
||||||
|
|
||||||
# ─────────────────────────────── MINIAPP ────────────────────────────────────
|
# ─────────────────────── FRONTEND-STATIC (FROM scratch) ─────────────────────
|
||||||
build-miniapp:
|
build-frontend-static:
|
||||||
name: Build & push miniapp
|
name: Build & push frontend-static
|
||||||
needs: test
|
needs: test
|
||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
outputs:
|
||||||
|
# Передаём точный sha-тег следующему джобу
|
||||||
|
image: ${{ steps.meta.outputs.image }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Compute image tags
|
||||||
|
id: meta
|
||||||
|
run: |
|
||||||
|
SHA="${GITHUB_SHA:0:12}"
|
||||||
|
SAFE_REF=$(echo "$GITHUB_REF_NAME" \
|
||||||
|
| tr '[:upper:]' '[:lower:]' \
|
||||||
|
| sed 's/[^a-z0-9._-]/-/g')
|
||||||
|
IMG="${{ env.FRONTEND_STATIC_IMAGE }}"
|
||||||
|
TAGS="${IMG}:sha-${SHA},${IMG}:${SAFE_REF}"
|
||||||
|
if [ "$GITHUB_REF_TYPE" = "tag" ]; then
|
||||||
|
TAGS="${TAGS},${IMG}:latest"
|
||||||
|
fi
|
||||||
|
echo "tags=${TAGS}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "image=${IMG}:sha-${SHA}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Log in to registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: CrazyHackGUT
|
||||||
|
password: ${{ secrets.IMAGE_PUSH_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: miniapp
|
||||||
|
file: miniapp/Dockerfile.frontend
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
cache-from: type=registry,ref=${{ env.FRONTEND_STATIC_IMAGE }}:cache
|
||||||
|
cache-to: type=registry,ref=${{ env.FRONTEND_STATIC_IMAGE }}:cache,mode=max
|
||||||
|
|
||||||
|
# ─────────────────────── FRONTEND (nginx поверх static) ─────────────────────
|
||||||
|
build-frontend:
|
||||||
|
name: Build & push frontend (nginx)
|
||||||
|
needs: build-frontend-static
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
packages: write
|
packages: write
|
||||||
steps:
|
steps:
|
||||||
@@ -101,7 +179,7 @@ jobs:
|
|||||||
SAFE_REF=$(echo "$GITHUB_REF_NAME" \
|
SAFE_REF=$(echo "$GITHUB_REF_NAME" \
|
||||||
| tr '[:upper:]' '[:lower:]' \
|
| tr '[:upper:]' '[:lower:]' \
|
||||||
| sed 's/[^a-z0-9._-]/-/g')
|
| sed 's/[^a-z0-9._-]/-/g')
|
||||||
IMG="${{ env.MINIAPP_IMAGE }}"
|
IMG="${{ env.FRONTEND_IMAGE }}"
|
||||||
TAGS="${IMG}:sha-${SHA},${IMG}:${SAFE_REF}"
|
TAGS="${IMG}:sha-${SHA},${IMG}:${SAFE_REF}"
|
||||||
if [ "$GITHUB_REF_TYPE" = "tag" ]; then
|
if [ "$GITHUB_REF_TYPE" = "tag" ]; then
|
||||||
TAGS="${TAGS},${IMG}:latest"
|
TAGS="${TAGS},${IMG}:latest"
|
||||||
@@ -122,8 +200,11 @@ jobs:
|
|||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: miniapp
|
context: miniapp
|
||||||
file: miniapp/Dockerfile
|
file: miniapp/Dockerfile.nginx
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
cache-from: type=registry,ref=${{ env.MINIAPP_IMAGE }}:cache
|
# Передаём точный тег собранного frontend-static
|
||||||
cache-to: type=registry,ref=${{ env.MINIAPP_IMAGE }}:cache,mode=max
|
build-args: |
|
||||||
|
STATIC_IMAGE=${{ needs.build-frontend-static.outputs.image }}
|
||||||
|
cache-from: type=registry,ref=${{ env.FRONTEND_IMAGE }}:cache
|
||||||
|
cache-to: type=registry,ref=${{ env.FRONTEND_IMAGE }}:cache,mode=max
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
name: Deploy to production
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
chart_version:
|
||||||
|
description: 'Helm chart version (e.g. 0.0.0-sha-abc123def456 or 1.2.3)'
|
||||||
|
required: true
|
||||||
|
image_tag:
|
||||||
|
description: 'Docker image tag (e.g. sha-abc123def456 or v1.2.3)'
|
||||||
|
required: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: code.kruzya.dev
|
||||||
|
NAMESPACE: memevault
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
name: Helm upgrade
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Set up kubeconfig
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.kube
|
||||||
|
echo "${{ secrets.KUBE_CONFIG }}" > ~/.kube/config
|
||||||
|
chmod 600 ~/.kube/config
|
||||||
|
|
||||||
|
- name: Log in to Helm registry
|
||||||
|
run: |
|
||||||
|
helm registry login ${{ env.REGISTRY }} \
|
||||||
|
--username CrazyHackGUT \
|
||||||
|
--password ${{ secrets.IMAGE_PUSH_TOKEN }}
|
||||||
|
|
||||||
|
- name: Deploy
|
||||||
|
run: |
|
||||||
|
helm upgrade --install memevault \
|
||||||
|
oci://${{ env.REGISTRY }}/crazyhackgut/telegrammemevault/memevault \
|
||||||
|
--version ${{ github.event.inputs.chart_version }} \
|
||||||
|
--namespace ${{ env.NAMESPACE }} \
|
||||||
|
--set image.tag=${{ github.event.inputs.image_tag }} \
|
||||||
|
--set miniapp.image.tag=${{ github.event.inputs.image_tag }} \
|
||||||
|
--atomic \
|
||||||
|
--timeout 5m
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1.7
|
|
||||||
|
|
||||||
# ── Build ─────────────────────────────────────────────────────────────────────
|
|
||||||
FROM node:22-alpine AS build
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY package*.json ./
|
|
||||||
RUN --mount=type=cache,target=/root/.npm \
|
|
||||||
npm ci
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
# ── Runtime ───────────────────────────────────────────────────────────────────
|
|
||||||
FROM nginx:1.27-alpine AS runtime
|
|
||||||
COPY --from=build /app/dist /usr/share/nginx/html
|
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
||||||
EXPOSE 80
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1.7
|
|
||||||
# Образ содержит только собранные статические файлы в корне (/).
|
|
||||||
# Используется как Image Volume в Kubernetes (≥ 1.31):
|
|
||||||
# volumes[].image монтирует содержимое образа напрямую в nginx-контейнер.
|
|
||||||
|
|
||||||
FROM node:22-alpine AS build
|
|
||||||
WORKDIR /app
|
|
||||||
|
|
||||||
COPY package*.json ./
|
|
||||||
RUN --mount=type=cache,target=/root/.npm \
|
|
||||||
npm ci
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
RUN npm run build
|
|
||||||
|
|
||||||
FROM scratch
|
|
||||||
COPY --from=build /app/dist /
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# syntax=docker/dockerfile:1.7
|
||||||
|
# Образ со статикой для image volume в Kubernetes (v1.31+).
|
||||||
|
# Содержит только собранные файлы Vite — без nginx и системных слоёв.
|
||||||
|
# Используется как init-volume: nginx монтирует его содержимое в /usr/share/nginx/html.
|
||||||
|
|
||||||
|
FROM node:22-alpine AS build
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN --mount=type=cache,target=/root/.npm \
|
||||||
|
npm ci
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Финальный образ — FROM scratch, файлы в корне
|
||||||
|
FROM scratch
|
||||||
|
COPY --from=build /app/dist /
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# syntax=docker/dockerfile:1.7
|
||||||
|
|
||||||
|
FROM node:22-alpine AS build
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN --mount=type=cache,target=/root/.npm \
|
||||||
|
npm ci
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# ── frontend-static: FROM scratch, image volume для k8s (v1.31+) ─────────────
|
||||||
|
FROM scratch AS static
|
||||||
|
COPY --from=build /app/dist /
|
||||||
|
|
||||||
|
# ── frontend: nginx для docker-compose ───────────────────────────────────────
|
||||||
|
FROM nginx:1.27-alpine AS nginx-runtime
|
||||||
|
COPY --from=build /app/dist /usr/share/nginx/html
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
EXPOSE 80
|
||||||
@@ -127,7 +127,6 @@ public sealed class InlineQueryHandler
|
|||||||
{
|
{
|
||||||
Caption = item.Caption,
|
Caption = item.Caption,
|
||||||
Title = item.InlineTitle,
|
Title = item.InlineTitle,
|
||||||
Description = item.InlineDescription ?? tagsLine,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
MediaType.Text => new InlineQueryResultArticle(
|
MediaType.Text => new InlineQueryResultArticle(
|
||||||
|
|||||||
Reference in New Issue
Block a user