diff --git a/.dockerignore b/.dockerignore index bb60387..1d58731 100644 --- a/.dockerignore +++ b/.dockerignore @@ -10,6 +10,7 @@ node_modules dist docs -config +data +frames .vscode video.mp4 \ No newline at end of file diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..ebab0a0 --- /dev/null +++ b/.env.example @@ -0,0 +1,35 @@ +HOST=0.0.0.0 +PORT=22 + +# Source video (auto-discovers video.* if unset). Only used to build frames.json. +VIDEO_PATH=video.mp4 + +MAX_LOOP=5 +# Weather to loop the video or play random frames after completion. Options: loop | random +PLAYBACK_MODE=random +# Let viewers switch frame sets with arrow keys +ALLOW_USER_CONTROL=true +# Min ms between arrow-key switches; ignores faster repeats. +SWITCH_DEBOUNCE_MS=120 +LOGIN_DELAY=1500 + +# ASCII rendering (live, no frame rebuild). +# CHARSET: detailed|standard|simple|blocks or custom ramp. +BRIGHTNESS_THRESHOLD=40 +CHARSET=blocks +INVERT=false + +# Max rendered width/height in characters. +MAX_DIMENSION=1080 +# Stored frame resolution (px). +# Higher = sharper but bigger frames.json. Rebuild required. +FRAME_RESOLUTION=512 + +MAX_CONNECTIONS=10 +MAX_TOTAL_CONNECTIONS=1000 +MAX_AUTH_ATTEMPTS=6 +HANDSHAKE_TIMEOUT=10000 + +LOG_CREDENTIALS=true +# Minimum log level to emit: debug | info | warn | error +LOG_LEVEL=info diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c325b2..da7584e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - bun-version: [latest, "1.1"] + bun-version: ["1.2"] steps: - uses: actions/checkout@v4 diff --git a/.gitignore b/.gitignore index 4bbc88e..f31587f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,10 @@ video.mp4 -#Configs -config/ +# Host keys & text assets +data/ + +# Generated frame sets +frames/ #VSCode .vscode diff --git a/Dockerfile b/Dockerfile index 91a9773..4796440 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,4 @@ -FROM oven/bun:1 AS build -WORKDIR /home/bun/app - -COPY package.json bun.lock ./ -RUN bun install --frozen-lockfile - -COPY tsconfig.json ./ -COPY src ./src -RUN bun run build - -FROM oven/bun:1-slim +FROM oven/bun:1.2-slim WORKDIR /home/bun/app RUN apt-get update -y && \ @@ -18,6 +8,7 @@ RUN apt-get update -y && \ COPY package.json bun.lock ./ RUN bun install --frozen-lockfile --production -COPY --from=build /home/bun/app/dist ./dist +COPY tsconfig.json ./ +COPY src ./src -CMD ["bun", "dist/index.js"] +CMD ["bun", "src/index.ts"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..f8e7988 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +services: + trollssh: + image: ghcr.io/yuzuzensai/trollssh:latest + container_name: trollssh + restart: unless-stopped + ports: + - "22:22" + env_file: + - .env + volumes: + # Host keys + banner/fakelogin/goodbye text assets (persisted). + - ./data:/home/bun/app/data + # Pre-generated frame sets + - ./frames:/home/bun/app/frames diff --git a/package.json b/package.json index 9a04a47..c6f8171 100644 --- a/package.json +++ b/package.json @@ -1,21 +1,22 @@ { "name": "trollssh", "version": "1.0.0", - "main": "index.js", + "main": "src/index.ts", "repository": "https://github.com/YuzuZensai/TrollSSH.git", "author": "Yuzu ", "license": "GPL-3.0", + "engines": { + "bun": ">=1.2.0" + }, "scripts": { "dev": "bun --watch src/index.ts", - "build": "tsc -b", - "start": "bun dist/index.js", + "start": "bun src/index.ts", "typecheck": "tsc --noEmit", "lint": "eslint .", "format": "prettier --check .", "format:fix": "prettier --write .", "test": "bun test", "docker-build": "docker build . -t ghcr.io/yuzuzensai/trollssh:latest", - "docker-run": "docker run -d --name trollssh --mount type=bind,source=\"$(pwd)\"/config,target=/home/node/app/config --mount type=bind,source=\"$(pwd)\"/video.mp4,target=/home/node/app/video.mp4 --network host --env-file .env ghcr.io/yuzuzensai/trollssh:latest", "docker-push": "docker push ghcr.io/yuzuzensai/trollssh:latest" }, "devDependencies": { diff --git a/tsconfig.json b/tsconfig.json index 37b451b..5843d3b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,8 +3,7 @@ "target": "ES2022", "module": "node16", "moduleResolution": "node16", - "outDir": "./dist", - "rootDir": "./src", + "noEmit": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "strict": true,