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
16 changes: 12 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@ services:
container_name: ticket-bot
environment:
- TOKEN
- DATABASE_URL=postgres://postgres:postgres@pgsql:5432/postgres
networks:
- net
depends_on:
- pgsql
restart: on-failure
volumes:
- /opt/ticket-bot/config:/app/config
pgsql:
image: postgres:15.3-alpine
environment:
- POSTGRES_PASSWORD=postgres
networks:
- net
volumes:
- ./db-data:/var/lib/postgresql/data
ports:
- "5432:5432"
- /opt/ticket-bot/pgsql:/var/lib/postgresql/data
restart: on-failure

networks:
net:
driver: bridge
20 changes: 20 additions & 0 deletions docker_run.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
#!/bin/bash

# Setup the config files
if [ ! -f "./config/config.json" ]; then
if [ -f "./temp_config/config.jsonc" ]; then
# Config already setup by the user
echo "Pre-build config detected, moving to config folder...";
mv ./temp_config/config.jsonc ./config/config.jsonc
else
# Config not setup by the user
echo "Config not detected, creating config...";
echo "Make sure to edit the config file in /opt/ticket-bot/config/config.jsonc before starting the bot again.";
mv ./temp_config/config.example.jsonc ./config/config.jsonc
exit 1;
fi
else
echo "Config detected, cleaning up temp_config...";
rm -rf ./temp_config
fi

npx prisma db push --schema=./prisma/docker.prisma
npm run start
10 changes: 7 additions & 3 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ FROM node:20.3-alpine

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

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

Expand All @@ -22,5 +22,9 @@ COPY tsconfig.json .
COPY src ./src
RUN npm run build

# Setup Bash
RUN apk add --no-cache bash
RUN chmod +x ./docker_run.sh

# Start the server
CMD ["./docker_run.sh"]
ENTRYPOINT ["./docker_run.sh"]