diff --git a/.gitignore b/.gitignore index 1e6698f5..ec061d82 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ yarn.lock pnpm-lock.yaml .env +.idea \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..0724c57b --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/README.md b/README.md index b3b7e4f0..ddeb7113 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..72a75a0c --- /dev/null +++ b/docker-compose.yml @@ -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 \ No newline at end of file