Skip to content

Commit 0b670df

Browse files
authored
Add Linux devcontainer (#9003)
Add a devcontainer.json to help streamline Linux development from other platforms. The container builds from `swift:nightly-main`.
1 parent 16452e1 commit 0b670df

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

.devcontainer/devcontainer.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "Swift Nightly Main",
3+
"image": "swiftlang/swift:nightly-main",
4+
"features": {
5+
"ghcr.io/devcontainers/features/common-utils:2": {
6+
"installZsh": "false",
7+
"username": "root",
8+
"upgradePackages": "false"
9+
},
10+
"ghcr.io/devcontainers/features/git:1": {
11+
"version": "os-provided",
12+
"ppa": "false"
13+
}
14+
},
15+
"postCreateCommand": "apt-get update && apt-get install -y curl sqlite3 libsqlite3-dev libncurses5-dev python3 build-essential",
16+
"runArgs": [
17+
"--cap-add=SYS_PTRACE",
18+
"--security-opt",
19+
"seccomp=unconfined"
20+
],
21+
"customizations": {
22+
"vscode": {
23+
"settings": {
24+
"lldb.library": "/usr/lib/liblldb.so"
25+
},
26+
"extensions": [
27+
"swiftlang.swift-vscode"
28+
]
29+
}
30+
},
31+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
32+
// "forwardPorts": [],
33+
"remoteUser": "root"
34+
}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ Package.resolved
1919
.docc-build
2020
.vscode
2121
Utilities/InstalledSwiftPMConfiguration/config.json
22-
.devcontainer
2322
Fixtures/BinaryLibraries/Static/Package1/Simple.artifactbundle/build

CONTRIBUTING.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,40 @@ swift build
9696
swift test
9797
```
9898

99+
## Developing in the Linux devcontainer
100+
101+
SwiftPM includes a devcontainer configuration that allows you to develop in a containerized environment with VS Code. This approach provides a consistent development environment with all necessary dependencies pre-installed, regardless of your host operating system.
102+
103+
### Prerequisites
104+
105+
1. Install [Visual Studio Code](https://code.visualstudio.com/)
106+
2. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) for VS Code
107+
3. Install [Docker](https://www.docker.com/products/docker-desktop/) on your system
108+
109+
### Opening the Project in a Container
110+
111+
1. Clone the SwiftPM repository (if you haven't already)
112+
2. Open the SwiftPM folder in VS Code
113+
3. VS Code will detect the devcontainer configuration and prompt you to "Reopen in Container". Click this button to start building and opening the container
114+
- Alternatively, you can press `F1`, type "Dev Containers: Reopen in Container", and press Enter
115+
4. Wait for the container to build and initialize (this may take a few minutes the first time)
116+
117+
### What's Included in the Dev Container
118+
119+
The SwiftPM devcontainer is based on the `swiftlang/swift:nightly-main` Docker image and includes:
120+
121+
- Swift nightly build from the main branch
122+
- Git
123+
- Common development utilities
124+
- VS Code Swift extension for syntax highlighting and language support
125+
- Debugging support with LLDB
126+
127+
### Building and Testing in the Container
128+
129+
Once you've opened the project in VS Code, choose `> Dev Containers: Build and Reopen in Container` from the command pallete. Once the container finishes building it will open and you can develop as if you are on Linux using VS Code.
130+
131+
All the commands described in the "Local Development" section below will work in the container environment.
132+
99133
## Local Development
100134

101135
With a Swift toolchain installed and the SwiftPM code cloned, you are ready to make changes and test them locally.

0 commit comments

Comments
 (0)