Skip to content

Commit d7c2fc3

Browse files
committed
Add a "universal" image which includes asdf and plugins
The purpose of this image is to include everything that is necessary to run a common Ruby application (be it a Ruby gem, or a Rails application or similar). It needs to include a broad range of Ruby and Node versions (this is a list which will need maintaining in future), along with any other tools needed. The current list of versions is inspired by Administrate, where we test with a large amount of minor Ruby versions. It's based on the "debian" base image, so brings along any decisions made there.
1 parent 5edfaaf commit d7c2fc3

6 files changed

Lines changed: 108 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ to demonstrate different configuration approaches that we've seen on projects.
3434
* `debian` is a barebones image without any development environments
3535
* It's based on images provided by the `buildpack-deps` project,
3636
* Images are tagged by date of build, the most recent also tagged as `latest`,
37+
* `universal` is a bigger image, inspired by [`laptop`][5], which should be
38+
everything you need for a web project
39+
* It's based on the most recent build of `debian`,
40+
* Images are tagged by date of build, along with a single `latest` pointed
41+
to the most recent
3742

3843
We currently only build `amd64` images, as this is enough to work with
3944
Codespaces.
@@ -115,3 +120,4 @@ Depending on the version of the feature, this will publish tags like:
115120
[2]: https://github.com/features/codespaces
116121
[3]: .devcontainer/
117122
[4]: https://github.com/thoughtbot/codespaces-demo/tree/custom-config
123+
[5]: https://github.com/thoughtbot/laptop
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM ghcr.io/thoughtbot/devcontainers/images/debian:latest
2+
3+
LABEL org.opencontainers.image.source=https://github.com/thoughtbot/devcontainers
4+
LABEL org.opencontainers.image.description="Universal Dev Container Image"
5+
LABEL org.opencontainers.image.licenses=MIT
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"features": {
3+
"ghcr.io/thoughtbot/devcontainers/features/asdf-plugin-nodejs:1": {
4+
"version": "1.0.0",
5+
"resolved": "ghcr.io/thoughtbot/devcontainers/features/asdf-plugin-nodejs@sha256:eb060fc441a4d3f31b255e671cbca212be2024aaf8e290f99b519f6ad462e9bc",
6+
"integrity": "sha256:eb060fc441a4d3f31b255e671cbca212be2024aaf8e290f99b519f6ad462e9bc",
7+
"dependsOn": [
8+
"ghcr.io/thoughtbot/devcontainers/features/asdf:1"
9+
]
10+
},
11+
"ghcr.io/thoughtbot/devcontainers/features/asdf-plugin-ruby:1": {
12+
"version": "1.0.0",
13+
"resolved": "ghcr.io/thoughtbot/devcontainers/features/asdf-plugin-ruby@sha256:551f29d153607931230b872d9420724d3c4a95342bdddf7d489f8e0f5f482e5c",
14+
"integrity": "sha256:551f29d153607931230b872d9420724d3c4a95342bdddf7d489f8e0f5f482e5c",
15+
"dependsOn": [
16+
"ghcr.io/thoughtbot/devcontainers/features/asdf:1"
17+
]
18+
},
19+
"ghcr.io/thoughtbot/devcontainers/features/asdf:1": {
20+
"version": "1.0.0",
21+
"resolved": "ghcr.io/thoughtbot/devcontainers/features/asdf@sha256:073b2dd9e06753b6adf6a3f279d7ee6568243f632004c4872b5b036039949e26",
22+
"integrity": "sha256:073b2dd9e06753b6adf6a3f279d7ee6568243f632004c4872b5b036039949e26"
23+
}
24+
}
25+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"build": {
3+
"dockerfile": "./Dockerfile",
4+
"context": "."
5+
},
6+
"features": {
7+
"ghcr.io/thoughtbot/devcontainers/features/asdf:1": {},
8+
"ghcr.io/thoughtbot/devcontainers/features/asdf-plugin-ruby:1": {
9+
"versions": "3.0,3.1,3.2,3.3,3.4,4.0,4.0.0"
10+
},
11+
"ghcr.io/thoughtbot/devcontainers/features/asdf-plugin-nodejs:1": {
12+
"versions": "20.11.0,lts"
13+
},
14+
},
15+
"remoteUser": "codespace",
16+
"containerUser": "codespace"
17+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
3+
VERBOSE="${VERBOSE:-0}"
4+
LAST_COMMAND_OUTPUT=
5+
6+
# assert_command command [expected status code]
7+
#
8+
# Run a command and assert it's exit code is 0 or one given
9+
assert_command() {
10+
cmd="$1"
11+
expected_return_status="${2:-0}"
12+
13+
LAST_COMMAND_OUTPUT=
14+
15+
# Always capture stdout and stderr, and don't let a failing command
16+
# cause this function to fail
17+
if LAST_COMMAND_OUTPUT="$(printf '%s' "$cmd" | sh -a 2>&1)"; then
18+
status="$?" # ok
19+
else
20+
status="$?" # also ok
21+
fi
22+
23+
if [ ! "$VERBOSE" -eq 0 ]; then
24+
echo "Command: $cmd"
25+
echo "Command output: $LAST_COMMAND_OUTPUT"
26+
echo "Status code: $status"
27+
fi
28+
29+
if [ "$status" -ne "$expected_return_status" ]; then
30+
echo "$cmd exited with: $status"
31+
exit 1
32+
fi
33+
}
34+
35+
# assert_package package
36+
#
37+
# Query OS packages and assert one is installed
38+
assert_package() {
39+
package=$1
40+
41+
assert_command "dpkg-query --show -f='\${Package}: \${Version}' $package"
42+
}

‎images/universal/test/test.sh‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
cwd=$(readlink -f "${0%/*}")
6+
7+
. "$cwd/test-utils.sh"
8+
9+
echo "Checking we've got Ruby via asdf..."
10+
assert_command "asdf list | grep ruby"
11+
12+
echo "Checking we've got Node via asdf..."
13+
assert_command "asdf list | grep nodejs"

0 commit comments

Comments
 (0)