Skip to content

Add a new Dockerfile for building Swift-DocC-Render-Artifact #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions swift-ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ The Dockerfiles used for Continuous Integration are layed out under the top leve
Under that, we have a directory for each of the target branches, e.g.
Continuous Integration for Swift's `master` branch uses the `swift-ci/master` Dockerfiles.

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.

## Continuous Integration

This system is designed to support many distributions.
Expand Down
15 changes: 15 additions & 0 deletions swift-ci/swift-docc-render/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:14.17.4

ARG SWIFT_DOCC_RENDER_BRANCH=main

RUN groupadd -g 998 build-user && \
useradd -m -r -u 998 -g build-user build-user

USER build-user

WORKDIR /home/build-user

RUN git clone https://github.com/apple/swift-docc-render.git
RUN cd swift-docc-render && git checkout $SWIFT_DOCC_RENDER_BRANCH
RUN /home/build-user/swift-docc-render/build-script-helper.py build --verbose
RUN /home/build-user/swift-docc-render/build-script-helper.py test --verbose
78 changes: 78 additions & 0 deletions swift-ci/swift-docc-render/build-swift-docc-render.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/bash
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2021 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See https://swift.org/LICENSE.txt for license information
# See https://swift.org/CONTRIBUTORS.txt for Swift project authors


set -e

function usage() {
echo "$0 --output-path <output_path> [OPTIONS]"
echo ""
echo "<output_path> - Path to the directory where the built Swift-DocC-Render will be copied"
echo ""
echo "OPTIONS"
echo ""
echo "-h --help"
echo "Show help information."
echo ""
echo "-b --branch"
echo "The branch of Swift-DocC-Render to build."
echo ""
}

OUTPUT_PATH=
BRANCH=main

while [ $# -ne 0 ]; do
case "$1" in
-o|--output-path)
shift
OUTPUT_PATH="$1"
;;
-b|--branch)
shift
BRANCH="$1"
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unrecognised argument \"$1\""
echo ""
usage
exit 1
;;
esac
shift
done

if [ -z "${OUTPUT_PATH}" ]; then
echo "Output path cannot be empty. See $0 --help"
exit 1
fi

function filepath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}

DIRECTORY_ROOT="$(dirname $(filepath $0))"
DOCKERFILE_PATH="$DIRECTORY_ROOT"/Dockerfile

docker build -t swift-docc-render:latest \
--no-cache \
--build-arg SWIFT_DOCC_RENDER_BRANCH="$BRANCH" \
-f "$DOCKERFILE_PATH" \
"$DIRECTORY_ROOT"

CONTAINER_ID=$(docker create swift-docc-render:latest)

docker cp -a $CONTAINER_ID:/home/build-user/swift-docc-render/dist/. "$OUTPUT_PATH"

docker rm $CONTAINER_ID