Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules
.git
.vscode
nlp-service
*.log
.env
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
typecheck:
name: TypeScript typecheck (src/)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- run: npm ci
- run: npm test

python-lint:
name: Python lint (nlp-service)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: pip install ruff
- run: ruff check nlp-service
65 changes: 65 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build & Publish Docker Images

on:
push:
branches: [main]
workflow_dispatch:

env:
REGISTRY: ghcr.io

jobs:
build-server:
name: Build server image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Compute lowercase image name
id: image
run: echo "name=${REGISTRY}/${GITHUB_REPOSITORY,,}/server" >> "$GITHUB_OUTPUT"
env:
REGISTRY: ${{ env.REGISTRY }}
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ steps.image.outputs.name }}:latest
${{ steps.image.outputs.name }}:${{ github.sha }}

build-nlp-service:
name: Build nlp-service image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Compute lowercase image name
id: image
run: echo "name=${REGISTRY}/${GITHUB_REPOSITORY,,}/nlp-service" >> "$GITHUB_OUTPUT"
env:
REGISTRY: ${{ env.REGISTRY }}
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: ./nlp-service
push: true
tags: |
${{ steps.image.outputs.name }}:latest
${{ steps.image.outputs.name }}:${{ github.sha }}
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:20-slim

WORKDIR /app

COPY package.json package-lock.json ./
RUN npm ci

COPY . .

ENV PORT=3000
EXPOSE 3000

CMD ["npm", "start"]
13 changes: 13 additions & 0 deletions nlp-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.11-slim

WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

ENV PORT=8000
EXPOSE 8000

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
2 changes: 1 addition & 1 deletion nlp-service/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel
from typing import Optional, List
from typing import Optional

load_dotenv(dotenv_path=os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", ".env"))

Expand Down
4 changes: 3 additions & 1 deletion nlp-service/test_service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import sys, os, json, traceback, importlib.util
import os
import traceback
import importlib.util

import spacy
nlp_spacy = spacy.load("xx_ent_wiki_sm")
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"nlp-service": "python nlp-service/main.py",
"start-all": "start /B python nlp-service/main.py > nul 2>&1 & timeout /T 10 /NOBREAK >nul & tsx server.ts",
"seed": "npx tsx src/seed.ts",
"demo": "npx tsx src/demo.ts"
"demo": "npx tsx src/demo.ts",
"typecheck": "tsc --noEmit",
"test": "npm run typecheck"
},
"dependencies": {
"@fission-ai/openspec": "^1.1.1",
Expand Down
Loading