I figured out a fix for my problem. It’s a bit of a convoluted, hacky process, but it works. In summary, upgrading to Node.js 20.x.x fixed my issue.
I created a Docker image that uses Node.js v20.x.x instead of the default v18.x.x that the Discourse dev Docker image uses.
I started by creating this Dockerfile
:
# NAME: discourse_node20
FROM discourse/discourse_dev:release
# upgrade node to LTS 20.x.x
ENV NODE_MAJOR=20
RUN apt-get update
RUN apt-get install -y ca-certificates curl gnupg
RUN mkdir -p /etc/apt/keyrings
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
RUN apt-get update
RUN apt-get install nodejs -y
Then I built the image: docker build -t discourse_node20 - < Dockerfile
Then I updated d/boot_dev
’s docker run
command to use the discourse_node20
image and not pull discourse/discourse_dev:release
since it isn’t being used. Here’s that updated command in d/boot_dev
:
# comment the line below out
# docker pull discourse/discourse_dev:release
docker run \
-d \
-p $local_publish:8025:8025 \
-p $local_publish:3000:3000 \
-p $local_publish:4200:4200 \
-p $local_publish:9292:9292 \
-p $local_publish:9405:9405 \
-v "$DATA_DIR:/shared/postgres_data:delegated" \
-v "$SOURCE_DIR:/src:delegated" \
-e UNICORN_BIND_ALL=true \
-e NODE_OPTIONS=--max_old_space_size=8192 \
$mount_plugin_symlinks \
$ENV_ARGS \
--hostname=discourse \
--name=discourse_dev \
--restart=always \
discourse_node20 /sbin/boot
From there I was able to successfully d/boot_dev --init
, d/rails s
, and d/ember-cli
giving me a functioning dev environment in Docker 24 and Fedora 39.
I don’t know why Node 20.x.x fixes the issue. Hopefully this is fixed upstream in the main dev image. I’d be happy to contribute a pull request but upgrading a major dependency seems like something beyond just a drive-by PR by me. Well, at least I’m unblocked for now!