Skip to content

Commit 3831036

Browse files
authored
Merge pull request #104 from JudahSan/fix/cta-rubyconf-2025
Add DevContainer setup and update README with setup instructions`
2 parents 530688e + 3320179 commit 3831036

File tree

9 files changed

+136
-17
lines changed

9 files changed

+136
-17
lines changed

.devcontainer/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
2+
ARG RUBY_VERSION=3.4.1
3+
FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION

.devcontainer/compose.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: "arc_platform"
2+
3+
services:
4+
rails-app:
5+
build:
6+
context: ..
7+
dockerfile: .devcontainer/Dockerfile
8+
9+
volumes:
10+
- ../..:/workspaces:cached
11+
12+
# Overrides default command so things don't shut down after the process ends.
13+
command: sleep infinity
14+
15+
# Uncomment the next line to use a non-root user for all processes.
16+
# user: vscode
17+
18+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
19+
# (Adding the "ports" property to this file will not forward from a Codespace.)
20+
depends_on:
21+
- selenium
22+
- redis
23+
- postgres
24+
25+
selenium:
26+
image: selenium/standalone-chromium
27+
restart: unless-stopped
28+
29+
redis:
30+
image: redis:7.2
31+
restart: unless-stopped
32+
volumes:
33+
- redis-data:/data
34+
35+
postgres:
36+
image: postgres:16.1
37+
restart: unless-stopped
38+
networks:
39+
- default
40+
volumes:
41+
- postgres-data:/var/lib/postgresql/data
42+
environment:
43+
POSTGRES_USER: postgres
44+
POSTGRES_PASSWORD: postgres
45+
46+
volumes:
47+
redis-data:
48+
postgres-data:

.devcontainer/devcontainer.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby
3+
{
4+
"name": "arc_platform",
5+
"dockerComposeFile": "compose.yaml",
6+
"service": "rails-app",
7+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
8+
9+
// Features to add to the dev container. More info: https://containers.dev/features.
10+
"features": {
11+
"ghcr.io/devcontainers/features/github-cli:1": {},
12+
"ghcr.io/rails/devcontainer/features/activestorage": {},
13+
"ghcr.io/devcontainers/features/node:1": {},
14+
"ghcr.io/rails/devcontainer/features/postgres-client": {}
15+
},
16+
17+
"containerEnv": {
18+
"CAPYBARA_SERVER_PORT": "45678",
19+
"SELENIUM_HOST": "selenium",
20+
"REDIS_URL": "redis://redis:6379/1",
21+
"DB_HOST": "postgres"
22+
},
23+
24+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
25+
"forwardPorts": [3000, 5432, 6379],
26+
27+
// Configure tool-specific properties.
28+
// "customizations": {},
29+
30+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
31+
// "remoteUser": "root",
32+
33+
34+
// Use 'postCreateCommand' to run commands after the container is created.
35+
"postCreateCommand": "bin/setup"
36+
}

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.2
1+
3.4.1

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ruby:3.0.2-alpine
1+
FROM ruby:3.4.1-alpine
22

33
ENV APP_PATH /var/app
44
ENV BUNDLE_VERSION 2.3.1

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,28 @@ The Africa Ruby Community (ARC) Platform is a project aimed at creating a hub fo
1313
*Note: This project is open source, and contributions are encouraged.*
1414

1515
## Application Setup
16+
17+
### Dev Containers
18+
19+
#### Prerequisites
20+
- Docker Desktop
21+
- VS Code with Dev Containers extension
22+
23+
#### Setup
24+
1. Open project in VS Code
25+
2. Click green "><" icon in bottom-left corner
26+
3. Select "Reopen in Container"
27+
28+
## First Run
29+
- Initial build may take several minutes
30+
- All dependencies will be installed automatically
31+
32+
## Running Rails
33+
```bash
34+
bundle exec rails server -b 0.0.0.0
35+
```
36+
Access app at `http://localhost:3000`
37+
1638
- To follow along, watch this youtube tutorial on how to set up the application step by step on WSL.
1739

1840
[![Application Setup](https://img.youtube.com/vi/-mz76HidnGA/0.jpg)](https://www.youtube.com/watch?v=-mz76HidnGA)
@@ -29,7 +51,7 @@ The Africa Ruby Community (ARC) Platform is a project aimed at creating a hub fo
2951
Install dependencies for compiling Ruby:
3052

3153
* macOS: Install Homebrew
32-
54+
3355
```sh
3456
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
3557
```

app/views/landing/home/_intro.html.erb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
<div class="bg-gradient-to-r from-red-600 to-red-700 text-center py-5 sm:py-6 md:py-8 px-4 sm:px-6 md:px-8 shadow-lg rounded-box mx-auto max-w-lg">
2-
<div class="tooltip" data-tip="Click to visit Ruby Conf Africa 2025">
3-
<a href="https://rubyconf.africa" class="btn btn-lg btn-primary btn-block text-xl sm:text-l font-extrabold flex items-center justify-center space-x-3 underline decoration-dashed hover:decoration-solid ">
4-
<span class="text-xl font-bold tracking-wide">Ruby Conf Africa 2025</span>
5-
<span class="text-3xl animate-pulse text-red-200">🔗</span>
6-
</a>
7-
</div>
1+
<div class="text-center shadow-lg rounded-box mx-auto">
2+
<a href="https://rubyconf.africa" title="Click to visit Ruby Conf Africa 2025" class="btn btn-lg btn-primary btn-block text-xl sm:text-l font-extrabold flex items-center justify-center space-x-3 underline decoration-dashed hover:decoration-solid">
3+
<span class="text-xl font-bold tracking-wide">Ruby Conf Africa 2025 🔗</span>
4+
</a>
85
</div>
96

107
<div class="grid md:grid-cols-2 pt-10 pb-10 gap-10">

config/database.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
# gem install pg
55
# On macOS with Homebrew:
66
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7-
# On macOS with MacPorts:
8-
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
97
# On Windows:
108
# gem install pg
119
# Choose the win32 build.
@@ -20,18 +18,24 @@ default: &default
2018
# For details on connection pooling, see Rails configuration guide
2119
# https://guides.rubyonrails.org/configuring.html#database-pooling
2220
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
21+
<% if ENV["DB_HOST"] %>
22+
host: <%= ENV["DB_HOST"] %>
23+
username: postgres
24+
password: postgres
25+
<% end %>
26+
2327

2428
development:
2529
<<: *default
2630
database: arc_platform_development
2731

28-
# The specified database role being used to connect to postgres.
29-
# To create additional roles in postgres see `$ createuser --help`.
30-
# When left blank, postgres will use the default role. This is
32+
# The specified database role being used to connect to PostgreSQL.
33+
# To create additional roles in PostgreSQL see `$ createuser --help`.
34+
# When left blank, PostgreSQL will use the default role. This is
3135
# the same name as the operating system user running Rails.
3236
#username: arc_platform
3337

34-
# The password associated with the postgres role (username).
38+
# The password associated with the PostgreSQL role (username).
3539
#password:
3640

3741
# Connect on a TCP socket. Omitted by default since the client uses a

test/application_system_test_case.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,14 @@
33
require 'test_helper'
44

55
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
6-
driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
6+
if ENV['CAPYBARA_SERVER_PORT']
7+
served_by host: 'rails-app', port: ENV['CAPYBARA_SERVER_PORT']
8+
9+
driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400], options: {
10+
browser: :remote,
11+
url: "http://#{ENV.fetch('SELENIUM_HOST', nil)}:4444"
12+
}
13+
else
14+
driven_by :selenium, using: :headless_chrome, screen_size: [1400, 1400]
15+
end
716
end

0 commit comments

Comments
 (0)