-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathdocker-build.sh
executable file
·37 lines (30 loc) · 1.03 KB
/
docker-build.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
36
37
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
shopt -s extglob
TMP_DIR=$(mktemp -d)
function main {
local here
here=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )
# We want the image to contain:
# * All of the important stuff from the top-level (html-build) directory
# * But, the Dockerfile from this (ci-build) directory
# And in particular it should *not* contain the top-level Dockerfile, dotfiles, .git/, and
# any html/ and output/ directories that might be hanging around from local testing.
cp "$here/Dockerfile" "$TMP_DIR"
cd "$here/.."
cp -r !(.*|html|output|Dockerfile) "$TMP_DIR"
cd "$TMP_DIR"
trap cleanTemp EXIT
local ghcr_repo="ghcr.io/whatwg/html-build"
# Build the Docker image, using GHCR as a cache. (This will be fast if nothing has changed
# in html-build or its dependencies).
docker pull ghcr.io/whatwg/wattsi
docker pull "$ghcr_repo" || true
docker build --cache-from "$ghcr_repo" --tag "$ghcr_repo" .
}
function cleanTemp {
rm -rf "$TMP_DIR"
}
main "$@"