Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docker Support #25

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ GUILD_ID=
OWNER_ID=

# Cooldown time in ms (set to 0 to disable)
COOLDOWN_TIME=2000
COOLDOWN_TIME=2000
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ node_modules
/src/modals/EvalModal.ts

# build
/dist
/dist


# User generated docker files (Root of the project only)
/db
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:latest
WORKDIR /usr/src/app
COPY package*.json ./
COPY . .
RUN npm install
RUN cp .env.example .env
RUN chmod u+x ./start.sh
CMD ["./start.sh"]
46 changes: 46 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: "3"
services:
dispenser-fork:
image: dispenser-fork
build: .
container_name: dispenser-fork
restart: unless-stopped
environment:
#DO NOT CHANGE THE HOST
POSTGRES_HOST: db
#DO NOT CHANGE THIS UNLESS YOU KNOW WHAT YOU ARE DOING
POSTGRES_USER: dispenser-fork
#CHANGE THE PASSWORD TO SOMETHING MORE SECURE (RECOMMENDED)
POSTGRES_PASSWORD: postgres
#DO NOT CHANGE THIS UNLESS YOU KNOW WHAT YOU ARE DOING!!
POSTGRES_DB: dispenser-fork
#THIS SHOULDN'T NEED TO CHANGE
DATABASE_URL: postgres://dispenser-fork:postgres@db:5432/dispenser-fork
####
#ANYTHING BELOW THIS NEEDS TO BE EDITED
#The discord bot's token (REQUIRED)
TOKEN: token
#The Bot ID for slash command deployment (REQUIRED)
CLIENT_ID: clientID
#The Server ID for quick deployment (Not required but recommended for quick deployment, delete line to disable)
GUILD_ID: guildID
# The ID of the Bot owner (NOT REQUIRED, delete line to disable)
OWNER_ID: ownerID
# Cooldown time in ms (set to 0 to disable)
COOLDOWN_TIME: 2000
depends_on:
- db
db:
image: postgres:latest
container_name: dispenser-fork-db
restart: unless-stopped
environment:
POSTGRES_USER: dispenser-fork
POSTGRES_PASSWORD: postgres
POSTGRES_DB: dispenser-fork
volumes:
- ./db:/var/lib/postgresql/data
networks:
default:
external: false
name: dispenser-fork-network
35 changes: 35 additions & 0 deletions docker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Docker installation

## Requirements:
- Docker
- Docker-compose

## Setup:
- Clone the repository
```bash
git clone https://github.com/nebulaServices/dispenser.git
cd dispenser
```

- Edit the docker-compose.yml file and change the env vars
- TOKEN
- CLIENT_ID
- GUILD_ID
- OWNER_ID (optional)
- COOLDOWN_TIME

*The other ones listed are not to be changed unless you know what you are doing*

- Build the image
```bash
docker-compose build
```

*You may have to run this as `sudo`*

- Run the image
```bash
docker-compose up -d
```

And that's it, the bot should be running now.