Merge branch 'dev' of ssh://meowgit.nekoea.red:22222/nihonium/nyanimedb into dev
All checks were successful
Build (backend build only) / build (push) Successful in 3m32s

This commit is contained in:
Iron_Felix 2025-12-19 23:49:57 +03:00
commit 53e270015c
7 changed files with 132 additions and 22 deletions

View file

@ -0,0 +1,49 @@
name: Build (backend build only)
on:
push:
branches:
- dev-ars
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# Build backend
- uses: actions/setup-go@v6
with:
go-version: '^1.25'
- name: Build backend
run: |
cd modules/backend
go build -o nyanimedb .
tar -czvf nyanimedb-backend.tar.gz nyanimedb
- name: Upload built backend to artifactory
uses: actions/upload-artifact@v3
with:
name: nyanimedb-backend.tar.gz
path: modules/backend/nyanimedb-backend.tar.gz
# Build Docker images
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ vars.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push backend image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfiles/Dockerfile_backend
push: true
tags: meowgit.nekoea.red/nihonium/nyanimedb-backend:latest

View file

@ -0,0 +1,54 @@
name: Build (frontend build only)
on:
push:
branches:
- front
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
# Build frontend
- uses: actions/setup-node@v5
with:
node-version-file: modules/frontend/package.json
cache: npm
cache-dependency-path: modules/frontend/package-lock.json
- name: Build frontend
env:
VITE_BACKEND_API_BASE_URL: ${{ vars.BACKEND_API_BASE_URL }}
run: |
cd modules/frontend
npm install
npm run build
tar -czvf nyanimedb-frontend.tar.gz dist/
- name: Upload built frontend to artifactory
uses: actions/upload-artifact@v3
with:
name: nyanimedb-frontend.tar.gz
path: modules/frontend/nyanimedb-frontend.tar.gz
# Build Docker images
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
registry: ${{ vars.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push frontend image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfiles/Dockerfile_frontend
push: true
tags: meowgit.nekoea.red/nihonium/nyanimedb-frontend:latest

View file

@ -1,13 +1,6 @@
FROM python:3.12-slim
WORKDIR /app/modules/anime_etl
# RUN apt-get update && apt-get install -y --no-install-recommends \
# build-essential \
# libpq-dev \
# ca-certificates \
# && rm -rf /var/lib/apt/lists/*
COPY modules/anime_etl/pyproject.toml modules/anime_etl/uv.lock ./
RUN pip install --no-cache-dir uv \
@ -17,5 +10,4 @@ COPY modules/anime_etl ./
ENV NYANIMEDB_MEDIA_ROOT=/media
# было: CMD ["python", "-m", "rabbit_worker"]
CMD ["uv", "run", "python", "-m", "rabbit_worker"]

View file

@ -1,25 +1,15 @@
FROM python:3.12-slim
# каталог внутри контейнера
WORKDIR /app/modules/image_storage
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# 1. зависимости через uv
COPY modules/image_storage/pyproject.toml modules/image_storage/uv.lock ./
RUN pip install --no-cache-dir uv \
&& uv sync --frozen --no-dev
# 2. сам код
COPY modules/image_storage ./
# 3. где будем хранить файлы внутри контейнера
ENV NYANIMEDB_MEDIA_ROOT=/media
EXPOSE 8000
# 4. поднимаем FastAPI-приложение (app/main.py → app.main:app)
CMD ["uv", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
CMD ["uv", "run", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

View file

@ -1,4 +1,5 @@
import React from "react";
import { useState, useEffect } from "react";
import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import UserPage from "./pages/UserPage/UserPage";
import TitlesPage from "./pages/TitlesPage/TitlesPage";
@ -11,8 +12,22 @@ import { Header } from "./components/Header/Header";
// OpenAPI.WITH_CREDENTIALS = true
const App: React.FC = () => {
// const username = localStorage.getItem("username") || undefined;
const userId = localStorage.getItem("user_id");
const [userId, setUserId] = useState<string | null>(localStorage.getItem("user_id"));
// 2. Listen for the same event the Header uses
useEffect(() => {
const handleAuthChange = () => {
setUserId(localStorage.getItem("user_id"));
};
window.addEventListener("storage", handleAuthChange);
window.addEventListener("local-storage-update", handleAuthChange);
return () => {
window.removeEventListener("storage", handleAuthChange);
window.removeEventListener("local-storage-update", handleAuthChange);
};
}, []);
return (
<Router>

View file

@ -14,8 +14,16 @@ export const Header: React.FC = () => {
// Listen for localStorage changes to update username dynamically
useEffect(() => {
const handleStorage = () => setUsername(localStorage.getItem("user_name"));
// This catches changes from OTHER tabs
window.addEventListener("storage", handleStorage);
return () => window.removeEventListener("storage", handleStorage);
// This catches changes in the CURRENT tab if you use dispatchEvent
window.addEventListener("local-storage-update", handleStorage);
return () => {
window.removeEventListener("storage", handleStorage);
window.removeEventListener("local-storage-update", handleStorage);
};
}, []);
const handleLogout = async () => {

View file

@ -21,6 +21,7 @@ export const LoginPage: React.FC = () => {
if (res.data?.user_id && res.data?.user_name) {
localStorage.setItem("user_id", res.data.user_id.toString());
localStorage.setItem("user_name", res.data.user_name);
window.dispatchEvent(new Event("storage"));
navigate("/profile");
} else {
setError("Login failed");
@ -34,6 +35,7 @@ export const LoginPage: React.FC = () => {
if (loginRes.data?.user_id && loginRes.data?.user_name) {
localStorage.setItem("user_id", loginRes.data.user_id.toString());
localStorage.setItem("user_name", loginRes.data.user_name);
window.dispatchEvent(new Event("storage"));
navigate("/profile");
}
} else {