Add docker-compose file (#27)
* feat: add docker-compose file * refactor: lower docker-compose version * feat(docker-compose): add help docs and image dir, fix lavalink * fix(docker): missing ffmpeg dependency * fix(docker): compile imagemagick with pango support This fixes commands such as `meme` causing the bot to crash, since Alpine does not have a pango-enabled version of IM7 in its repos. * feat(docker): cache npm dependencies By copying just the `package-(lock).json` and installing dependencies, Docker will cache the deps on subsequent builds. * fix(docker-compose): need to adjust connection addresses The MongoDB and Chrome addresses are automatically passed through with the correct value. A separate `servers.json` file specifically for docker-compose is used with the correct container addresses. Each container has a static ip - this is due to an unfortunate limitation of the Chrome remote debugger, which needs either an IP or `localhost`, and refuses connections to a hostname. * refactor(docker): do not include servers.json for compose Compose will use the normal `servers.json` and users will have to change the hostnames to `lavalink` and `api` respectively.
This commit is contained in:
parent
3deb2b4986
commit
c6b7e6629c
3 changed files with 190 additions and 2 deletions
|
@ -2,14 +2,50 @@
|
|||
|
||||
FROM node:alpine
|
||||
|
||||
RUN apk --no-cache upgrade && apk add --no-cache imagemagick imagemagick-dev git msttcorefonts-installer python3 alpine-sdk
|
||||
RUN apk --no-cache upgrade
|
||||
RUN apk add --no-cache git msttcorefonts-installer python3 alpine-sdk ffmpeg \
|
||||
zlib-dev libpng-dev libjpeg-turbo-dev freetype-dev fontconfig-dev perl-dev \
|
||||
ghostscript-dev libtool tiff-dev lcms2-dev libwebp-dev libxml2-dev libx11-dev \
|
||||
libxext-dev chrpath libheif-dev pango-dev freetype fontconfig ghostscript \
|
||||
ghostscript-fonts lcms2 graphviz
|
||||
|
||||
# install imagemagick from source rather than using the package
|
||||
# since the alpine package does not include pango support.
|
||||
RUN git clone https://github.com/ImageMagick/ImageMagick.git ImageMagick \
|
||||
&& cd ImageMagick \
|
||||
&& git checkout 7.0.10-45 \
|
||||
&& ./configure \
|
||||
--prefix=/usr \
|
||||
--sysconfdir=/etc \
|
||||
--mandir=/usr/share/man \
|
||||
--infodir=/usr/share/info \
|
||||
--enable-static \
|
||||
--disable-openmp \
|
||||
--with-threads \
|
||||
--with-x \
|
||||
--with-tiff \
|
||||
--with-png \
|
||||
--with-webp \
|
||||
--with-gslib \
|
||||
--with-gs-font-dir=/usr/share/fonts/Type1 \
|
||||
--with-heic \
|
||||
--with-modules \
|
||||
--with-xml \
|
||||
--with-perl \
|
||||
--with-perl-options="PREFIX=/usr INSTALLDIRS=vendor" \
|
||||
--with-pango \
|
||||
&& make \
|
||||
&& sudo make install
|
||||
|
||||
RUN update-ms-fonts && fc-cache -f
|
||||
|
||||
RUN adduser esmBot -s /bin/sh -D
|
||||
WORKDIR /home/esmBot/.internal
|
||||
COPY . .
|
||||
|
||||
COPY ./package.json package.json
|
||||
COPY ./package-lock.json package-lock.json
|
||||
RUN npm install
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
USER esmBot
|
||||
|
||||
|
|
51
Dockerfile.bot
Normal file
51
Dockerfile.bot
Normal file
|
@ -0,0 +1,51 @@
|
|||
# Docker/Kubernetes file for running the bot
|
||||
|
||||
FROM node:alpine
|
||||
|
||||
RUN apk --no-cache upgrade
|
||||
RUN apk add --no-cache git msttcorefonts-installer python3 alpine-sdk ffmpeg \
|
||||
zlib-dev libpng-dev libjpeg-turbo-dev freetype-dev fontconfig-dev perl-dev \
|
||||
ghostscript-dev libtool tiff-dev lcms2-dev libwebp-dev libxml2-dev libx11-dev \
|
||||
libxext-dev chrpath libheif-dev pango-dev freetype fontconfig ghostscript \
|
||||
ghostscript-fonts lcms2 graphviz
|
||||
|
||||
# install imagemagick from source rather than using the package
|
||||
# since the alpine package does not include pango support.
|
||||
RUN git clone https://github.com/ImageMagick/ImageMagick.git ImageMagick \
|
||||
&& cd ImageMagick \
|
||||
&& git checkout 7.0.10-45 \
|
||||
&& ./configure \
|
||||
--prefix=/usr \
|
||||
--sysconfdir=/etc \
|
||||
--mandir=/usr/share/man \
|
||||
--infodir=/usr/share/info \
|
||||
--enable-static \
|
||||
--disable-openmp \
|
||||
--with-threads \
|
||||
--with-x \
|
||||
--with-tiff \
|
||||
--with-png \
|
||||
--with-webp \
|
||||
--with-gslib \
|
||||
--with-gs-font-dir=/usr/share/fonts/Type1 \
|
||||
--with-heic \
|
||||
--with-modules \
|
||||
--with-xml \
|
||||
--with-perl \
|
||||
--with-perl-options="PREFIX=/usr INSTALLDIRS=vendor" \
|
||||
--with-pango \
|
||||
&& make \
|
||||
&& sudo make install
|
||||
|
||||
RUN update-ms-fonts && fc-cache -f
|
||||
|
||||
RUN adduser esmBot -s /bin/sh -D
|
||||
WORKDIR /home/esmBot/.internal
|
||||
COPY ./package.json package.json
|
||||
COPY ./package-lock.json package-lock.json
|
||||
RUN npm install
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
USER esmBot
|
||||
|
||||
ENTRYPOINT ["node", "app.js"]
|
101
docker-compose.yml
Normal file
101
docker-compose.yml
Normal file
|
@ -0,0 +1,101 @@
|
|||
version: '3.0'
|
||||
|
||||
services:
|
||||
bot:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.bot
|
||||
image: esmbot
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./logs:/home/esmBot/.internal/logs
|
||||
- bot-output:/home/esmBot/output
|
||||
- bot-temp:/home/esmBot/temp
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
OUTPUT: /home/esmBot/help
|
||||
TEMPDIR: /home/esmBot/temp
|
||||
|
||||
MONGO: mongodb://mongo:27017/esmBot
|
||||
# chrome remote debugger can only be accessed over localhost or IP
|
||||
CHROME: 172.20.0.4:9222
|
||||
links:
|
||||
- lavalink
|
||||
- chrome
|
||||
depends_on:
|
||||
- api
|
||||
- chrome
|
||||
- lavalink
|
||||
- mongo
|
||||
|
||||
networks:
|
||||
esmbot:
|
||||
ipv4_address: 172.20.0.2
|
||||
|
||||
|
||||
api:
|
||||
container_name: api
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile.api
|
||||
image: esmbot-api
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
esmbot:
|
||||
ipv4_address: 172.20.0.3
|
||||
|
||||
chrome:
|
||||
container_name: chrome
|
||||
build:
|
||||
context: ./utils/screenshot
|
||||
image: headless-chrome-alpine
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
esmbot:
|
||||
ipv4_address: 172.20.0.4
|
||||
|
||||
lavalink:
|
||||
container_name: lavalink
|
||||
image: fredboat/lavalink:dev
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./application.yml:/opt/Lavalink/application.yml
|
||||
- ./assets:/opt/Lavalink/assets
|
||||
networks:
|
||||
esmbot:
|
||||
ipv4_address: 172.20.0.5
|
||||
|
||||
mongo:
|
||||
container_name: mongo
|
||||
image: mongo:latest
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- mongo-data:/data/db
|
||||
networks:
|
||||
esmbot:
|
||||
ipv4_address: 172.20.0.6
|
||||
|
||||
mongo-express:
|
||||
image: mongo-express
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- mongo
|
||||
ports:
|
||||
- 8888:8081
|
||||
networks:
|
||||
esmbot:
|
||||
ipv4_address: 172.20.0.7
|
||||
|
||||
volumes:
|
||||
bot-output:
|
||||
bot-temp:
|
||||
mongo-data:
|
||||
|
||||
networks:
|
||||
esmbot:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.20.0.0/24
|
||||
gateway: 172.20.0.1
|
Loading…
Reference in a new issue