Skip to content

Commit

Permalink
Merge pull request #232 from Mirasaki/223-leaderboard-name-of-gameser…
Browse files Browse the repository at this point in the history
…ver-instead-of-guildname

Docker update
  • Loading branch information
Mirasaki authored Mar 12, 2024
2 parents b3f7904 + 603312b commit 544f62c
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 155 deletions.
59 changes: 59 additions & 0 deletions .devcontainer/arm64.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
FROM arm64v8/node:20-slim

# Please refer to https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-in-docker
# for more information on running puppeteer in docker

# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
# installs, work.
RUN apt-get update \
&& apt-get install -y wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

# If running Docker >= 1.13.0 use docker run's --init arg to reap zombie processes, otherwise
# uncomment the following lines to have `dumb-init` as PID 1
# ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_x86_64 /usr/local/bin/dumb-init
# RUN chmod +x /usr/local/bin/dumb-init
# ENTRYPOINT ["dumb-init", "--"]

# Uncomment to skip the chromium download when installing puppeteer. If you do,
# you'll need to launch puppeteer with:
# browser.launch({executablePath: 'google-chrome-stable'})
# ENV PUPPETEER_SKIP_DOWNLOAD true

# Create app/working/bot directory
RUN mkdir -p /app
WORKDIR /app

# Install app production dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
RUN npm ci --omit=dev

# Install puppeteer so it's available in the container.
# Add user so we don't need --no-sandbox.
# same layer as npm install to keep re-chowned files from using up several hundred MBs more space
RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
&& mkdir -p /home/pptruser/Downloads \
&& chown -R pptruser:pptruser /home/pptruser \
&& chown -R pptruser:pptruser /app/node_modules \
&& chown -R pptruser:pptruser /app/package.json \
&& chown -R pptruser:pptruser /app/package-lock.json

# Run everything after as non-privileged user.
USER pptruser

# Bundle app source
COPY . ./

# Optional API/Backend port
EXPOSE 3000

# Run the start command
CMD [ "npm", "run", "start" ]
18 changes: 11 additions & 7 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Config
.env
*.env
.env.example
Procfile
release.config.js

Expand All @@ -11,6 +12,7 @@ npm-debug.log

# Ignoring all markdown files
*.md
tutorials

# Github
.git
Expand All @@ -23,15 +25,17 @@ npm-debug.log
Dockerfile
*.Dockerfile
docker-compose.yml
*.docker-compose.yml
.dockerignore

# Linter files
.markdownlint.json
.eslintrc.json

# Etc
LICENSE
linter-output.txt
.env.example
# .config.example.js used as fallback in test script
tsconfig.json # Only used to generate types in development
typings.d.ts # exported typings file

# Only used to generate types in development
tsconfig.json
# Exported typings file
typings.d.ts
# README static files
assets/showcase
43 changes: 33 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
FROM node:19
FROM node:20-slim

# Docker Puppeteer reference:
# https://pptr.dev/guides/docker
# https://github.com/puppeteer/puppeteer/blob/main/docker/Dockerfile
# Please refer to https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-in-docker
# for more information on running puppeteer in docker

# Install latest chrome dev package and fonts to support major charsets (Chinese, Japanese, Arabic, Hebrew, Thai and a few others)
# Note: this installs the necessary libs to make the bundled version of Chrome that Puppeteer
# Note: this installs the necessary libs to make the bundled version of Chromium that Puppeteer
# installs, work.
RUN apt-get update --no-install-recommends\
&& apt-get install -y --no-install-recommends wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/googlechrome-linux-keyring.gpg \
&& sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/googlechrome-linux-keyring.gpg] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
RUN apt-get update \
&& apt-get install -y wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \
&& apt-get update \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-khmeros fonts-kacst fonts-freefont-ttf libxss1 \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*

# If running Docker >= 1.13.0 use docker run's --init arg to reap zombie processes, otherwise
# uncomment the following lines to have `dumb-init` as PID 1
# ADD https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_x86_64 /usr/local/bin/dumb-init
# RUN chmod +x /usr/local/bin/dumb-init
# ENTRYPOINT ["dumb-init", "--"]

# Uncomment to skip the chromium download when installing puppeteer. If you do,
# you'll need to launch puppeteer with:
# browser.launch({executablePath: 'google-chrome-stable'})
# ENV PUPPETEER_SKIP_DOWNLOAD true

# Create app/working/bot directory
RUN mkdir -p /app
WORKDIR /app
Expand All @@ -26,6 +36,19 @@ WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev

# Install puppeteer so it's available in the container.
# Add user so we don't need --no-sandbox.
# same layer as npm install to keep re-chowned files from using up several hundred MBs more space
RUN groupadd -r pptruser && useradd -r -g pptruser -G audio,video pptruser \
&& mkdir -p /home/pptruser/Downloads \
&& chown -R pptruser:pptruser /home/pptruser \
&& chown -R pptruser:pptruser /app/node_modules \
&& chown -R pptruser:pptruser /app/package.json \
&& chown -R pptruser:pptruser /app/package-lock.json

# Run everything after as non-privileged user.
USER pptruser

# Bundle app source
COPY . ./

Expand Down
26 changes: 18 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,23 @@ version: '3.1'

services:
client:
build: .
container_name: client
restart: always
container_name: cftools-discord-bot
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
volumes:
# Bind mount, read-only app
- ./:/app:ro
# Anonymous volume
- /app/node_modules
- ./config/config.js:/app/config/config.js
- ./config/servers.js:/app/config/servers.js
- ./cftools-discord-bot.db:/app/cftools-discord-bot.db
env_file:
- ./config/.env
- config/.env

puppeteer:
container_name: cftools-discord-bot-puppeteer
image: buildkite/puppeteer
restart: unless-stopped
volumes:
- ./cftools-discord-bot.db:/app/cftools-discord-bot.db
env_file:
- config/.env
Loading

0 comments on commit 544f62c

Please sign in to comment.