From 1beeaff2c3644cd1da7c82e58f69302a19db0355 Mon Sep 17 00:00:00 2001 From: Jez Nicholson Date: Thu, 23 Apr 2026 10:18:19 +0100 Subject: [PATCH 1/2] config devcontainer --- .devcontainer/Dockerfile | 3 +++ .devcontainer/compose.yaml | 39 +++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 39 +++++++++++++++++++++++++++++++++ .vscode/tasks.json | 17 ++++++++++++++ Gemfile | 2 ++ Gemfile.lock | 4 ++++ config/database.yml.example | 8 ++++++- 7 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/compose.yaml create mode 100644 .devcontainer/devcontainer.json create mode 100644 .vscode/tasks.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..dcf56a2 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,3 @@ +# Make sure RUBY_VERSION matches the Ruby version in .ruby-version +ARG RUBY_VERSION=3.3.9 +FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION diff --git a/.devcontainer/compose.yaml b/.devcontainer/compose.yaml new file mode 100644 index 0000000..e331283 --- /dev/null +++ b/.devcontainer/compose.yaml @@ -0,0 +1,39 @@ +name: "boltspa" + +services: + rails-app: + build: + context: .. + dockerfile: .devcontainer/Dockerfile + + volumes: + - ../..:/workspaces:cached + # Overrides default command so things don't shut down after the process ends. + command: sleep infinity + + # Uncomment the next line to use a non-root user for all processes. + # user: vscode + + # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. + # (Adding the "ports" property to this file will not forward from a Codespace.) + depends_on: + - selenium + - postgres + + selenium: + image: selenium/standalone-chromium + restart: unless-stopped + + postgres: + image: postgres:17 + restart: unless-stopped + networks: + - default + volumes: + - postgres-data:/var/lib/postgresql/data + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + +volumes: + postgres-data: diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..854e699 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,39 @@ +// For format details, see https://containers.dev/implementors/json_reference/. +// For config options, see the README at: https://github.com/devcontainers/templates/tree/main/src/ruby +{ + "name": "boltspa", + "dockerComposeFile": "compose.yaml", + "service": "rails-app", + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + + // Features to add to the dev container. More info: https://containers.dev/features. + "features": { + // "ghcr.io/devcontainers/features/github-cli:1": {}, + "ghcr.io/rails/devcontainer/features/activestorage": {}, + // "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}, + // "ghcr.io/rails/devcontainer/features/sqlite3": {} + "ghcr.io/rails/devcontainer/features/postgres-client": { + "version": "17" + } + }, + + "containerEnv": { + "CAPYBARA_SERVER_PORT": "45678", + "SELENIUM_HOST": "selenium", + "KAMAL_REGISTRY_PASSWORD": "$KAMAL_REGISTRY_PASSWORD", + "DB_HOST": "postgres" + }, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [3000, 5432], + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://containers.dev/implementors/json_reference/#remoteUser. + // "remoteUser": "root", + + + // Use 'postCreateCommand' to run commands after the container is created. + "postCreateCommand": "bin/setup --skip-server" +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..62b52ee --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "boltspa: start", + "type": "shell", + "command": "overmind start -f Procfile.dev", + "group": "none", + "presentation": { + "reveal": "always", + "panel": "new" + } + } + ] +} \ No newline at end of file diff --git a/Gemfile b/Gemfile index 38bbcd3..c364ed6 100644 --- a/Gemfile +++ b/Gemfile @@ -51,3 +51,5 @@ group :test do gem 'capybara' gem 'selenium-webdriver' end + +gem "dockerfile-rails", ">= 1.7", group: :development diff --git a/Gemfile.lock b/Gemfile.lock index 36ecf62..bd24ee6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -140,6 +140,8 @@ GEM reline (>= 0.3.8) debug_inspector (1.2.0) diff-lcs (1.6.2) + dockerfile-rails (1.7.10) + rails (>= 3.0.0) drb (2.2.3) erb (6.0.3) erubi (1.13.1) @@ -462,6 +464,7 @@ DEPENDENCIES bootsnap capybara debug + dockerfile-rails (>= 1.7) faker faraday fx @@ -519,6 +522,7 @@ CHECKSUMS debug (1.11.1) sha256=2e0b0ac6119f2207a6f8ac7d4a73ca8eb4e440f64da0a3136c30343146e952b6 debug_inspector (1.2.0) sha256=9bdfa02eebc3da163833e6a89b154084232f5766087e59573b70521c77ea68a2 diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962 + dockerfile-rails (1.7.10) sha256=04163273792ec6c6560244d32c0b44bbed705384a47b8063adcbf0d7bc8abd26 drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373 erb (6.0.3) sha256=e43685a8a0a0ea6a924871b2162e8953ef73147ce46b75b36d1f6774fd286e91 erubi (1.13.1) sha256=a082103b0885dbc5ecf1172fede897f9ebdb745a4b97a5e8dc63953db1ee4ad9 diff --git a/config/database.yml.example b/config/database.yml.example index b436ea2..5f01ac6 100644 --- a/config/database.yml.example +++ b/config/database.yml.example @@ -1,10 +1,16 @@ default: &default adapter: postgresql encoding: unicode + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + <% if ENV["DB_HOST"] %> + host: <%= ENV["DB_HOST"] %> + username: postgres + password: postgres + <% else %> host: localhost username: someuser password: somepass - pool: 5 + <% end %> development: <<: *default From 0f91d5a2ce83f436e0e6e2f250b8b3fa5769c4de Mon Sep 17 00:00:00 2001 From: Jez Nicholson Date: Thu, 23 Apr 2026 17:16:08 +0100 Subject: [PATCH 2/2] add your own credentials --- .gitignore | 4 ++++ .vscode/tasks.json | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/.gitignore b/.gitignore index e3af8a3..ffbc0b6 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,7 @@ database.yml data.json .overmind.sock + +# Ignore key files for decrypting credentials and more. +/config/credentials/*.key +/config/credentials/development.yml.enc diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 62b52ee..972395a 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -12,6 +12,26 @@ "reveal": "always", "panel": "new" } + }, + { + "label": "boltspa: console", + "type": "shell", + "command": "./bin/rails console", + "group": "none", + "presentation": { + "reveal": "always", + "panel": "new" + } + }, + { + "label": "boltspa: credentials", + "type": "shell", + "command": "EDITOR=\"vi\" ./bin/rails credentials:edit --environment development", + "group": "none", + "presentation": { + "reveal": "always", + "panel": "new" + } } ] } \ No newline at end of file