Skip to content

Commit

Permalink
Merge pull request #179 from Sayrix/docker
Browse files Browse the repository at this point in the history
Docker
  • Loading branch information
Sayrix authored Jul 3, 2023
2 parents b88deaf + 42112b1 commit bf1ca07
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 1 deletion.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ LICENSE
package.json
package-lock.json
dist/
db-data
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ config.jsonc
token.json
dist
.env
*.db
*.db
db-data
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3'

services:
bot:
build: .
container_name: ticket-bot
environment:
- TOKEN
- DATABASE_URL=postgres://postgres:postgres@pgsql:5432/postgres
depends_on:
- pgsql
restart: on-failure
pgsql:
image: postgres:15.3-alpine
environment:
- POSTGRES_PASSWORD=postgres
volumes:
- ./db-data:/var/lib/postgresql/data
ports:
- "5432:5432"
2 changes: 2 additions & 0 deletions docker_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
npx prisma db push --schema=./prisma/docker.prisma
npm run start
26 changes: 26 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM node:20.3-alpine

# Setup workspace
WORKDIR /app
ENV DATABASE_URL="postgresql://postgres:postgres@db:5432/postgres?schema=public"

# Copy runtime files
COPY ./config/config.jsonc ./config/config.jsonc
COPY docker_run.sh .
COPY locales ./locales

# Prisma builds
COPY prisma ./prisma
RUN npx prisma generate --schema=./prisma/docker.prisma

# Install dependencies
COPY package.json .
RUN npm install

# Transpile the source
COPY tsconfig.json .
COPY src ./src
RUN npm run build

# Start the server
CMD ["./docker_run.sh"]
31 changes: 31 additions & 0 deletions prisma/docker.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Docker uses postgresql as the main database
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model config {
key String @id
value String? @db.Text
}

model tickets {
id Int @id @default(autoincrement())
channelid String @unique
messageid String @unique
category String @db.Text
invited String @default("[]")
reason String
creator String
createdat BigInt
claimedby String?
claimedat BigInt?
closedby String?
closedat BigInt?
closereason String?
transcript String?
}

0 comments on commit bf1ca07

Please sign in to comment.