From b4ac3e9bf20bb7a19e7b2005aadb3b2b662a4340 Mon Sep 17 00:00:00 2001 From: Kieran Eglin Date: Fri, 8 Aug 2025 10:33:44 -0700 Subject: [PATCH 1/2] Added devcontainer manifest --- .devcontainer/Dockerfile | 38 ++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 18 +++++++++++++++ .devcontainer/docker-compose.yml | 15 +++++++++++++ spec/rails_helper.rb | 2 +- 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..157b88cf --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,38 @@ +# Use the official Ruby image as base +FROM ruby:3.3-slim + +# Install system dependencies +RUN apt-get update -qq && apt-get install -y \ + build-essential \ + git \ + curl \ + sqlite3 \ + libsqlite3-dev \ + libyaml-dev \ + && rm -rf /var/lib/apt/lists/* + +# Install Node.js (for documentation site) +RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - \ + && apt-get install -y nodejs + +# Create a non-root user +RUN groupadd --gid 1000 user \ + && useradd --uid 1000 --gid user --shell /bin/bash --create-home user + +# Set up the working directory +WORKDIR /workspace + +# Install bundler +RUN gem install bundler + +# Create cache directory for gems +RUN mkdir -p /usr/local/bundle && chown -R user:user /usr/local/bundle + +# Switch to non-root user +USER user + +# Set up git config (helps with development) +RUN git config --global init.defaultBranch main + +# Set the default shell +SHELL ["/bin/bash", "-c"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..7a8f87ac --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,18 @@ +{ + "name": "Inertia Rails Development", + "dockerComposeFile": "docker-compose.yml", + "service": "app", + "workspaceFolder": "/workspace", + "customizations": { + "vscode": { + "extensions": [ + "shopify.ruby-lsp", + "ms-vscode.vscode-json", + "redhat.vscode-yaml" + ] + } + }, + "forwardPorts": [3000, 5173], + "postCreateCommand": "bin/setup", + "remoteUser": "user" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 00000000..38c20171 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,15 @@ +services: + app: + build: + context: .. + dockerfile: .devcontainer/Dockerfile + volumes: + - ..:/workspace:cached + - gem_cache:/usr/local/bundle + command: sleep infinity + environment: + - RAILS_ENV=development + working_dir: /workspace + +volumes: + gem_cache: diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 03e1f42e..484b2a55 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -2,7 +2,7 @@ # Requiring logger fixes an issue between concurrent-ruby and activesupport in Rails < 7.1 # https://github.com/rails/rails/issues/54260 require 'logger' -ENV['RAILS_ENV'] ||= 'test' +ENV['RAILS_ENV'] = 'test' require File.expand_path('../dummy/config/environment', __FILE__) From 3f4c09d41270d04603406bde1442e8e777390848 Mon Sep 17 00:00:00 2001 From: Kieran Eglin Date: Fri, 8 Aug 2025 11:10:53 -0700 Subject: [PATCH 2/2] Removed irrelevant section of Dockerfile --- .devcontainer/Dockerfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 157b88cf..11244213 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -31,8 +31,5 @@ RUN mkdir -p /usr/local/bundle && chown -R user:user /usr/local/bundle # Switch to non-root user USER user -# Set up git config (helps with development) -RUN git config --global init.defaultBranch main - # Set the default shell SHELL ["/bin/bash", "-c"]