Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
18 changes: 18 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
}
15 changes: 15 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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:
2 changes: 1 addition & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed since the container specifies as RAILS_ENV that would override this. You could instead use RAILS_ENV=test bundle exec rspec, but I can't think of a scenario in which you'd want to run the tests in a non-test ENV 🤷‍♂️


require File.expand_path('../dummy/config/environment', __FILE__)

Expand Down