Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
ebf9d17
Update Ruby version to 4.0 and adjust related documentation
sireeshajonnalagadda Feb 12, 2026
511611c
Add network check for rubygems.org accessibility in test script
sireeshajonnalagadda Feb 13, 2026
542e4fd
Improve network check for rubygems.org accessibility with retries and…
sireeshajonnalagadda Feb 13, 2026
b94a895
Merge branch 'main' into ruby-4.0
sireeshajonnalagadda Feb 17, 2026
592dc51
Refactor gem installation check to use built-in bundler instead of ex…
sireeshajonnalagadda Feb 18, 2026
968d8cd
Add support for ruby 4.0
sireeshajonnalagadda Feb 18, 2026
2f15806
Fix ruby-rails-postgres template option default
sireeshajonnalagadda Feb 18, 2026
0313fd6
Fix ruby template option default
sireeshajonnalagadda Feb 18, 2026
85a5f50
Update Ruby version in README and devcontainer configuration to 4.0-t…
sireeshajonnalagadda Feb 19, 2026
8d4e7c3
Enhance Docker networking
sireeshajonnalagadda Feb 20, 2026
81b83cf
Refactor Docker Compose configuration for improved readability
sireeshajonnalagadda Feb 20, 2026
448d9e8
Merge branch 'main' into ruby-4.0
sireeshajonnalagadda Feb 20, 2026
d7bb100
Update PostgreSQL image to latest and adjust volume path for data per…
sireeshajonnalagadda Feb 20, 2026
52634c6
Update PostgreSQL image to latest and adjust volume path for data per…
sireeshajonnalagadda Feb 20, 2026
0ef56b9
addressing review comments
sireeshajonnalagadda Feb 23, 2026
c68767e
addressing review comments
sireeshajonnalagadda Feb 23, 2026
13aebcc
Update gem presence check for Bundler
sireeshajonnalagadda Feb 24, 2026
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
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"image": "mcr.microsoft.com/devcontainers/javascript-node:4-24-trixie",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"moby":"false"
"moby": "false"
}
},
"postCreateCommand": "npm install -g @devcontainers/cli",
Expand Down
2 changes: 1 addition & 1 deletion src/ruby-rails-postgres/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/devcontainers/ruby:2-${templateOption:imageVariant}
FROM mcr.microsoft.com/devcontainers/ruby:3-${templateOption:imageVariant}

# Install Rails
RUN su vscode -c "gem install rails webdrivers"
Expand Down
40 changes: 36 additions & 4 deletions src/ruby-rails-postgres/.devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
version: '3'
# Dev Container Docker Compose Configuration for Ruby on Rails with PostgreSQL
# This configuration has been optimized for reliability in automated and remote environments

services:
app:
Expand All @@ -12,17 +13,38 @@ services:
# Overrides default command so things don't shut down after the process ends.
command: sleep infinity

# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:db
# Database connection string for Rails applications
# Provides a standard way to connect to the PostgreSQL database
environment:
DATABASE_URL: "postgresql://postgres:postgres@db:5432/postgres"

# IMPORTANT: Use proper Docker networking instead of network_mode to avoid namespace issues
# The previous network_mode: service:db caused container startup failures in automated environments
# This approach is more reliable and works consistently across different deployment scenarios
depends_on:
db:
condition: service_healthy # Wait for PostgreSQL to be ready before starting the app
networks:
- app-network # Connect to custom bridge network for service communication
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

db:
image: postgres:latest
restart: unless-stopped
networks:
- app-network # Connect to the same network as the app container

# Health check ensures PostgreSQL is ready before dependent services start
# This is critical for depends_on with condition: service_healthy to work properly
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
interval: 10s # Check every 10 seconds
timeout: 5s # Wait up to 5 seconds for response
retries: 5 # Retry 5 times before marking as unhealthy
start_period: 30s # Give PostgreSQL 30 seconds to start before health checks begin
volumes:
- postgres-data:/var/lib/postgresql/data
- postgres-data:/var/lib/postgresql
- ./create-db-user.sql:/docker-entrypoint-initdb.d/create-db-user.sql
environment:
POSTGRES_USER: postgres
Expand Down Expand Up @@ -53,5 +75,15 @@ services:
# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)

# Persistent storage for PostgreSQL data
volumes:
postgres-data:
# Named volume ensures data persists across container restarts
# Located at /var/lib/postgresql/data inside the container

# Custom bridge network for service communication
# Replaces the problematic network_mode: service:db approach
networks:
app-network:
driver: bridge # Standard bridge driver for container-to-container communication
# Services on this network can communicate using service names (app -> db)
2 changes: 1 addition & 1 deletion src/ruby-rails-postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Develop Ruby on Rails applications with Postgres. Includes a Rails application c

| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|
| imageVariant | Ruby version (use -trixie, -bookworm, -bullseye variants on local arm64/Apple Silicon) : | string | 3.4-trixie |
| imageVariant | Ruby version (use -trixie, -bookworm, -bullseye variants on local arm64/Apple Silicon) : | string |4.0-trixie |

This template references an image that was [pre-built](https://containers.dev/implementors/reference/#prebuilding) to automatically include needed devcontainer.json metadata.

Expand Down
14 changes: 7 additions & 7 deletions src/ruby-rails-postgres/devcontainer-template.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "ruby-rails-postgres",
"version": "5.0.0",
"version": "6.0.0",
"name": "Ruby on Rails & Postgres",
"description": "Develop Ruby on Rails applications with Postgres. Includes a Rails application container and PostgreSQL server.",
"documentationURL": "https://github.com/devcontainers/templates/tree/main/src/ruby-rails-postgres",
Expand All @@ -9,23 +9,23 @@
"options": {
"imageVariant": {
"type": "string",
"description": "Ruby version (use -bookworm, -bullseye variants on local arm64/Apple Silicon):",
"description": "Ruby version (use - trixie, -bookworm, -bullseye variants on local arm64/Apple Silicon):",
"proposals": [
"3-trixie",
"4.0-trixie",
"3.4-trixie",
"3.3-trixie",
"3.2-trixie",
"3-bookworm",
"4.0-bookworm",
"3.4-bookworm",
"3.3-bookworm",
"3.2-bookworm",
"3-bullseye",
"4.0-bullseye",
"3.4-bullseye",
"3.3-bullseye",
"3.2-bullseye"
],
"default": "3.4-trixie"
}
"default": "4.0-trixie"
}
},
"platforms": ["Ruby"],
"optionalPaths": [
Expand Down
2 changes: 1 addition & 1 deletion src/ruby/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Ruby",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/ruby:2-${templateOption:imageVariant}"
"image": "mcr.microsoft.com/devcontainers/ruby:3-${templateOption:imageVariant}"

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
Expand Down
2 changes: 1 addition & 1 deletion src/ruby/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Develop Ruby based applications. includes everything you need to get up and runn

| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|
| imageVariant | Ruby version (use -trixie, -bookworm, -bullseye variants on local arm64/Apple Silicon) : | string | 3.4-trixie |
| imageVariant | Ruby version (use -trixie, -bookworm, -bullseye variants on local arm64/Apple Silicon) : | string |4.0-trixie |

This template references an image that was [pre-built](https://containers.dev/implementors/reference/#prebuilding) to automatically include needed devcontainer.json metadata.

Expand Down
10 changes: 5 additions & 5 deletions src/ruby/devcontainer-template.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "ruby",
"version": "5.0.0",
"version": "6.0.0",
"name": "Ruby",
"description": "Develop Ruby based applications. includes everything you need to get up and running.",
"documentationURL": "https://github.com/devcontainers/templates/tree/main/src/ruby",
Expand All @@ -11,20 +11,20 @@
"type": "string",
"description": "Ruby version (use -trixie, -bookworm, -bullseye variants on local arm64/Apple Silicon):",
"proposals": [
"3-trixie",
"4.0-trixie",
"3.4-trixie",
"3.3-trixie",
"3.2-trixie",
"3-bookworm",
"4.0-bookworm",
"3.4-bookworm",
"3.3-bookworm",
"3.2-bookworm",
"3-bullseye",
"4.0-bullseye",
"3.4-bullseye",
"3.3-bullseye",
"3.2-bullseye"
],
"default": "3.4-trixie"
"default": "4.0-trixie"
}
},
"platforms": ["Ruby"],
Expand Down
5 changes: 5 additions & 0 deletions test/ruby-rails-postgres/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ fixTestProjectFolderPrivs
# Run common tests
checkCommon


# Run devcontainer specific tests
check "rails" rails --version
check "rails installation path" gem which rails
check "user has write permission to rvm gems" [ -w /usr/local/rvm/gems ]
check "user has write permission to rvm gems default" [ -w /usr/local/rvm/gems/default ]
check "user can install gems" gem install github-markup
check "gem command works" gem --version
check "user can install gems" gem install github-markup
check "Bundler gem presence " gem list | grep -q "bundler"


# Report result
reportResults