diff --git a/.env.example b/.env.example index d99aa17..836c1a8 100644 --- a/.env.example +++ b/.env.example @@ -18,4 +18,4 @@ GUILD_ID= OWNER_ID= # Cooldown time in ms (set to 0 to disable) -COOLDOWN_TIME=2000 \ No newline at end of file +COOLDOWN_TIME=2000 diff --git a/.gitignore b/.gitignore index fb0aec7..d91dbba 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,8 @@ node_modules /src/modals/EvalModal.ts # build -/dist \ No newline at end of file +/dist + + +# User generated docker files (Root of the project only) +/db diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6d00529 --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..83b588b --- /dev/null +++ b/docker-compose.yml @@ -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 diff --git a/docker.md b/docker.md new file mode 100644 index 0000000..f84dc36 --- /dev/null +++ b/docker.md @@ -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.