Skip to content

Commit

Permalink
chore(node): Upgrade to node lts (#5394)
Browse files Browse the repository at this point in the history
Upgrading the docker build and nvm to node 20.18, which is the latest
supported, stable LTS version. Node 12 and 16 have been EoL since April,
2022 and August, 2023, respectively. In addition, a transitive
dependency of mjml, minimatch, is not compatible with anything less than
node 14 at this point, so email generation from templates was broken.
With the move to newer node, I had to deal with a new node/docker
restriction which won't allow you to `npm install` in the root
directory. I wanted to maintain backwards compatiblity with current
installs and their MJML_PATH parameter, so I worked around the problem
by installing mjml in another directory and then moving node_modules to
the root directory. It's not pretty, but it worked. I'm trying to run
tests locally and I get one failure, but I'm not sure if it's my setup
or something I need to correct. I've manually tested the setup, gone
into every page, and not experienced problems.

Co-authored-by: Marc Vilanova <[email protected]>
  • Loading branch information
bashbreakpoint and mvilanova authored Oct 31, 2024
1 parent 053723e commit c87f545
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.13.0
20.18.0
20 changes: 17 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
wget \
&& rm -rf /var/lib/apt/lists/*

RUN wget --quiet -O - https://deb.nodesource.com/setup_16.x | bash - \
RUN wget --quiet -O - https://deb.nodesource.com/setup_20.x | bash - \
&& apt-get install -y nodejs --no-install-recommends

ARG SOURCE_COMMIT
Expand Down Expand Up @@ -87,7 +87,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
RUN echo "deb http://apt.postgresql.org/pub/repos/apt bullseye-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -

RUN wget --quiet -O - https://deb.nodesource.com/setup_12.x | bash -
RUN wget --quiet -O - https://deb.nodesource.com/setup_20.x | bash -

COPY --from=sdist /dist/*.whl /tmp/dist/
RUN buildDeps="" \
Expand All @@ -104,7 +104,21 @@ RUN buildDeps="" \
pkg-config postgresql-client-14 nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& npm install mjml --no-cache-dir
# mjml has to be installed differently here because
# after node 14, docker will install npm files at the
# root directoy and fail, so we have to create a new
# directory and use it for the install then copy the
# files to the root directory to maintain backwards
# compatibility for email generation
&& mkdir -p /mjml_install \
# if our workdir is /, then pushd/popd doesn't work
# for the npm install. It still tries to install in /,
# which npm can't do
&& cd /mjml_install \
&& npm install --no-cache-dir mjml \
&& mv node_modules / \
&& cd / \
&& rm -rf /mjml_install

EXPOSE 8000
VOLUME /var/lib/dispatch/files
Expand Down

0 comments on commit c87f545

Please sign in to comment.