diff --git a/Dockerfile b/Dockerfile index b1ed91d06..346c5fdbc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,6 @@ WORKDIR /source # Copy the .csproj files for each project COPY src/Nadeko.Medusa/*.csproj src/Nadeko.Medusa/ COPY src/NadekoBot/*.csproj src/NadekoBot/ -COPY src/NadekoBot/creds_example.yml src/NadekoBot/ COPY src/NadekoBot.Coordinator/*.csproj src/NadekoBot.Coordinator/ COPY src/NadekoBot.Generators/*.csproj src/NadekoBot.Generators/ COPY src/NadekoBot.Voice/*.csproj src/NadekoBot.Voice/ @@ -44,12 +43,6 @@ RUN set -xe; \ apt-get autoremove -y; \ apt-get autoclean -y -# Copy creds_example.yml from the build stage -COPY --from=build /source/src/NadekoBot/creds_example.yml /source/src/NadekoBot/ - -# Check if creds.yml exists, if not, copy and rename creds_example.yml -RUN mkdir -p /app/data && if [ ! -f /app/data/creds.yml ]; then cp /source/src/NadekoBot/creds_example.yml /app/data/creds.yml; fi - # Copy the built application and the entrypoint script from the build stage COPY --from=build /app ./ COPY docker-entrypoint.sh /usr/local/sbin @@ -64,4 +57,4 @@ VOLUME [ "/app/data" ] # Set the entrypoint and default command ENTRYPOINT [ "/usr/local/sbin/docker-entrypoint.sh" ] -CMD dotnet NadekoBot.dll "$shard_id" "$total_shards" +CMD dotnet NadekoBot.dll "$shard_id" "$total_shards" \ No newline at end of file diff --git a/docs/guides/docker-guide.md b/docs/guides/docker-guide.md index b7a328f69..f4df053de 100644 --- a/docs/guides/docker-guide.md +++ b/docs/guides/docker-guide.md @@ -1,46 +1,76 @@ -# Setting up NadekoBot with Docker +# Deploying NadekoBot with Docker: A Comprehensive Guide -# WORK IN PROGRESS +## Getting Started -### Installation +Ensure Docker and Docker Compose are installed on your system. If not, follow the official Docker guides for your specific operating system: + +- [Docker Installation Guide](https://docs.docker.com/engine/install/) +- [Docker Compose Installation Guide](https://docs.docker.com/compose/install/) + +## Step-by-Step Installation + +1. **Choose Your Workspace:** Select a directory where you'll set up your NadekoBot stack. Use your terminal to navigate to this directory. For the purpose of this guide, we'll use `/opt/stacks/nadekobot/` as an example, but you can choose any directory that suits your needs. + +2. **Create a Docker Compose File:** In this directory, create a Docker Compose file named `docker-compose.yml`. You can use any text editor for this task. For instance, to use the `nano` editor, type `nano docker-compose.yml`. + +3. **Configure Your Docker Compose File:** Populate your Docker Compose file with the following configuration: -1. Create a `/srv/nadeko` folder - - `mkdir -p /srv/nadeko` -2. Create a `docker-compose.yml` - - nano `docker-compose.yml` - - copy the following contents into it: -##### docker-compose.yml ```yml -version: "3.7" services: nadeko: image: registry.gitlab.com/kwoth/nadekobot:latest - depends_on: - - redis + container_name: nadeko + restart: unless-stopped environment: - TZ: Europe/Paris - NadekoBot_RedisOptions: redis,name=nadeko - #NadekoBot_ShardRunCommand: dotnet - #NadekoBot_ShardRunArguments: /app/NadekoBot.dll {0} {1} + TZ: Europe/Rome volumes: - - /srv/nadeko/conf/creds.yml:/app/creds.yml:ro - - /srv/nadeko/data:/app/data - - redis: - image: redis:4-alpine - sysctls: - - net.core.somaxconn=511 - command: redis-server --maxmemory 32M --maxmemory-policy volatile-lru - volumes: - - /srv/nadeko/redis-data:/data + - /opt/stacks/nadekobot/conf/creds.yml:/app/data/creds.yml + - /opt/stacks/nadekobot/data:/app/data +networks: {} ``` -3. Save your file and run docker compose - - `docker-compose up` -4. Edit creds in `/srv/nadeko/conf/creds.yml` -5. Run it again with - - `docker-compose up` -### Updating -- `cd /srv/nadeko` -- `docker-compose pull` -- `docker-compose up -d` +4. **Prepare Your Credentials File:** Before running Docker Compose, ensure the `creds.yml` file exists in the `/opt/stacks/nadekobot/conf/` directory. If it's missing, create it using `touch /opt/stacks/nadekobot/conf/creds.yml`. You may need to use `sudo`. Remember to replace `/opt/stacks/nadekobot/` with your chosen directory. + +5. **Edit Your Credentials File:** Populate the `creds.yml` file in `/opt/stacks/nadekobot/conf/creds.yml` with your bot's credentials. You can use any text editor for this task. For instance, to use the `nano` editor, type `nano /opt/stacks/nadekobot/conf/creds.yml`. You may need to use `sudo`. Again, replace `/opt/stacks/nadekobot/` with your chosen directory. + +6. **Launch Your Bot:** Now, you're ready to run Docker Compose. Use the following command: `docker-compose up -d`. + +## Keeping Your Bot Up-to-Date + +There are two methods to update your NadekoBot: + +### Manual Update + +1. **Navigate to Your Directory:** Use `cd /path/to/your/directory` to go to the directory containing your Docker Compose file. + +2. **Pull the Latest Images:** Use `docker-compose pull` to fetch the latest images. + +3. **Restart Your Containers:** Use `docker-compose up -d` to restart the containers. + +### Automatic Update with Watchtower + +If you prefer an automated update process, consider using Watchtower. Watchtower automatically updates your Docker containers to the latest versions. + +To use Watchtower with NadekoBot, you need to add a specific label to the service in your Docker Compose file. Here's how your Docker Compose file should look: + +```yml +services: + nadeko: + image: registry.gitlab.com/kwoth/nadekobot:latest + container_name: nadeko + restart: unless-stopped + labels: + - com.centurylinklabs.watchtower.enable=true + environment: + TZ: Europe/Rome + volumes: + - /opt/stacks/nadekobot/conf/creds.yml:/app/data/creds.yml + - /opt/stacks/nadekobot/data:/app/data +networks: {} +``` + +Remember to replace `/opt/stacks/nadekobot/` with your chosen directory in the Docker Compose file. + +To install and run Watchtower, follow the guide provided by Containrrr: + +- [Watchtower Installation and Usage Guide](https://containrrr.dev/watchtower/) \ No newline at end of file