Skip to content

Update Docker Setup and Configuration #340

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

Open
wants to merge 1 commit into
base: master
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ yarn.lock
pnpm-lock.yaml

.env
.idea
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use the official Node.js image as a base
FROM node:18

# Set the working directory inside the container
WORKDIR /app

# Copy package.json and package-lock.json into the container
COPY package*.json ./

# Install dependencies
RUN npm install

# Copy the rest of the application files into the container
COPY . .

# Expose the port the app will run on
EXPOSE 3000

# Start the application
CMD ["npm", "start"]
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,56 @@ Please do not withdraw the license and keep the credits on this project.

To have full access to the project and to be able to withdraw the credits a small donation is accepted.

### 📦 Installation via Docker

#### 1. Install Docker

Make sure you have [Docker](https://www.docker.com/get-started) and [Docker Compose](https://docs.docker.com/compose/install/) installed.

#### 2. Build the Docker Image and Run the Container

1. To build the Docker image from the `Dockerfile` in the root directory of your project, use the Docker tool. The image will be created with the tag `music-bot`.

`docker build -t music-bot .`

2. After building the image, you can run the container, specifying the container name, port mapping, and the environment variable file `.env` for configuration.

`docker run -d --name music-bot -p 3000:3000 --env-file .env music-bot`

#### 3. Using Docker Compose

If you prefer to use `docker-compose` to manage containers, ensure that your project has a `docker-compose.yml` file. This file should define all services, including the container for your bot, as well as ports and the environment variable file.

```yaml
version: '3.8'
services:
music-bot:
build:
context: .
dockerfile: Dockerfile
container_name: music-bot
ports:
- "3000:3000"
env_file:
- .env
restart: unless-stopped
```

1. To build and start the container using `docker-compose`, use the standard commands, which will automatically create and start the container in the background.

`docker-compose up --build -d`

2. To stop the containers using Docker Compose, there's a command to stop all services and remove the created containers.

`docker-compose down`

#### 4. Notes

- Environment variables from the `.env` file will automatically be loaded for both Docker and Docker Compose, provided the file is correctly configured.
- Make sure all required variables (such as `DISCORD_TOKEN`, `GUILD_ID`, and others) are set in the `.env` file before running the container.

Now your bot should be set up and running in a Docker container!

### ❗supported languages:

| Code | Language | Code | Language | Code | Language |
Expand Down
14 changes: 14 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: '3.8'

services:
music-bot:
build:
context: .
dockerfile: Dockerfile
container_name: music-bot
ports:
- "3000:3000"
environment: # Define environment variables directly in the docker-compose file
DISCORD_TOKEN: ""
GUILD_ID: ""
restart: unless-stopped