Skip to content

Commit 9f8155c

Browse files
committed
Configure dev container
Why these changes are being introduced: Dev containers make it easier to develop apps without maintaining a local Ruby/Rails environment. Relevant ticket(s): * [TCO-89](https://mitlibraries.atlassian.net/browse/TCO-89) How this addresses that need: This adds dev container config files and documentation. Side effects of this change: Gemfile.lock now includes aarch64-linux, probably because I ran the dev container on my Macbook.
1 parent 598e3da commit 9f8155c

File tree

5 files changed

+96
-0
lines changed

5 files changed

+96
-0
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.2.8
3+
FROM ghcr.io/rails/devcontainer/images/ruby:$RUBY_VERSION

.devcontainer/compose.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: "timdex-ui"
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+
24+
# selenium:
25+
# image: selenium/standalone-chromium
26+
# restart: unless-stopped
27+
28+
# redis:
29+
# image: redis:7.2
30+
# restart: unless-stopped
31+
# volumes:
32+
# - redis-data:/data
33+
# volumes:
34+
# redis-data:

.devcontainer/devcontainer.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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": "timdex-ui",
5+
"dockerComposeFile": "compose.yaml",
6+
"service": "rails-app",
7+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
8+
// Features to add to the dev container. More info: https://containers.dev/features.
9+
"features": {
10+
"ghcr.io/devcontainers/features/github-cli:1": {},
11+
// "ghcr.io/rails/devcontainer/features/activestorage": {},
12+
"ghcr.io/rails/devcontainer/features/sqlite3": {},
13+
"ghcr.io/rails/devcontainer/features/postgres-client": {}
14+
},
15+
// "containerEnv": {
16+
// "CAPYBARA_SERVER_PORT": "45678",
17+
// "SELENIUM_HOST": "selenium",
18+
// "REDIS_URL": "redis://redis:6379/1"
19+
// },
20+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
21+
"forwardPorts": [
22+
3000,
23+
6379
24+
],
25+
// Configure tool-specific properties.
26+
// "customizations": {},
27+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
28+
// "remoteUser": "root",
29+
// Use 'postCreateCommand' to run commands after the container is created.
30+
"postCreateCommand": "bin/setup"
31+
}

Gemfile.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ GEM
143143
erb (2.2.3)
144144
cgi
145145
erubi (1.13.1)
146+
ffi (1.17.2-aarch64-linux-gnu)
146147
ffi (1.17.2-arm64-darwin)
147148
ffi (1.17.2-x86_64-darwin)
148149
ffi (1.17.2-x86_64-linux-gnu)
@@ -223,6 +224,8 @@ GEM
223224
net-smtp (0.5.1)
224225
net-protocol
225226
nio4r (2.7.4)
227+
nokogiri (1.18.8-aarch64-linux-gnu)
228+
racc (~> 1.4)
226229
nokogiri (1.18.8-arm64-darwin)
227230
racc (~> 1.4)
228231
nokogiri (1.18.8-x86_64-darwin)
@@ -356,6 +359,7 @@ GEM
356359
actionpack (>= 6.1)
357360
activesupport (>= 6.1)
358361
sprockets (>= 3.0.0)
362+
sqlite3 (2.7.1-aarch64-linux-gnu)
359363
sqlite3 (2.7.1-arm64-darwin)
360364
sqlite3 (2.7.1-x86_64-darwin)
361365
sqlite3 (2.7.1-x86_64-linux-gnu)
@@ -396,6 +400,7 @@ GEM
396400
zeitwerk (2.7.3)
397401

398402
PLATFORMS
403+
aarch64-linux
399404
arm64-darwin-22
400405
arm64-darwin-23
401406
arm64-darwin-24

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,26 @@ The schema for the GraphQL endpoint can be found at `/config/schema/schema.json`
149149
```ruby
150150
GraphQL::Client.dump_schema(TimdexBase::HTTP, 'config/schema/schema.json')
151151
```
152+
153+
### Development containers (aka devcontainers)
154+
155+
This repository provides [devcontainers](https://containers.dev). Rather than taking the time to configure your local
156+
environment, consider using the provided devcontainers. You can still use your prefered code editors as if you were
157+
working locally, but all execution of code will happen in containers in a way that will be consistent across all
158+
developers using these containers.
159+
160+
#### VScode
161+
162+
[VScode can detect and manage devcontainers](https://code.visualstudio.com/docs/devcontainers/containers)
163+
for you. It can build and reopen the code in the container and then the terminal within VScode will execute
164+
commands in the container.
165+
166+
This requires a functional Docker environment and the [VScode Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers).
167+
168+
#### Non-VScode
169+
170+
If you prefer an editor other than VSCode, 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.
171+
172+
[DevPod](https://github.com/loft-sh/devpod) is also something to consider. It provides a VScode-via-web-browser-in-a-box
173+
as well as allowing you to use whatever editor you want and only using DevPod to start/stop the containers and run your
174+
terminals. Local for editor, DevPod managed Dev Container for everything else.

0 commit comments

Comments
 (0)