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
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,15 @@ jobs:
test:
name: CI
uses: TytaniumDev/.github/.github/workflows/test.yml@main

verify-ts:
name: TypeScript Verification
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: ./scripts/verify-ts.sh
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ venv/
.vscode/
.idea/
*.log
activity/node_modules/
node_modules/
activity/dist/

# Project-specific
Expand Down
22 changes: 10 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
FROM python:3.11-slim

# Install system dependencies
RUN apt-get update && apt-get install -y \
ffmpeg \
libnacl-dev \
gcc \
&& rm -rf /var/lib/apt/lists/*
FROM node:22-slim

WORKDIR /app

ARG GIT_SHA=
ENV GIT_SHA=${GIT_SHA}

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy workspace configs first for better layer caching
COPY package.json package-lock.json ./
COPY packages/shared/package.json packages/shared/
COPY packages/bot/package.json packages/bot/

RUN npm ci --workspace=packages/shared --workspace=packages/bot

COPY . .
# Copy source code
COPY packages/ packages/

CMD ["python", "bot.py"]
CMD ["node", "node_modules/.bin/tsx", "packages/bot/src/bot.ts"]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For production deployments, it's better to compile the TypeScript code to JavaScript during the build process and run the output with node directly, rather than using tsx at runtime. This avoids the overhead of on-the-fly compilation and removes a development dependency from the final image.

A multi-stage Dockerfile would be ideal for this. You can have a builder stage that installs all dependencies and compiles the code, and a final, smaller production stage that copies only the necessary node_modules and the compiled JavaScript from the dist directory.

CMD ["node", "packages/bot/dist/bot.js"]

2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
volumes:
- ./data:/data
healthcheck:
test: ["CMD-SHELL", "grep -aq 'bot.py' /proc/1/cmdline"]
test: ["CMD-SHELL", "grep -aq node /proc/1/cmdline"]
interval: 10s
timeout: 5s
retries: 3
Expand Down
20 changes: 20 additions & 0 deletions eslint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.strict,
{
ignores: ['**/dist/', '**/node_modules/', 'activity/'],
},
{
files: ['packages/**/*.ts'],
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
],
'@typescript-eslint/no-non-null-assertion': 'warn',
},
},
);
Loading