diff --git a/Dockerfile.bot b/Dockerfile similarity index 71% rename from Dockerfile.bot rename to Dockerfile index 7285db1..11f3b29 100644 --- a/Dockerfile.bot +++ b/Dockerfile @@ -4,8 +4,12 @@ FROM node:alpine RUN apk --no-cache upgrade RUN apk add --no-cache git cmake msttcorefonts-installer python3 alpine-sdk ffmpeg wget rpm2cpio \ zlib-dev libpng-dev libjpeg-turbo-dev freetype-dev fontconfig-dev \ - libtool libwebp-dev libxml2-dev pango-dev freetype fontconfig \ - vips vips-dev grep + libtool libwebp-dev libxml2-dev freetype fontconfig \ + vips vips-dev grep libc6-compat + +# install pnpm +RUN --mount=type=cache,id=pnpm-store,target=/root/.pnpm-store \ + npm install -g pnpm@6.27.1 # gets latest version of twemoji RUN mkdir /tmp/twemoji \ @@ -25,7 +29,7 @@ RUN git clone https://github.com/carlobaldassi/liblqr \ && make install # install imagemagick from source rather than using the package -# since the alpine package does not include pango support. +# since the alpine package does not include liblqr support. RUN git clone https://github.com/ImageMagick/ImageMagick.git ImageMagick \ && cd ImageMagick \ && ./configure \ @@ -54,26 +58,27 @@ COPY ./assets/caption.otf /usr/share/fonts/caption.otf COPY ./assets/caption2.ttf /usr/share/fonts/caption2.ttf COPY ./assets/hbc.ttf /usr/share/fonts/hbc.ttf COPY ./assets/reddit.ttf /usr/share/fonts/reddit.ttf +COPY ./assets/whisper.otf /usr/share/fonts/whisper.otf RUN fc-cache -fv COPY --chown=node:node ./package.json package.json -COPY --chown=node:node ./package-lock.json package-lock.json -RUN npm install +COPY --chown=node:node ./pnpm-lock.yaml pnpm-lock.yaml +RUN pnpm install COPY . . RUN rm .env -RUN npm run build +RUN pnpm run build -RUN mkdir /home/esmBot/help -RUN chown esmBot:esmBot /home/esmBot/help -RUN chmod 666 /home/esmBot/help +RUN mkdir /home/esmBot/help \ + && chown esmBot:esmBot /home/esmBot/help \ + && chmod 777 /home/esmBot/help -RUN mkdir /home/esmBot/temp -RUN chown esmBot:esmBot /home/esmBot/temp -RUN chmod 666 /home/esmBot/temp +RUN mkdir /home/esmBot/temp \ + && chown esmBot:esmBot /home/esmBot/temp \ + && chmod 777 /home/esmBot/temp -RUN mkdir /home/esmBot/.internal/logs -RUN chown esmBot:esmBot /home/esmBot/.internal/logs -RUN chmod 666 /home/esmBot/.internal/logs +RUN mkdir /home/esmBot/.internal/logs \ + && chown esmBot:esmBot /home/esmBot/.internal/logs \ + && chmod 777 /home/esmBot/.internal/logs USER esmBot diff --git a/Dockerfile.api b/Dockerfile.api deleted file mode 100644 index c72080b..0000000 --- a/Dockerfile.api +++ /dev/null @@ -1,60 +0,0 @@ -# Docker/Kubernetes file for running the image API -FROM node:alpine - -RUN apk --no-cache upgrade -RUN apk add --no-cache git cmake msttcorefonts-installer python3 alpine-sdk ffmpeg \ - zlib-dev libpng-dev libjpeg-turbo-dev freetype-dev fontconfig-dev \ - libtool libwebp-dev libxml2-dev pango-dev freetype fontconfig \ - vips vips-dev - -# liblqr needs to be built manually for magick to work -# and because alpine doesn't have it in their repos -RUN git clone https://github.com/carlobaldassi/liblqr \ - && cd liblqr \ - && ./configure \ - && make \ - && make install - -# 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 \ - && ./configure \ - --prefix=/usr \ - --sysconfdir=/etc \ - --mandir=/usr/share/man \ - --infodir=/usr/share/info \ - --enable-static \ - --disable-openmp \ - --with-threads \ - --with-png \ - --with-webp \ - --with-modules \ - --with-pango \ - --without-hdri \ - --with-lqr \ - && make \ - && make install - -RUN update-ms-fonts && fc-cache -f - -RUN adduser esmBot -s /bin/sh -D -WORKDIR /home/esmBot/.internal - -COPY ./assets/caption.otf /usr/share/fonts/caption.otf -COPY ./assets/caption2.ttf /usr/share/fonts/caption2.ttf -COPY ./assets/hbc.ttf /usr/share/fonts/hbc.ttf -COPY ./assets/reddit.ttf /usr/share/fonts/reddit.ttf -RUN fc-cache -fv - -COPY --chown=node:node ./package.json package.json -COPY --chown=node:node ./package-lock.json package-lock.json -RUN npm install -COPY . . -RUN npm run build - -USER esmBot - -EXPOSE 3762 - -ENTRYPOINT ["node", "api/index.js"] diff --git a/api/IMPLEMENTATION.md b/api/IMPLEMENTATION.md index 01fcb4c..6b8a226 100644 --- a/api/IMPLEMENTATION.md +++ b/api/IMPLEMENTATION.md @@ -34,7 +34,7 @@ A client sends *requests* (T-messages) to a server, which subsequently *replies* ### Job Object The job object is formatted like this: -```json +```js { "cmd": string, // name of internal image command, e.g. caption "path": string, // canonical image URL, used for getting the actual image diff --git a/docker-compose.yml b/docker-compose.yml index 3eb8c9b..4d965ee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,6 @@ services: bot: build: context: . - dockerfile: Dockerfile.bot image: esmbot restart: unless-stopped volumes: diff --git a/package.json b/package.json index 3b5fb27..1dca7f3 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,7 @@ }, "scripts": { "build": "cmake-js compile", - "docker:build": "docker build -t esmbot -f Dockerfile.bot .", - "docker:build-api": "docker build -t esmbot-api -f Dockerfile.api .", + "docker:build": "DOCKER_BUILDKIT=1 docker build -t esmbot .", "docker:run-bot": "docker run --rm --network=host esmbot", "docker:run-api": "docker run --rm --network=host esmbot-api", "docker:run-lava": "docker run --rm --network host -v \"$(pwd)\"/application.yml:/opt/Lavalink/application.yml -v \"$(pwd)\"/assets:/opt/Lavalink/assets fredboat/lavalink:dev",