diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..209e3ef --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +20 diff --git a/Dockerfile b/Dockerfile index 9f2fd55..7fa6032 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/etc/bashrc.sh b/etc/bashrc.sh new file mode 100755 index 0000000..9760d5f --- /dev/null +++ b/etc/bashrc.sh @@ -0,0 +1,5 @@ +# nvm +if [ -a "$HOME/.nvm/nvm.sh" ]; then + export NVM_DIR="$HOME/.nvm" + source "$NVM_DIR/nvm.sh" +fi diff --git a/justfile b/justfile index 46a5c83..dcc0985 100644 --- a/justfile +++ b/justfile @@ -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 }}