Skip to content

Commit 9d11e10

Browse files
authored
Replace scripts with common tools and git features (#18)
* Build devcontainer from features * Fix lldb.library setting * Remove Node.js comments * Remove swift 4.2 * Update README * Remove table from README * Add test script * comment
1 parent 417d7ae commit 9d11e10

File tree

8 files changed

+70
-742
lines changed

8 files changed

+70
-742
lines changed

README.md

+7-27
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,13 @@
44

55
Develop Swift based applications. Includes everything you need to get up and running.
66

7-
| Metadata | Value |
8-
|----------|-------|
9-
| *Contributors* | [0xTim](https://github.com/0xTim), [adam-fowler](https://github.com/adam-fowler), [cloudnull](https://github.com/cloudnull) |
10-
| *Categories* | Languages |
11-
| *Definition type* | Dockerfile |
12-
| *Supported architecture(s)* | x86-64, arm64 |
13-
| *Works in Codespaces* | Yes |
14-
| *Container host OS support* | Linux, macOS, Windows |
15-
| *Container OS* | Debian |
16-
| *Languages, platforms* | Swift |
17-
18-
## Using this definition
19-
20-
While the definition itself works unmodified, you can select the version of Swift the container uses by updating the `VARIANT` arg in the included `devcontainer.json` (and rebuilding if you've already created the container).
21-
22-
```json
23-
"args": { "VARIANT": "5.7" }
24-
```
25-
26-
Given how frequently web applications use Node.js for front end code, this container also includes an optional install of Node.js. You can enable installation and change the version of Node.js installed or disable its installation by updating the `args` property in `.devcontainer/devcontainer.json`.
27-
28-
```jsonc
29-
"args": {
30-
"VARIANT": "5.7",
31-
"NODE_VERSION": "14" // Set to "none" to skip Node.js installation
32-
}
33-
```
7+
## Options
8+
9+
| Options Id | Description | Type | Default Value |
10+
|-----|-----|-----|-----|
11+
| imageVariant | Version of Swift | string | 5.7 |
12+
13+
This template uses the common-utils feature to implement some commonly implemented options including install zsh and updating packages. Edit the values in the `devcontainer.json` to enable these. More details on available options can be found [here](https://github.com/devcontainers/features/blob/main/src/common-utils/README.md).
3414

3515
### Adding the definition to a project or codespace
3616

scripts/publish.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/sh
12
# This script requires the devcontainer tool for publishing. You can install it with
23
# npm install -g @devcontainers/cli
34
# More details can be found here https://github.com/devcontainers/cli#try-it-out

scripts/test.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
# This script requires the devcontainer tool for publishing. You can install it with
3+
# npm install -g @devcontainers/cli
4+
# More details can be found here https://github.com/devcontainers/cli#try-it-out
5+
#
6+
# The script currently requires you to edit the devcontainer.json to replace the ${templateOption:imageVariant}
7+
# with the swift version number you are testing with
8+
template_id=swift
9+
set -e
10+
11+
# Build container
12+
echo "Building dev container"
13+
id_label="test-container=${template_id}"
14+
devcontainer up --id-label ${id_label} --workspace-folder "src/${template_id}/"
15+
16+
# Test swift runs
17+
devcontainer exec --workspace-folder "src/${template_id}/" --id-label ${id_label} /bin/sh -c 'swift --version'
18+
19+
# Clean up
20+
docker rm -f $(docker container ls -f "label=${id_label}" -q)

src/swift/.devcontainer/Dockerfile

-33
This file was deleted.
+39-31
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,44 @@
11
{
22
"name": "Swift",
3-
"build": {
4-
"dockerfile": "Dockerfile"
5-
},
6-
"runArgs": [
7-
"--cap-add=SYS_PTRACE",
8-
"--security-opt",
9-
"seccomp=unconfined"
10-
],
3+
"image": "swift:${templateOption:imageVariant}",
4+
"features": {
5+
"ghcr.io/devcontainers/features/common-utils:2": {
6+
"installZsh": "false",
7+
"username": "vscode",
8+
"userUid": "1000",
9+
"userGid": "1000",
10+
"upgradePackages": "false"
11+
},
12+
"ghcr.io/devcontainers/features/git:1": {
13+
"version": "os-provided",
14+
"ppa": "false"
15+
}
16+
},
17+
"runArgs": [
18+
"--cap-add=SYS_PTRACE",
19+
"--security-opt",
20+
"seccomp=unconfined"
21+
],
22+
// Configure tool-specific properties.
23+
"customizations": {
24+
// Configure properties specific to VS Code.
25+
"vscode": {
26+
// Set *default* container specific settings.json values on container create.
27+
"settings": {
28+
"lldb.library": "/usr/lib/liblldb.so"
29+
},
30+
// Add the IDs of extensions you want installed when the container is created.
31+
"extensions": [
32+
"sswg.swift-lang"
33+
]
34+
}
35+
},
36+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
37+
// "forwardPorts": [],
1138

12-
// Configure tool-specific properties.
13-
"customizations": {
14-
// Configure properties specific to VS Code.
15-
"vscode": {
16-
// Set *default* container specific settings.json values on container create.
17-
"settings": {
18-
"lldb.library": "/usr/lib/liblldb.so"
19-
},
20-
21-
// Add the IDs of extensions you want installed when the container is created.
22-
"extensions": [
23-
"sswg.swift-lang"
24-
]
25-
}
26-
},
39+
// Use 'postCreateCommand' to run commands after the container is created.
40+
"postCreateCommand": "swift --version",
2741

28-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
29-
// "forwardPorts": [],
30-
31-
// Use 'postCreateCommand' to run commands after the container is created.
32-
// "postCreateCommand": "",
33-
34-
// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
35-
"remoteUser": "vscode"
42+
// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
43+
"remoteUser": "vscode"
3644
}

0 commit comments

Comments
 (0)