Commit 628ff463 authored by nanahira's avatar nanahira

add build with frontend

parent 9f24db3c
Pipeline #17222 canceled with stages
in 12 minutes and 47 seconds
.git*
__pycache__
.dockerignore
Dockerfile
Dockerfile*
/*.bat
/*.sh
/models
......
stages:
- build
- build2
- deploy
variables:
GIT_DEPTH: "1"
......@@ -13,13 +14,22 @@ before_script:
- docker build --pull -t $TARGET_IMAGE .
- docker push $TARGET_IMAGE
build-x86:
build:
extends: .build-image
tags:
- docker
variables:
TARGET_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
build_full:
extends: .build-image
stage: build2
script:
- docker build --pull --build-arg BASE=$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG -f Dockerfile.full -t $TARGET_IMAGE .
- docker push $TARGET_IMAGE
variables:
TARGET_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-full
.deploy:
stage: deploy
tags:
......@@ -32,6 +42,15 @@ build-x86:
deploy_latest:
extends: .deploy
variables:
FROM_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
TARGET_IMAGE: $CI_REGISTRY_IMAGE:latest
only:
- master
deploy_full:
extends: .deploy
variables:
FROM_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-full
TARGET_IMAGE: $CI_REGISTRY_IMAGE:$full
only:
- master
ARG BASE=git-registry.mycard.moe/novelai-storage/naifu:latest
FROM node:lts-bullseye as frontend
RUN apt update && apt -y install git && npm install -g pnpm && \
git clone https://code.mycard.moe/novelai-storage/naifu-frontend.git /frontend && \
cd /frontend && pnpm install && pnpm run build
FROM $BASE
COPY --from=frontend /frontend/build ./static
ENV WITH_STATIC=1
......@@ -8,6 +8,8 @@ services:
- ./models:/app/models
- ./main.py:/app/main.py:ro
- ./hydra_node:/app/hydra_node:ro
- ./static:/app/static:ro
environment:
# TOKEN_SERVER: https://api.moecube.com/accounts/authUser
TOKEN: mycard
WITH_STATIC: 1
......@@ -6,8 +6,8 @@ from pydantic import BaseModel
from fastapi.responses import HTMLResponse, PlainTextResponse, Response
from fastapi.exceptions import HTTPException
from fastapi.middleware.cors import CORSMiddleware
#from fastapi.staticfiles import StaticFiles
#from starlette.responses import FileResponse
from fastapi.staticfiles import StaticFiles
from starlette.responses import FileResponse
from hydra_node.config import init_config_model
from hydra_node.models import EmbedderModel
from typing import Optional, List
......@@ -316,7 +316,7 @@ def generate_text(request: TextRequest, authorized: bool = Depends(verify_token)
return ErrorOutput(error=str(e))
@app.get('/predict-tags', response_model=Union[TagOutput, ErrorOutput])
async def predict_tags(prompt="", authorized: bool = Depends(verify_token)):
async def predict_tags(prompt=""): #, authorized: bool = Depends(verify_token)):
t = time.perf_counter()
try:
#output = sanitize_input(config, request)
......@@ -342,11 +342,12 @@ async def predict_tags(prompt="", authorized: bool = Depends(verify_token)):
os.kill(mainpid, signal.SIGTERM)
return ErrorOutput(error=str(e))
#@app.get('/')
#def index():
# return FileResponse('static/index.html')
if os.getenv("WITH_STATIC", None):
@app.get('/')
def index():
return FileResponse('static/index.html')
#app.mount("/", StaticFiles(directory="static/"), name="static")
app.mount("/", StaticFiles(directory="static/"), name="static")
if __name__ == "__main__":
uvicorn.run("main:app", host="0.0.0.0", port=4315, log_level="info")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment