Use nvm to install Node rather than deprecated nodesource scripts

This commit is contained in:
Jake Howard 2023-10-27 17:37:58 +01:00
parent 366dc6a123
commit c3aea8f176
Signed by: jake
GPG Key ID: 57AFB45680EDD477
4 changed files with 15 additions and 3 deletions

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
20

View File

@ -51,6 +51,8 @@ COPY --chown=website ./etc ./etc
COPY --chown=website ./manage.py ./manage.py
COPY --chown=website ./website ./website
RUN cat ./etc/bashrc.sh >> ~/.bashrc
RUN SECRET_KEY=none python manage.py collectstatic --noinput --clear
CMD ["/app/etc/entrypoints/web"]
@ -58,10 +60,14 @@ CMD ["/app/etc/entrypoints/web"]
# Just dev stuff
FROM production as dev
COPY --chown=website .nvmrc ./
RUN curl https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash \
&& bash --login -c "nvm install --no-progress && nvm alias default $(nvm run --silent --version)"
# Swap user, so the following tasks can be run as root
USER root
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs
RUN apt-get install -y postgresql-client inotify-tools
RUN apt-get update --yes --quiet && apt-get install -y postgresql-client inotify-tools
RUN curl -sSf https://just.systems/install.sh | bash -s -- --to /usr/bin
# Restore user

5
etc/bashrc.sh Executable file
View File

@ -0,0 +1,5 @@
# nvm
if [ -a "$HOME/.nvm/nvm.sh" ]; then
export NVM_DIR="$HOME/.nvm"
source "$NVM_DIR/nvm.sh"
fi

View File

@ -9,7 +9,7 @@ DEV_COMPOSE := justfile_directory() + "/docker/dev/docker-compose.yml"
build:
docker-compose -f {{ DEV_COMPOSE }} pull
docker-compose -f {{ DEV_COMPOSE }} build
docker-compose -f {{ DEV_COMPOSE }} run --rm --no-deps web npm ci
docker-compose -f {{ DEV_COMPOSE }} run --rm --no-deps web bash -lc "npm ci"
@compose +ARGS:
docker-compose -f {{ DEV_COMPOSE }} {{ ARGS }}