Skip to content

Commit 5df48ed

Browse files
authored
Merge pull request #252 from ethan-kusters/ekusters/r81634420-add-support-for-building-swift-docc-render-artifact
Add a new Dockerfile for building Swift-DocC-Render-Artifact
2 parents 364635a + d65db7a commit 5df48ed

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

swift-ci/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ The Dockerfiles used for Continuous Integration are layed out under the top leve
1111
Under that, we have a directory for each of the target branches, e.g.
1212
Continuous Integration for Swift's `master` branch uses the `swift-ci/master` Dockerfiles.
1313

14+
There is also a specific directory (`swift-docc-render`) for the Dockerfile used to build Swift-DocC-Render. Swift-DocC-Render builds separately from the rest of the projects in the Swift toolchain and ships a pre-built copy for use in the toolchain in the Swift-DocC-Render-Artifact repository.
15+
1416
## Continuous Integration
1517

1618
This system is designed to support many distributions.

swift-ci/swift-docc-render/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM node:14.17.4
2+
3+
ARG SWIFT_DOCC_RENDER_BRANCH=main
4+
5+
RUN groupadd -g 998 build-user && \
6+
useradd -m -r -u 998 -g build-user build-user
7+
8+
USER build-user
9+
10+
WORKDIR /home/build-user
11+
12+
RUN git clone https://github.com/apple/swift-docc-render.git
13+
RUN cd swift-docc-render && git checkout $SWIFT_DOCC_RENDER_BRANCH
14+
RUN /home/build-user/swift-docc-render/build-script-helper.py build --verbose
15+
RUN /home/build-user/swift-docc-render/build-script-helper.py test --verbose
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash
2+
#
3+
# This source file is part of the Swift.org open source project
4+
#
5+
# Copyright (c) 2021 Apple Inc. and the Swift project authors
6+
# Licensed under Apache License v2.0 with Runtime Library Exception
7+
#
8+
# See https://swift.org/LICENSE.txt for license information
9+
# See https://swift.org/CONTRIBUTORS.txt for Swift project authors
10+
11+
12+
set -e
13+
14+
function usage() {
15+
echo "$0 --output-path <output_path> [OPTIONS]"
16+
echo ""
17+
echo "<output_path> - Path to the directory where the built Swift-DocC-Render will be copied"
18+
echo ""
19+
echo "OPTIONS"
20+
echo ""
21+
echo "-h --help"
22+
echo "Show help information."
23+
echo ""
24+
echo "-b --branch"
25+
echo "The branch of Swift-DocC-Render to build."
26+
echo ""
27+
}
28+
29+
OUTPUT_PATH=
30+
BRANCH=main
31+
32+
while [ $# -ne 0 ]; do
33+
case "$1" in
34+
-o|--output-path)
35+
shift
36+
OUTPUT_PATH="$1"
37+
;;
38+
-b|--branch)
39+
shift
40+
BRANCH="$1"
41+
;;
42+
-h|--help)
43+
usage
44+
exit 0
45+
;;
46+
*)
47+
echo "Unrecognised argument \"$1\""
48+
echo ""
49+
usage
50+
exit 1
51+
;;
52+
esac
53+
shift
54+
done
55+
56+
if [ -z "${OUTPUT_PATH}" ]; then
57+
echo "Output path cannot be empty. See $0 --help"
58+
exit 1
59+
fi
60+
61+
function filepath() {
62+
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
63+
}
64+
65+
DIRECTORY_ROOT="$(dirname $(filepath $0))"
66+
DOCKERFILE_PATH="$DIRECTORY_ROOT"/Dockerfile
67+
68+
docker build -t swift-docc-render:latest \
69+
--no-cache \
70+
--build-arg SWIFT_DOCC_RENDER_BRANCH="$BRANCH" \
71+
-f "$DOCKERFILE_PATH" \
72+
"$DIRECTORY_ROOT"
73+
74+
CONTAINER_ID=$(docker create swift-docc-render:latest)
75+
76+
docker cp -a $CONTAINER_ID:/home/build-user/swift-docc-render/dist/. "$OUTPUT_PATH"
77+
78+
docker rm $CONTAINER_ID

0 commit comments

Comments
 (0)