Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node 20, OS base image, ESM, Chromium, and dependency upgrades #382

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
module.exports = {
root: true,
env: {
node: true
node: true,
es2023: true,
},
extends: [
'airbnb-base',
'plugin:@typescript-eslint/recommended',
'airbnb-typescript/base',
'plugin:prettier/recommended',
'plugin:import/recommended',
'plugin:import/typescript',
'plugin:@typescript-eslint/recommended',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
sourceType: 'module'
sourceType: 'module',
},
rules: {
'import/extensions': 0,
'import/prefer-default-export': 0,
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],
},
ignorePatterns: ['dist/**', 'node_modules/**', '**/*.config.js', '.eslintrc.js', 'docs/**'],
}
ignorePatterns: ['dist', 'node_modules', '!.*.cjs', 'docs/**'],
};
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
4 changes: 4 additions & 0 deletions .prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
printWidth: 100,
singleQuote: true,
};
4 changes: 0 additions & 4 deletions .prettierrc.js

This file was deleted.

8 changes: 3 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
"type": "node",
"request": "launch",
"name": "Debug Main",
"runtimeArgs": [
"-r",
"ts-node/register"
],
"autoAttachChildProcesses": true,
"program": "${workspaceRoot}/node_modules/vite-node/dist/cli.mjs",
"args": [
"${workspaceFolder}/src/index.ts"
],
"outputCapture": "std",
"console": "integratedTerminal"
}
},
]
}
17 changes: 7 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
########
# BASE
########
FROM node:18-alpine3.17 as base
FROM node:20-alpine3.19 as base

ENV DISTRO=alpine
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
Expand All @@ -13,15 +13,12 @@ WORKDIR /usr/app
########
FROM base as deps

# Go to https://hub.docker.com/_/node/ and note the latest stable Alpine version available (e.g. alpine3.17).
# Go to https://pkgs.alpinelinux.org/package/v3.17/community/x86_64/chromium (replace with the latest Alpine version)
# and note the Chromium version available. Then go to https://github.com/puppeteer/puppeteer/releases?q=chromium&expanded=true
# and find the latest puppeteer version that supports that Chromium version, and update it in the package.json.
# Go to https://hub.docker.com/_/node/ and note the latest stable Alpine version available (e.g. alpine3.19).
# Go to https://pkgs.alpinelinux.org/package/v3.19/community/x86_64/chromium (replace with the latest Alpine version)
# and note the Chromium version available. Then go to https://pptr.dev/chromium-support
# and find the latest version that supports that Chromium version, and update it in the package.json.
RUN apk add --no-cache \
'chromium=~112' \
nss \
freetype \
harfbuzz \
'chromium=~121' \
ca-certificates \
ttf-freefont \
# App dependencies
Expand Down Expand Up @@ -74,7 +71,7 @@ LABEL org.opencontainers.image.title="epicgames-freegames-node" \
org.opencontainers.image.name="epicgames-freegames-node" \
org.opencontainers.image.revision=${COMMIT_SHA} \
org.opencontainers.image.ref.name=${BRANCH} \
org.opencontainers.image.base.name="node:18-alpine3.17" \
org.opencontainers.image.base.name="node:20-alpine3.19" \
org.opencontainers.image.version="latest"

ENV NODE_ENV=production \
Expand Down
7 changes: 3 additions & 4 deletions Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
########
# BASE
########
FROM node:18-bullseye-slim as base
FROM node:20-bookworm-slim as base

ENV DISTRO=debian
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
Expand All @@ -13,7 +13,6 @@ WORKDIR /usr/app
########
FROM base as deps

# Chromium dependencies https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-in-docker
# The Google Chrome apt list only seems to provide the latest version, so version compatibility with puppeteer is questionable
RUN apt-get update \
&& apt-get install -y wget gnupg procps \
Expand Down Expand Up @@ -77,8 +76,8 @@ LABEL org.opencontainers.image.title="epicgames-freegames-node" \
org.opencontainers.image.name="epicgames-freegames-node" \
org.opencontainers.image.revision=${COMMIT_SHA} \
org.opencontainers.image.ref.name=${BRANCH} \
org.opencontainers.image.base.name="node:18-bullseye-slim" \
org.opencontainers.image.version="bullseye-slim"
org.opencontainers.image.base.name="node:20-bookworm-slim" \
org.opencontainers.image.version="debian"

ENV NODE_ENV=production \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome-stable \
Expand Down
6 changes: 3 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ This image is available from both [GitHub Container Registry](https://github.com

If you're [experiencing issues with Chromium starting](https://github.com/claabs/epicgames-freegames-node/issues/164) (hangs on login/notification), you can try the Debian image:

* `ghcr.io/claabs/epicgames-freegames-node:bullseye-slim`
* `charlocharlie/epicgames-freegames:bullseye-slim`
* `ghcr.io/claabs/epicgames-freegames-node:debian`
* `charlocharlie/epicgames-freegames:debian`

If you are using full JSON configuration, the only remaining Docker configurables are the [port](#ports) and [volume](#volumes).

Expand Down Expand Up @@ -225,7 +225,7 @@ If for some reason you don't want to use Docker to run this tool you can run it
* Or download and unpack ZIP archive: [epicgames-freegames-node](https://github.com/claabs/epicgames-freegames-node/archive/master.zip)
1. Create `config` folder in the cloned/unpacked directory
1. Create [JSON configuration](#json-configuration)
1. [Install Node.js 18](https://nodejs.org/) or higher
1. [Install Node.js 20](https://nodejs.org/) or higher
1. Install Node.js dependencies
* Start terminal and navigate to cloned/unpacked directory
* Run `npm i`
Expand Down
8 changes: 4 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
TEMP_CONFIG="/tmp/config.json"

# Resolve and output the below variables to /tmp/config.json
npm run entrypoint-config
node --enable-source-maps /usr/app/dist/src/entrypoint-config.js
TZ=$(cat $TEMP_CONFIG | jq -r ".timezone")
RUN_ON_STARTUP=$(cat $TEMP_CONFIG | jq -r ".runOnStartup")
RUN_ONCE=$(cat $TEMP_CONFIG | jq -r ".runOnce")
Expand All @@ -18,7 +18,7 @@ echo "$TZ" > /etc/timezone
# If runOnStartup is set, run it once before setting up the schedule
echo "Run on startup: ${RUN_ON_STARTUP}"
if [ "$RUN_ON_STARTUP" = "true" ]; then
node /usr/app/dist/src/index.js
node --enable-source-maps /usr/app/dist/src/index.js
fi

# If runOnce is not set, schedule the process
Expand All @@ -27,14 +27,14 @@ if [ "$RUN_ONCE" = "false" ]; then
echo "Setting cron schedule as ${CRON_SCHEDULE}"
if [ "$DISTRO" = "alpine" ]; then
# Add the command to the crontab
echo "${CRON_SCHEDULE} cd /usr/app && node /usr/app/dist/src/index.js" | crontab -
echo "${CRON_SCHEDULE} cd /usr/app && node --enable-source-maps /usr/app/dist/src/index.js" | crontab -
# Run the cron process. The container should halt here and wait for the schedule.
/usr/sbin/crond -f -l 8
else
# Debian cron wipes the environment, so we save it to a script to load in cron
printenv | sed 's/^\(.*\)$/export \1/g' > /root/project_env.sh
# Add the command to the crontab. Debian cron doesn't ensure single instance, so we use flock to ensure it
echo "${CRON_SCHEDULE} . /root/project_env.sh && cd /usr/app && flock -n /var/lock/epicgames.lock node /usr/app/dist/src/index.js > /proc/1/fd/1 2>/proc/1/fd/2" | crontab -
echo "${CRON_SCHEDULE} . /root/project_env.sh && cd /usr/app && flock -n /var/lock/epicgames.lock node --enable-source-maps /usr/app/dist/src/index.js > /proc/1/fd/1 2>/proc/1/fd/2" | crontab -
# Run the cron process. The container should halt here and wait for the schedule.
cron -f
fi
Expand Down
Loading
Loading