Compare commits

...

2 Commits

4 changed files with 112 additions and 1 deletions

13
.dockerignore Normal file
View File

@@ -0,0 +1,13 @@
node_modules
dist
.env
.env.*
prisma/dev.db
prisma/dev.db-journal
prisma/migrations/*.db
.idea
.vscode
coverage
*.log
.cache
.tmp

View File

@@ -0,0 +1,52 @@
name: Deploy
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Keyscan
run: |
ssh-keyscan git.koptilnya.xyz >> ~/.ssh/known_hosts
- name: Set up secret file
env:
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
run: |
echo "${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}" | sed 's/./& /g'
- name: Checkout
uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
ssh-strict: false
persist-credentials: false
# - name: Backup DB
# run: cp /home/koptilnya/services/chad/data/database.db /home/koptilnya/services/chad/database-$(date+"%d-%m-%Y").db
- name: Build
run: docker build -t hh-auto-reply ./server
- name: Stop old container
run: docker rm -f hh-auto-reply || true
- name: Run
run: |
docker run -d \
--name hh-auto-reply \
--network traefik \
--volume /home/koptilnya/services/chad/data:/app/data \
-p 40000-40100:40000-40100/udp \
--label "traefik.enable=true" \
--label "traefik.http.routers.hh-auto-reply.rule=Host(\`api.koptilnya.xyz\`) && PathPrefix(\`/hh-auto-reply\`)" \
--label "traefik.http.routers.hh-auto-reply.entrypoints=websecure" \
--label "traefik.http.routers.hh-auto-reply.tls=true" \
--label "traefik.http.routers.hh-auto-reply.tls.certresolver=myresolver" \
--label "traefik.http.services.hh-auto-reply.loadbalancer.server.port=80" \
hh-auto-reply:latest

46
Dockerfile Normal file
View File

@@ -0,0 +1,46 @@
# ── Stage 1: build ─────────────────────────────────────────────────────────────
FROM node:22-slim AS builder
WORKDIR /app
# build tools for native modules
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 make g++ \
&& rm -rf /var/lib/apt/lists/*
COPY package.json yarn.lock .yarnrc.yml ./
RUN corepack enable
RUN yarn install --immutable
COPY tsconfig.json ./
COPY prisma ./prisma
COPY src ./src
RUN yarn prisma generate && yarn build
# ── Stage 2: runtime ───────────────────────────────────────────────────────────
FROM node:22-slim AS runner
WORKDIR /app
RUN yarn prisma migrate deploy
RUN corepack enable
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/prisma ./prisma
COPY package.json yarn.lock .yarnrc.yml ./
# install Chromium + all system dependencies for Playwright
RUN npx playwright install --with-deps chromium
# SQLite data lives on a volume so it survives container restarts
RUN mkdir -p /data
ENV DATABASE_URL="file:/data/dev.db"
ENV NODE_ENV=production
VOLUME ["/data"]
# apply pending migrations then start the bot
CMD ["sh", "-c", "npx prisma migrate deploy && node dist/index.js"]

View File

@@ -7,8 +7,8 @@
"build": "tsc", "build": "tsc",
"start": "node --env-file=.env dist/index.js", "start": "node --env-file=.env dist/index.js",
"db-view": "yarn prisma studio", "db-view": "yarn prisma studio",
"db:deploy": "npx prisma migrate deploy && npx prisma generate",
"db-migrate": "npx prisma migrate dev", "db-migrate": "npx prisma migrate dev",
"db-deploy": "npx prisma migrate deploy",
"db-migrate-server": "git pull npx prisma migrate deploy", "db-migrate-server": "git pull npx prisma migrate deploy",
"lint": "eslint .", "lint": "eslint .",
"lint:fix": "eslint . --fix" "lint:fix": "eslint . --fix"