Use the Rails org ruby image in the Rails devcontainer

This commit is contained in:
Andrew Novoselac 2024-03-14 15:16:16 -04:00
parent 5fcbc2c421
commit 7f8e0af2a7
3 changed files with 15 additions and 24 deletions

@ -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

@ -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

@ -9,6 +9,9 @@
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/node:1": {
"version": "latest"
}
},