Skip to content

Commit

Permalink
Use the Rails org ruby image in the Rails devcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewn617 committed Mar 22, 2024
1 parent 83f997f commit b2befc2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 24 deletions.
32 changes: 10 additions & 22 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

4 changes: 2 additions & 2 deletions .devcontainer/boot.sh
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/node:1": {
"version": "latest"
}
},

Expand Down

0 comments on commit b2befc2

Please sign in to comment.