diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..1124421 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,35 @@ +# 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 the default shell +SHELL ["/bin/bash", "-c"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..7a8f87a --- /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 0000000..38c2017 --- /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 03e1f42..484b2a5 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__)