-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun-in-docker.sh
35 lines (28 loc) · 1.14 KB
/
run-in-docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
# Synopsis:
# Test runner for run.sh in a docker container
# Takes the same arguments as run.sh (EXCEPT THAT SOLUTION AND OUTPUT PATH ARE RELATIVE)
# Builds the Dockerfile
# Runs the docker image passing along the initial arguments
# Arguments:
# $1: exercise slug
# $2: **RELATIVE** path to solution folder (without trailing slash)
# $3: **RELATIVE** path to output directory (without trailing slash)
# Output:
# Writes the tests output to the output directory
# Example:
# ./run-in-docker.sh two-fer ./relative/path/to/two-fer/solution/folder/ ./relative/path/to/output-directory/
# If arguments not provided, print usage and exit
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
echo "usage: ./run-in-docker.sh two-fer ./relative/path/to/two-fer/solution/folder/ ./relative/path/to/output-directory/"
fi
# build docker image
docker build -t typescript-test-runner .
# run image passing the arguments
docker run \
--network none \
--read-only \
--mount type=bind,src=$PWD/$2,dst=/solution/ \
--mount type=bind,src=$PWD/$3,dst=/output/ \
--mount type=tmpfs,dst=/tmp \
typescript-test-runner $1 /solution/ /output/