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
54 changes: 27 additions & 27 deletions .github/workflows/deploy-commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Read Node version
run: |
NODE_VERSION=$(cat .nvmrc | sed 's/v//')
echo "NODE_VERSION=$NODE_VERSION" >> $GITHUB_ENV

- name: Deploy Discord Commands to VPS
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
script: |
cd /home/${{ secrets.VPS_USER }}/webdev-bot-deploy

# Read NODE_VERSION from .nvmrc
export NODE_VERSION=$(cat .nvmrc | sed 's/v//')
echo "Using Node version: $NODE_VERSION"

# Run deploy script inside the already running Docker container
# .env file should already exist from main deployment
echo "Deploying Discord commands..."
docker compose --profile prod exec bot-prod node dist/scripts/deploy-commands.js

echo "Discord commands deployment completed!"
- name: Checkout code
uses: actions/checkout@v4

- name: Read Node version
run: |
NODE_VERSION=$(cat .nvmrc | sed 's/v//')
echo "NODE_VERSION=$NODE_VERSION" >> $GITHUB_ENV

- name: Deploy Discord Commands to VPS
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
script: |
cd /home/${{ secrets.VPS_USER }}/webdev-bot-deploy

# Read NODE_VERSION from .nvmrc
export NODE_VERSION=$(cat .nvmrc | sed 's/v//')
echo "Using Node version: $NODE_VERSION"

# Run deploy script inside the already running Docker container
# .env file should already exist from main deployment
echo "Deploying Discord commands..."
docker compose --profile prod exec bot-prod node dist/scripts/deploy-commands.js

echo "Discord commands deployment completed!"
94 changes: 47 additions & 47 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,57 @@ name: Build, Test and Deploy Discord Bot to VPS

on:
push:
branches: [ "main" ]
branches: ['main']
workflow_dispatch: # Allow manual deployment

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Read Node version
run: |
NODE_VERSION=$(cat .nvmrc | sed 's/v//')
echo "NODE_VERSION=$NODE_VERSION" >> $GITHUB_ENV

- name: Deploy to VPS
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
script: |
cd /home/${{ secrets.VPS_USER }}/webdev-bot-deploy

# Stash any local changes
git stash push -m "Auto-deploy $(date)" 2>/dev/null || true

# Pull latest changes
git checkout main
git pull origin main

# Read NODE_VERSION from .nvmrc
export NODE_VERSION=$(cat .nvmrc | sed 's/v//')
echo "Using Node version: $NODE_VERSION"

# Create .env file with secrets
# Public config comes from .env.production (committed to repo)
# NODE_ENV=production is set in docker-compose.yml
cat > .env << EOF
DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }}
CLIENT_ID=${{ secrets.CLIENT_ID }}
EOF

# Stop any existing containers
docker compose down || true

# Build and start production container with profile
# NODE_ENV=production is explicitly set in docker-compose.yml bot-prod service
docker compose --profile prod up -d --build

# Check status
echo "Deployment completed. Container status:"
docker compose ps
- name: Checkout code
uses: actions/checkout@v4

- name: Read Node version
run: |
NODE_VERSION=$(cat .nvmrc | sed 's/v//')
echo "NODE_VERSION=$NODE_VERSION" >> $GITHUB_ENV

- name: Deploy to VPS
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
script: |
cd /home/${{ secrets.VPS_USER }}/webdev-bot-deploy

# Stash any local changes
git stash push -m "Auto-deploy $(date)" 2>/dev/null || true

# Pull latest changes
git checkout main
git pull origin main

# Read NODE_VERSION from .nvmrc
export NODE_VERSION=$(cat .nvmrc | sed 's/v//')
echo "Using Node version: $NODE_VERSION"

# Create .env file with secrets
# Public config comes from .env.production (committed to repo)
# NODE_ENV=production is set in docker-compose.yml
cat > .env << EOF
DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }}
CLIENT_ID=${{ secrets.CLIENT_ID }}
EOF

# Stop any existing containers
docker compose down || true

# Build and start production container with profile
# NODE_ENV=production is explicitly set in docker-compose.yml bot-prod service
docker compose --profile prod up -d --build

# Check status
echo "Deployment completed. Container status:"
docker compose ps
11 changes: 5 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Test

on:
pull_request:
branches: [ "**" ]
branches: ['**']
paths-ignore:
- 'docs/**'
- '.gitignore'
Expand Down Expand Up @@ -32,15 +32,14 @@ jobs:
npm install --no-audit --no-fund
fi

- name: Lint and Format
run: npm run check
- name: Lint
run: npm run lint

- name: Typecheck
run: npm run typecheck
- name: Format
run: npm run fmt:check

- name: Build
run: npm run build

- name: Test
run: npm run test:ci

3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["oxc.oxc-vscode"]
}
35 changes: 21 additions & 14 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
{
"editor.defaultFormatter": "biomejs.biome",
"prettier.enable": false,
"oxc.enable": false,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.biome": "explicit"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[json]": {
"editor.defaultFormatter": "biomejs.biome"
},
"typescript.tsdk": "node_modules/typescript/lib"
"biome.enabled": false,
"prettier.enable": false,
"eslint.enable": false,
"editor.codeActionsOnSave": {
"source.fixAll.oxc": "always"
},
"oxc.fmt.configPath": "oxfmt.config.ts",
"editor.defaultFormatter": "oxc.oxc-vscode",
"editor.formatOnSave": true,
"[typescript]": {
"editor.defaultFormatter": "oxc.oxc-vscode",
"editor.formatOnSave": true
},
"[javascript]": {
"editor.defaultFormatter": "oxc.oxc-vscode",
"editor.formatOnSave": true
},
"[json]": {
"editor.defaultFormatter": "oxc.oxc-vscode",
"editor.formatOnSave": true
}
}
11 changes: 10 additions & 1 deletion DOCKER.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ docker compose --profile dev up
```

In development mode:

- Code changes in `src/` are automatically detected and the bot restarts
- Full development dependencies are available
- Logs are streamed to your terminal
Expand Down Expand Up @@ -67,6 +68,7 @@ docker compose --profile prod up -d
```

In production mode:

- Minimal image size (only production dependencies)
- Optimized for runtime performance
- Runs in detached mode by default
Expand Down Expand Up @@ -124,6 +126,7 @@ docker run -it \
### Bot Not Starting

1. Check if environment variables are set correctly:

```bash
docker compose --profile dev run --rm bot-dev env | grep DISCORD
```
Expand All @@ -149,6 +152,7 @@ chmod 755 src/
If code changes aren't being detected in development mode:

1. Verify the volume mounts are correct:

```bash
docker inspect webdev-bot-dev | grep Mounts -A 10
```
Expand All @@ -161,6 +165,7 @@ If code changes aren't being detected in development mode:
### Image Size Concerns

The production image is optimized for size using:

- Alpine Linux base image
- Multi-stage builds (dev dependencies not included)
- Only compiled `dist/` folder and production dependencies
Expand Down Expand Up @@ -193,27 +198,31 @@ docker compose build --no-cache
## Additional Commands

View running containers:

```bash
docker ps
```

View all containers (including stopped):

```bash
docker ps -a
```

Remove all stopped containers:

```bash
docker compose down -v
```

View container logs in real-time:

```bash
docker compose --profile dev logs -f bot-dev
```

Execute commands inside the container:

```bash
docker compose --profile dev exec bot-dev sh
```

Loading
Loading