Skip to content
Snippets Groups Projects
README.md 4.82 KiB
Newer Older
Griefed's avatar
Griefed committed
# docker-D-Zone
Griefed's avatar
Griefed committed
https://github.com/d-zone-org/d-zone/tree/heroku in a container!
Griefed's avatar
Griefed committed

Griefed's avatar
Griefed committed
![Docker Pulls](https://img.shields.io/docker/pulls/griefed/d-zone?style=flat-square)
![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/griefed/d-zone?label=Image%20size&sort=date&style=flat-square)
![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/griefed/d-zone?label=Docker%20build&style=flat-square)
![Docker Cloud Automated build](https://img.shields.io/docker/cloud/automated/griefed/d-zone?label=Docker%20build&style=flat-square)
![GitHub Repo stars](https://img.shields.io/github/stars/Griefed/docker-D-Zone?label=GitHub%20Stars&style=social)
![GitHub forks](https://img.shields.io/github/forks/Griefed/docker-D-Zone?label=GitHub%20Forks&style=social)

Griefed's avatar
Griefed committed
Creates a Container which runs the heroku branch of [D-Zone-Org's](https://github.com/d-zone-org) [D-Zone](https://github.com/d-zone-org/d-zone), with [node:8-alpine](https://hub.docker.com/_/node) as the base image, as seen on https://pixelatomy.com/dzone/?s=default. 
Griefed's avatar
Griefed committed

# Deploy with docker-compose:
```
  d-zone:
    container_name: d-zone
    image: griefed/d-zone
    restart: unless-stopped
    ports:
      - 3000:3000
    environment:
      - TOKEN=<YOUR_BOT_TOKEN_HERE>
```
### Deploy on Rasbperry Pi
Using the Dockerfile, this container can be built and run on a Raspberry Pi, too! I've tested it on a Raspberry Pi 3B+.
Griefed's avatar
Griefed committed
Simply put the Dockerfile in a directory called `d-zone` 
```
FROM node:8-alpine

LABEL   maintainer="Griefed <griefed@griefed.de>"
LABEL   description="Based on https://github.com/d-zone-org/d-zone/tree/v1/docker \
but pulls files from GitHub instead of copying from local filesystem. \
You must set your bot token as an environment variable and your bot must be \
a member of at least one server for this to work."


RUN     apk update && apk upgrade && apk add git && apk add nano                        && \
        git clone -b v1/docker https://github.com/d-zone-org/d-zone.git /opt/d-zone     && \
        cd /opt/d-zone                                                                  && \
        npm install                                                                     && \
        npm run-script build                                                            && \
        apk del git

WORKDIR /opt/d-zone

CMD ["npm","start"]
```
in the same directory as your docker-compose.yml, edit your docker-compose.yml:
Griefed's avatar
Griefed committed
```
  d-zone:
    container_name: d-zone
    build: ./d-zone/
    restart: unless-stopped
    ports:
      - 3000:3000
    environment:
      - TOKEN=<YOUR_BOT_TOKEN_HERE>
```
Then build with:
```
docker-compose up -d --build d-zone
```
Griefed's avatar
Griefed committed

## Note:
D-Zone will, by default, listen to all channels on the servers which your bot is connected to. If you want to set ignoreChannels, you need to edit a file in your D-Zone container:

- docker exec into the container: `docker exec -it d-zone /bin/sh`
- Open discord-config.json in NANO: `nano discord-config.json`
- Edit the "servers" block on a per server basis, e.g.:
```
  "servers": [
    {
      "id": "<YOUR_SERVER_ID_HERE",
      "default": true,
      "ignoreChannels": ["TEXTCHANNEL_ID1","TEXTCHANNEL_ID2","TEXTCHANNEL_ID3"]
    }
  ]
```
`CTRL+X` followed by `Y` followed by `ENTER` to safe and quit NANO. Enter `exit` to leave the container and restart the container with `docker restart d-zone`. 
This tutorial assumes that your bot is only a member of one server. If you want to define multiple server, see https://github.com/d-zone-org/d-zone/blob/master/discord-config-example.json

Griefed's avatar
Griefed committed
You may also need to exec into the container in order to edit your socket-config.json and change the port D-Zone runs on. The `heroku` branch seems to default to port 0, which, of couse, doesn't work. For the example below to function, you need to change the port to `3000`. 
Griefed's avatar
Griefed committed

Griefed's avatar
Griefed committed
### Note 2

Griefed's avatar
Griefed committed
I use a dockerized nginx as a reverse proxy, specifically https://hub.docker.com/r/linuxserver/swag.
Griefed's avatar
Griefed committed
If you want to serve d-zone with a reverse proxy like nginx and HTTPS, then this may be of help to you:
```
  d-zone:
    container_name: d-zone
    image: griefed/d-zone
    restart: unless-stopped
    environment:
      - TOKEN=<YOUR_BOT_TOKEN_HERE>
```
Griefed's avatar
Griefed committed
```
server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name YOUR_SUBDOMAIN_HERE.*;

    include /config/nginx/ssl.conf;

    client_max_body_size 0;

    location / {
        include /config/nginx/proxy.conf;
        resolver 127.0.0.11 valid=30s;
        proxy_set_header HOST $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass_request_headers on;
Griefed's avatar
Griefed committed
        proxy_pass http://d-zone:3000;
Griefed's avatar
Griefed committed
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }
}
```
Griefed's avatar
Griefed committed

Griefed's avatar
Griefed committed
![d-zone](https://i.imgur.com/uCd6eRa.png)