Skip to content

Commit 6556d7f

Browse files
authored
Merge pull request #1 from gokhanercan/master
Added docker and ansible instructions
2 parents 8ebc7c9 + 376615d commit 6556d7f

19 files changed

Lines changed: 437 additions & 20 deletions

‎.dockerignore‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.output
3+
dist
4+
*.log
5+
Dockerfile

‎.gitattributes‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
*.sh text eol=lf
2+
Dockerfile text eol=lf
3+
4+
# Data files (wordnets, dictionaries, corpora) must stay LF. The
5+
# nlptoolkit-dictionary loader splits on "\n" and uses the last token on each
6+
# line as a flag, so trailing CR breaks flag lookups like isProperNoun().
7+
*.txt text eol=lf
8+
*.xml text eol=lf

‎.github/workflows/deploy.yml‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Deploy to Guzel VPS
2+
3+
on:
4+
push:
5+
branches: [master]
6+
workflow_dispatch: # allow manual "Run workflow" from the Actions tab
7+
8+
# The deploy SSH key is command-restricted on the VPS — it can only run
9+
# /root/deploy.sh — so even a leaked key cannot open a shell.
10+
# Secrets required on the repo:
11+
# DEPLOY_SSH_KEY - private key (ed25519) matching /root/.ssh/authorized_keys entry
12+
# VPS_HOST_KEY - a single known_hosts line (from ssh-keyscan -t ed25519 <host>)
13+
14+
jobs:
15+
deploy:
16+
runs-on: ubuntu-latest
17+
concurrency:
18+
group: deploy-guzel
19+
cancel-in-progress: false
20+
timeout-minutes: 10
21+
22+
steps:
23+
- name: Configure SSH
24+
run: |
25+
mkdir -p ~/.ssh
26+
chmod 700 ~/.ssh
27+
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_ed25519
28+
chmod 600 ~/.ssh/id_ed25519
29+
echo "${{ secrets.VPS_HOST_KEY }}" > ~/.ssh/known_hosts
30+
chmod 600 ~/.ssh/known_hosts
31+
32+
- name: Trigger deploy
33+
run: |
34+
# The key is pinned to command="/root/deploy.sh" on the server,
35+
# so whatever we pass here is ignored. We pass `true` as a no-op.
36+
ssh -o IdentitiesOnly=yes \
37+
-i ~/.ssh/id_ed25519 \
38+
-o UserKnownHostsFile=~/.ssh/known_hosts \
39+
root@104.247.163.162 true
40+
41+
- name: Smoke test
42+
run: |
43+
# Poll the public endpoint until it returns 200 (startup ~30-60s).
44+
for i in {1..60}; do
45+
code=$(curl -sS -o /dev/null -w '%{http_code}' --max-time 4 http://104.247.163.162:3000/ || true)
46+
echo "attempt $i: HTTP $code"
47+
if [ "$code" = "200" ]; then exit 0; fi
48+
sleep 3
49+
done
50+
echo "::error::App did not return 200 within ~3 minutes"
51+
exit 1

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ logs
2525
!.env.example
2626

2727
# Project specific
28-
hunky-dory.xml
28+
hunky-dory.xml
29+
*.tar

‎AGENTS.md‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# AGENTS.md
2+
3+
Guidelines for coding assistants working on this repository. Vendor-neutral — intended for any AI coding tool (Claude Code, Codex, Cursor, etc.).
4+
5+
## Project overview
6+
7+
Nuxt 3 (Vue 3) port of the Starlang NLP Toolkit. Runs as a single Node/Nitro server built from `Dockerfile`. Data files (wordnets, dictionaries, corpora) ship alongside the build — some at the repo root (copied into `.output/` by the Dockerfile) and some under `public/` (served as static by Nuxt).
8+
9+
This is a fork of [kubarium/nlptoolkit](https://github.com/kubarium/nlptoolkit) maintained by [gokhanercan](https://github.com/gokhanercan). Fork-specific additions live in:
10+
11+
- `Dockerfile`
12+
- `ops/` — ansible playbook, deploy notes
13+
- This file
14+
15+
## Semantic versioning
16+
17+
The project follows [Semantic Versioning](https://semver.org/) (`MAJOR.MINOR.PATCH`).
18+
19+
### Version file
20+
21+
- **`package.json`** — the `"version"` field is the single source of truth. The UI reads it via `nuxt.config.ts` (`runtimeConfig.public.appVersion`) and renders it in the `NavBar` footer.
22+
23+
### When to bump each number
24+
25+
- **PATCH** (`1.0.0 → 1.0.1`): bug fixes, doc-only changes, dependency patch bumps, internal refactors with no observable behavior change.
26+
- **MINOR** (`1.0.1 → 1.1.0`): new features, new pages/tools, non-breaking additions to routes or components. Reset PATCH to `0`.
27+
- **MAJOR** (`1.1.0 → 2.0.0`): breaking changes — removed/renamed routes or APIs, schema changes, defaults flipped in user-visible ways. Reset MINOR and PATCH to `0`.
28+
29+
When torn between MINOR and PATCH, **prefer PATCH**. Pre-release suffixes (`1.2.0-beta.1`) are allowed when needed.
30+
31+
### Core rules
32+
33+
1. **Always bump `package.json`'s `version` when you change application code, the Dockerfile, or ops scripts.** Comment-only or AGENTS.md-only edits can skip a bump.
34+
2. **Never skip numbers.** `1.0.3 → 1.0.4`, not `1.0.3 → 1.0.5`.
35+
3. **Never reuse a number.** Once shipped or tagged, that number is burned.
36+
4. **Never decrease a version.** Fix forward with a new PATCH.
37+
5. **Bump once per logical change**, not once per file.
38+
6. **Do not bump for CI/tooling/formatting-only changes.**
39+
40+
### Workflow for a coding assistant
41+
42+
When modifying code in this repo:
43+
44+
1. Decide MAJOR / MINOR / PATCH based on the user-visible impact of the change.
45+
2. Update `package.json`'s `version` in the same commit as the code change.
46+
3. If you add a new file that also records a version (e.g. a new installer), list it here so future updates stay in sync.
47+
4. Do not create git tags unless the user asks.
48+
49+
If uncertain about the bump level, ask before committing.
50+
51+
## Build & run
52+
53+
Three helper scripts at the repo root cover common workflows:
54+
55+
- `./install.sh` — install pnpm (if missing) + project deps.
56+
- `./run.sh` — `pnpm dev`, Nitro on `:3000`. Ctrl+C to stop.
57+
- `./docker-run.sh` — `docker build` + `docker run` on `:3000`. Ctrl+C to stop (auto-removed).
58+
59+
See `ops/readme.md` for the production deployment flow (docker save → scp → docker load on a remote host).
60+
61+
## Upstream sync
62+
63+
- Upstream is `kubarium/nlptoolkit` (remote name: `upstream`).
64+
- Fork is `gokhanercan/nlptoolkit` (remote name: `origin`).
65+
- When syncing upstream, prefer **merge** (not rebase) to avoid force-pushing the fork's public commits.

‎Dockerfile‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Build stage
2+
FROM node:18 AS builder
3+
WORKDIR /app
4+
COPY . .
5+
RUN npm install -g pnpm@latest
6+
RUN pnpm install
7+
# Raise Node's heap ceiling for the Nitro build — default ~2GB OOMs on
8+
# this repo's data-file-heavy build. 4GB gives headroom on modest hosts.
9+
RUN NODE_OPTIONS=--max-old-space-size=4096 pnpm build
10+
11+
COPY *.txt .output/
12+
COPY *.xml .output/
13+
14+
# Runtime stage
15+
FROM node:18-alpine
16+
WORKDIR /app
17+
COPY --from=builder /app/.output .
18+
EXPOSE 3000
19+
CMD ["node", "server/index.mjs"]
20+
21+
# Usage:
22+
# docker build -t nlptoolkit .
23+
# docker run -p 3000:3000 nlptoolkit
24+
# docker save -o nlptoolkit.tar nlptoolkit
25+
26+
# # Install git
27+
# RUN apt-get update && apt-get install -y git
28+
# #RUN git clone https://github.com/gokhanercan/nlptoolkit /app

‎README.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# Install
2+
3+
```bash
4+
npm install -g pnpm@latest-10
5+
pnpm i
6+
pnpm build
7+
node .output/server/index.mjs
8+
```
9+
10+
111
# Nuxt Minimal Starter
212

313
Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.

‎components/NavBar.vue‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<script setup lang="ts">
22
import type { NavigationMenuItem } from '@nuxt/ui'
33
4+
const appVersion = useRuntimeConfig().public.appVersion
5+
46
const menu_labels = {
57
"Turkish": {
68
"Resources": ['FrameNet', 'PropBank', 'WordNet', 'SentiNet', 'Dictionary', 'Morphological Lexicon'],
@@ -63,9 +65,11 @@ const items = ref<NavigationMenuItem[][]>([
6365
color="secondary" />
6466

6567
<a href="https://github.com/StarlangSoftware" target="_blank"
66-
class="flex self-center items-center justify-self-end py-2 gap-4">
68+
class="flex self-center items-center justify-self-end pt-2 gap-4">
6769
<img src="https://avatars.githubusercontent.com/u/61943048?s=48&v=4" alt="Starlang Software Logo">
6870
Starlang Software
6971
</a>
72+
73+
<p class="text-xs text-center text-gray-400 pb-2">v{{ appVersion }}</p>
7074
</header>
7175
</template>

‎docker-run.sh‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
# Build the Docker image and run the app on :3000.
3+
# Foreground: Ctrl+C stops the container; it is auto-removed on exit.
4+
#
5+
# Usage: ./docker-run.sh (from anywhere — cds into the repo first)
6+
set -euo pipefail
7+
8+
cd "$(dirname -- "${BASH_SOURCE[0]}")"
9+
10+
trap 'code=$?; echo ""; read -n 1 -s -r -p "Exited (code $code) — press any key to close..."; echo ""' EXIT
11+
12+
IMAGE="nlptoolkit"
13+
NAME="nlptoolkit"
14+
15+
echo "==> docker build -t ${IMAGE} ."
16+
docker build -t "${IMAGE}" .
17+
18+
# Remove any previous foreground/detached container with the same name.
19+
docker rm -f "${NAME}" >/dev/null 2>&1 || true
20+
21+
echo "==> docker run -p 3000:3000 (Ctrl+C to stop)"
22+
docker run --rm --name "${NAME}" -p 3000:3000 "${IMAGE}"

‎install.sh‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
# Install pnpm (if missing) and this project's dependencies.
3+
#
4+
# Usage: ./install.sh (from anywhere — cds into the repo first)
5+
set -euo pipefail
6+
7+
cd "$(dirname -- "${BASH_SOURCE[0]}")"
8+
9+
trap 'code=$?; echo ""; read -n 1 -s -r -p "Exited (code $code) — press any key to close..."; echo ""' EXIT
10+
11+
if ! command -v pnpm >/dev/null 2>&1; then
12+
echo "==> pnpm not found, installing pnpm@latest-10 globally via npm"
13+
npm install -g pnpm@latest-10
14+
fi
15+
16+
echo "==> pnpm install"
17+
pnpm install
18+
19+
echo "==> done — run ./run.sh to start the dev server"

0 commit comments

Comments
 (0)