Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add devcontainer config #157

Merged
merged 2 commits into from
Dec 13, 2024
Merged
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
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version
ARG RUBY_VERSION=3.2.2
FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION
34 changes: 34 additions & 0 deletions .devcontainer/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "tacos"

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
# - redis

# selenium:
# image: selenium/standalone-chromium
# restart: unless-stopped

# redis:
# image: redis:7.2
# restart: unless-stopped
# volumes:
# - redis-data:/data
# volumes:
# redis-data:
31 changes: 31 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby
{
"name": "tacos",
"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/rails/devcontainer/features/sqlite3": {},
"ghcr.io/rails/devcontainer/features/postgres-client": {},
},
// "containerEnv": {
// "CAPYBARA_SERVER_PORT": "45678",
// "SELENIUM_HOST": "selenium",
// "REDIS_URL": "redis://redis:6379/1"
// },
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
3000,
6379
],
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root",
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "bin/setup"
}
62 changes: 0 additions & 62 deletions Dockerfile

This file was deleted.

5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -161,6 +161,7 @@ GEM
faraday (>= 1, < 3)
faraday-net_http (3.4.0)
net-http (>= 0.5.0)
ffi (1.17.0-aarch64-linux-gnu)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86_64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
@@ -253,6 +254,8 @@ GEM
net-smtp (0.5.0)
net-protocol
nio4r (2.7.4)
nokogiri (1.16.7-aarch64-linux)
racc (~> 1.4)
nokogiri (1.16.7-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.7-x86_64-darwin)
@@ -421,6 +424,7 @@ GEM
actionpack (>= 6.1)
activesupport (>= 6.1)
sprockets (>= 3.0.0)
sqlite3 (1.7.3-aarch64-linux)
sqlite3 (1.7.3-arm64-darwin)
sqlite3 (1.7.3-x86_64-darwin)
sqlite3 (1.7.3-x86_64-linux)
@@ -474,6 +478,7 @@ GEM
zeitwerk (2.7.1)

PLATFORMS
aarch64-linux
arm64-darwin-22
arm64-darwin-23
x86_64-darwin-22
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,34 @@ There is a `Makefile` that contains some useful command shortcuts for typical de

To see a current list of commands, run `make help`.

### Development containers (aka devcontainers)

This repository provides [devcontainers](https://containers.dev). Rather than taking the time to configure your local
environment, consider using the provided devcontainers. You can still use your prefered code editors as if you were
working locally, but all execution of code will happen in containers in a way that will be consistent across all
developers using these containers.

#### Visual Studio Code

[Visual Studio Code can detect and manage devcontainers](https://code.visualstudio.com/docs/devcontainers/containers)
for you. It can build and reopen the code in the container and then the terminal within Visual Studio Code will execute
commands in the container. The first time you start the container, it is a bit slow but subsequent launches are fairly
quick.

This requires a functional Docker environment and the [Visual Studio Code Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers).

Note: when Visual Studio Code reopens in the container, it does not automaticaly launch the server. Instead, you use the
terminal within Visual Studio Code to run the same commands you would in a local environment, such as `bin/rails s` or
`bin/rails test`. In this repo, we also have a series of command shortcuts you can see via `make`.

#### Non-Visual Studio Code

If you prefer an editor other than Visual Studio Code, you can manage [Dev Containers from the CLI](https://containers.dev/supporting#devcontainer-cli) or look to see if your chosen editor may have direct support for Dev Containers.

[DevPod](https://github.com/loft-sh/devpod) is also something to consider. It provides a VScode-via-web-browser-in-a-box
as well as allowing you to use whatever editor you want and only using DevPod to start/stop the containers and run your
terminals. With this approach you could use your local editor, and the DevPod managed Dev Container for everything else.

### Generating cassettes for tests

We use [VCR](https://github.com/vcr/vcr) to record transactions with remote systems for testing. This includes the rake
Loading