From 7f8e0af2a73e8ad94505eba1bee308ecf71d02e4 Mon Sep 17 00:00:00 2001 From: Andrew Novoselac Date: Thu, 14 Mar 2024 15:16:16 -0400 Subject: [PATCH] Use the Rails org ruby image in the Rails devcontainer --- .devcontainer/Dockerfile | 32 ++++++++++---------------------- .devcontainer/boot.sh | 4 ++-- .devcontainer/devcontainer.json | 3 +++ 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9827210127b..a1bfb44d6a2 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,31 +1,16 @@ # See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.191.1/containers/ruby/.devcontainer/base.Dockerfile # [Choice] Ruby version: 3, 3.3, 3.2, 3.1, 3.0, 2, 2.7, 2.6 -ARG VARIANT="3.3" -FROM mcr.microsoft.com/devcontainers/ruby:${VARIANT} - -# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 -ARG NODE_VERSION="lts/*" -RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi +ARG VARIANT="3.3.0" +FROM ghcr.io/rails/devcontainer/images/ruby:${VARIANT} # [Optional] Uncomment this section to install additional OS packages. RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ && apt-get -y install --no-install-recommends \ mariadb-client libmariadb-dev \ postgresql-client postgresql-contrib libpq-dev \ - ffmpeg mupdf mupdf-tools libvips poppler-utils - - -ARG IMAGEMAGICK_VERSION="7.1.0-5" -RUN wget -qO /tmp/im.tar.xz https://imagemagick.org/archive/releases/ImageMagick-$IMAGEMAGICK_VERSION.tar.xz \ - && wget -qO /tmp/im.sig https://imagemagick.org/archive/releases/ImageMagick-$IMAGEMAGICK_VERSION.tar.xz.asc \ - && gpg --batch --keyserver keyserver.ubuntu.com --recv 89AB63D48277377A \ - && gpg --batch --verify /tmp/im.sig /tmp/im.tar.xz \ - && tar xJf /tmp/im.tar.xz -C /tmp \ - && cd /tmp/ImageMagick-$IMAGEMAGICK_VERSION \ - && ./configure --with-rsvg && make -j 9 && make install \ - && ldconfig /usr/local/lib \ - && rm -rf /tmp/* + ffmpeg mupdf mupdf-tools libvips-dev poppler-utils \ + libxml2-dev sqlite3 imagemagick # Add the Rails main Gemfile and install the gems. This means the gem install can be done # during build instead of on start. When a fork or branch has different gems, we still have an @@ -44,8 +29,11 @@ COPY activerecord/activerecord.gemspec /tmp/rails/activerecord/ COPY activestorage/activestorage.gemspec /tmp/rails/activestorage/ COPY activesupport/activesupport.gemspec /tmp/rails/activesupport/ COPY railties/railties.gemspec /tmp/rails/railties/ +# Docker does not support COPY as users other than root. So we need to chown this dir so we +# can bundle as vscode user and then remove the tmp dir +RUN chown -R vscode:vscode /tmp/rails +USER vscode RUN cd /tmp/rails \ - && bundle install \ - && yarn install \ + && /home/vscode/.rbenv/shims/bundle install \ && rm -rf /tmp/rails -RUN chown -R vscode:vscode /usr/local/rvm + diff --git a/.devcontainer/boot.sh b/.devcontainer/boot.sh index 6491c5797f1..e3f703c3fa8 100755 --- a/.devcontainer/boot.sh +++ b/.devcontainer/boot.sh @@ -1,7 +1,7 @@ bundle install -yarn install -sudo chown -R vscode:vscode /usr/local/bundle +. ${NVM_DIR}/nvm.sh && nvm install --lts +yarn install cd activerecord diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index e30a9cdc9d9..9983e167ea6 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,6 +9,9 @@ "features": { "ghcr.io/devcontainers/features/github-cli:1": { "version": "latest" + }, + "ghcr.io/devcontainers/features/node:1": { + "version": "latest" } },