Skip to content

Commit 2940fff

Browse files
Update Dockerfile to run tests without root permissions (#42)
Fixes test failures that were occuring when using the included Dockerfile to run DocC's tests for Linux. The test suite does not expect to be run on a root user account. This also better emulates the way tests will be run on Linux in the Swift.org CI system. The changes to the Dockerfile are based on the Dockerfiles used in swift-ci here: https://github.com/apple/swift-docker/blob/main/swift-ci/master/ubuntu/20.04/Dockerfile.
1 parent 92f7fe1 commit 2940fff

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

CONTRIBUTING.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,28 +209,22 @@ by running the test suite in a Docker environment that simulates Swift on Linux.
209209

210210
1. Install [Docker Desktop for Mac](https://www.docker.com/products/docker-desktop).
211211

212-
2. Get the newest Swift Docker image with:
212+
2. Build Swift-DocC (see [Building Swift-DocC](#building-swift-docc)).
213213

214-
```bash
215-
docker pull swift
216-
```
217-
218-
3. Build Swift-DocC (see [Building Swift-DocC](#building-swift-docc)).
219-
220-
4. Run the following command from the root of this repository
214+
3. Run the following command from the root of this repository
221215
to build the Swift-DocC Docker image:
222216

223217
```bash
224218
docker build -t swift-docc:latest .
225219
```
226220

227-
5. Run the following command to run the test suite:
221+
4. Run the following command to run the test suite:
228222

229223
```bash
230-
docker run -v `pwd`:/swift-docc swift-docc sh -c 'swift test --package-path /swift-docc --enable-test-discovery --skip-update'
224+
docker run -v `pwd`:/swift-docc swift-docc sh -c 'swift test --package-path /swift-docc --parallel --skip-update'
231225
```
232226

233-
6. To interactively test the command line interface,
227+
5. To interactively test the command line interface,
234228
first log into the container with:
235229

236230
```bash

Dockerfile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,14 @@
66
# See https://swift.org/LICENSE.txt for license information
77
# See https://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9-
FROM swiftlang/swift:nightly-5.5
9+
FROM swift:5.5
10+
11+
# Set up the current build user in the same way done in the Swift.org CI system:
12+
# https://github.com/apple/swift-docker/blob/main/swift-ci/master/ubuntu/20.04/Dockerfile.
13+
14+
RUN groupadd -g 998 build-user && \
15+
useradd -m -r -u 42 -g build-user build-user
16+
17+
USER build-user
18+
19+
WORKDIR /home/build-user

0 commit comments

Comments
 (0)