on master help sign in
Modify docker build script
commit0f114e0414058bdd82cb77aa1a585a1be9ad7a6d authorJeff Happily <goodboy96@live.com.my> dateFri 14 Feb 2020, 12:04 (7 years ago) parentd6b16c4
4 files changed+109−48
automated/build.sh+9 automated/dockerfiles/README.md+2−5 automated/dockerfiles/build.sh+9−43 automated/dockerfiles/lts-14.0/Dockerfile.sub+89
automated/build.sh+9
@@ -145,6 +145,15 @@ docker run $ARGS_UPLOAD $IMAGE /bin/bash -c "curator upload-docs --target $TARGE
145145
146146docker run $ARGS_UPLOAD $IMAGE curator legacy-bulk --stackage-snapshots /dot-stackage/curator/stackage-snapshots/ --lts-haskell /dot-stackage/curator/lts-haskell/ --stackage-nightly /dot-stackage/curator/stackage-nightly/
147147
148+# Build and push docker image fpco/stack-build & fpco/stack-build-small for current release
149+
150+if [ $SHORTNAME = "lts" ]
151+then
152+ $ROOT/dockerfiles/build.sh $TARGET
153+ $ROOT/dockerfiles/build.sh --push $TARGET
154+ $ROOT/dockerfiles/build.sh --push --small $TARGET
155+fi
156+
148157(
149158if [ $SHORTNAME = "lts" ]
150159then
automated/dockerfiles/README.md+2−5
@@ -8,7 +8,7 @@ images. This script and its Dockerfiles are used for building images for LTS >=
88Usage
99-----
1010
11− ./build.sh [--push] [--dry-run] [--small] lts-X.Y|lts-X|lts]"
11+ ./build.sh [--push] [--dry-run] [--small] lts-X.Y"
1212
1313Options
1414-------
@@ -25,10 +25,7 @@ Options
2525Argument
2626---------
2727
28−If you specify and exact LTS version, that image will be built. If you only
29−specify the major version, then an image for the latest minor version for that
30−major version will be built. If you specify 'lts', an image for the latest LTS
31−snapshot is built.
28+The image for the selected LTS version will be built.
3229
3330This searches for a Dockerfile for the selected snapshot in
3431`lts-X.Y/Dockerfile`, and if one isn't found reuses the same image as built the
automated/dockerfiles/build.sh+9−43
@@ -21,7 +21,7 @@ VARIANT=build
2121usage() {
2222 echo "$0: $1" >&2
2323 echo
24− echo "Usage: $0 [--push] [--dry-run] [--small] lts-X.Y|lts-X|lts]"
24+ echo "Usage: $0 [--push] [--dry-run] [--small] lts-X.Y]"
2525 echo "See README.md for more information."
2626 echo
2727 exit 1
@@ -77,27 +77,16 @@ while [[ $# -gt 0 ]]; do
7777 esac
7878done
7979
80−#
81−# Determine actual snapshot version from aliases
82−#
83−
84−SNAPSHOTS="$(mktemp "lts-snapshots.json.XXXXXX")"
85−trap "rm -f \"$SNAPSHOTS\"" EXIT
86−wget -qO- https://www.stackage.org/download/lts-snapshots.json >"$SNAPSHOTS"
87−
8880case "$LTS_SLUG_ARG" in
8981 "")
90− usage "Missing argument: snapshot or alias"
82+ usage "Missing argument: snapshot"
9183 ;;
9284 lts-*.*)
9385 LTS_SLUG="$LTS_SLUG_ARG"
9486 ;;
9587 *)
96− LTS_SLUG=$(jq -r ".[\"$LTS_SLUG_ARG\"]" "$SNAPSHOTS")
97− if [[ -z "$LTS_SLUG" || "$LTS_SLUG" = "null" ]]; then
98− echo "$0: Cannot find LTS version for slug: $LTS_SLUG_ARG" >&2
99− exit 1
100− fi
88+ echo "$0: Wrong snapshot format: $LTS_SLUG_ARG" >&2
89+ exit 1
10190 ;;
10291esac
10392
@@ -105,24 +94,6 @@ LTS_VERSION="${LTS_SLUG#lts-}"
10594LTS_MAJOR="${LTS_VERSION%.*}"
10695LTS_MINOR="${LTS_VERSION#*.}"
10796
108−#
109−# Determine latest LTS version
110−#
111−
112−LATEST_LTS_SLUG=$(jq -r ".[\"lts\"]" $SNAPSHOTS)
113−LATEST_LTS_VERSION="${LATEST_LTS_SLUG#lts-}"
114−LATEST_LTS_MAJOR="${LATEST_LTS_VERSION%.*}"
115−LATEST_LTS_MINOR="${LATEST_LTS_VERSION#*.}"
116−
117−#
118−# Determine latest minor version of the selected major version
119−#
120−
121−MAJOR_LATEST_LTS_SLUG=$(jq -r ".[\"lts-$LTS_MAJOR\"]" $SNAPSHOTS)
122−MAJOR_LATEST_LTS_VERSION="${MAJOR_LATEST_LTS_SLUG#lts-}"
123−MAJOR_LATEST_LTS_MAJOR="${MAJOR_LATEST_LTS_VERSION%.*}"
124−MAJOR_LATEST_LTS_MINOR="${MAJOR_LATEST_LTS_VERSION#*.}"
125−
12697#
12798# Find the Dockerfile for the selected snapshot
12899#
@@ -157,14 +128,9 @@ fi
157128# Create and push additional tags
158129#
159130
160−# If we select the latest minor version for the selected major version, then
161−# also create and push an 'lts-X' tag.
162−if [[ "$MAJOR_LATEST_LTS_VERSION" = "$LTS_VERSION" ]]; then
163− tagpush "$DOCKER_REPO:$LTS_SLUG" "$DOCKER_REPO:lts-$LTS_MAJOR"
164−fi
131+# Create and push an 'lts-X' tag.
132+tagpush "$DOCKER_REPO:$LTS_SLUG" "$DOCKER_REPO:lts-$LTS_MAJOR"
165133
166−# If we selected the latest LTS snapshot, also create and push the 'lts' and 'latest' tags.
167−if [[ "$LATEST_LTS_VERSION" = "$LTS_VERSION" ]]; then
168− tagpush "$DOCKER_REPO:$LTS_SLUG" "$DOCKER_REPO:lts"
169− tagpush "$DOCKER_REPO:$LTS_SLUG" "$DOCKER_REPO:latest"
170−fi
134+# Create and push the 'lts' and 'latest' tags.
135+tagpush "$DOCKER_REPO:$LTS_SLUG" "$DOCKER_REPO:lts"
136+tagpush "$DOCKER_REPO:$LTS_SLUG" "$DOCKER_REPO:latest"
automated/dockerfiles/lts-14.0/Dockerfile.subnew file+89
@@ -0,0 +1,89 @@
1+FROM ubuntu:18.04
2+
3+LABEL maintainer="manny@fpcomplete.com"
4+
5+ARG GHC_VERSION=8.6.5
6+ARG LTS_SLUG=lts-14.0
7+ARG PID1_VERSION=0.1.2.0
8+ARG STACK_VERSION=2.1.3
9+ARG CUDA_VERSION=10.0
10+ARG JVM_PATH=/usr/lib/jvm/java-8-openjdk-amd64
11+ARG LLVM_VERSION=3.9
12+ARG BOOTSTRAP_COMMIT=d4143f1845f26e8e99d0a1a8134d6ff535ab98b2
13+ARG DEBIAN_FRONTEND=noninteractive
14+ARG VARIANT=build
15+ARG STACK_ROOT=/home/stackage/.stack
16+
17+#
18+# Set encoding to UTF-8 and PATH to find GHC and cabal/stack-installed binaries.
19+#
20+
21+ENV LANG=C.UTF-8 \
22+ LC_ALL=C.UTF-8 \
23+ PATH=/root/.local/bin:/usr/local/cuda-$CUDA_VERSION/bin:$STACK_ROOT/programs/x86_64-linux/ghc-$GHC_VERSION/bin:$PATH \
24+ CUDA_PATH=/usr/local/cuda-$CUDA_VERSION \
25+ CPATH=$JVM_PATH/include:$JVM_PATH/include/linux:/usr/lib/llvm-$LLVM_VERSION/include
26+
27+#
28+# Install pre-requisites
29+#
30+
31+RUN apt-get update && \
32+ apt-get install -y --no-install-recommends \
33+ wget netbase ca-certificates g++ gcc libc6-dev libffi-dev libgmp-dev \
34+ make xz-utils zlib1g-dev git gnupg libtinfo-dev && \
35+ rm -rf /var/lib/apt/lists/*
36+
37+#
38+# Use Stackage's debian-bootstrap.sh script to install system libraries and
39+# tools required to build any Stackage package.
40+# Re-installs 'stack' *after* running debian-bootstrap.sh since that may have
41+# installed a different version.
42+# In the case of 'small' image, just install Stack and GHC.
43+#
44+
45+RUN if [ "$VARIANT" != "small" ]; then \
46+ wget -qO- https://raw.githubusercontent.com/fpco/stackage/$BOOTSTRAP_COMMIT/debian-bootstrap.sh | sed "s/^GHCVER=8.6.5$/GHCVER=$GHC_VERSION/" | GHCVER=$GHC_VERSION bash; \
47+ fi && \
48+ wget -qO- https://github.com/commercialhaskell/stack/releases/download/v$STACK_VERSION/stack-$STACK_VERSION-linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C /usr/bin '*/stack' && \
49+ if [ "$VARIANT" = "small" ]; then \
50+ stack setup --resolver ghc-$GHC_VERSION; \
51+ fi && \
52+ rm -rf /var/lib/apt/lists/* && \
53+ cd $STACK_ROOT && \
54+ find . -type f -not -path "./programs/x86_64-linux/ghc-$GHC_VERSION/*" -exec rm '{}' \; && \
55+ find . -type d -print0 |sort -rz |xargs -0 rmdir 2>/dev/null || true
56+
57+#
58+# Configure Stack to use the GHC installed in the Docker image rather than installing its own
59+#
60+
61+RUN mkdir /etc/stack/ && \
62+ echo "system-ghc: true" >/etc/stack/config.yaml
63+
64+#
65+# Use 'stack' to install basic Haskell tools like alex, happy, and cpphs. We
66+# remove most of the STACK_ROOT afterward to save space, but keep the 'share'
67+# files that some of these tools require.
68+#
69+
70+RUN stack --resolver=$LTS_SLUG --local-bin-path=/usr/bin install \
71+ happy alex cpphs gtk2hs-buildtools hscolour hlint hindent && \
72+ cd $STACK_ROOT && \
73+ find . -type f -not -path './snapshots/*/share/*' -and -not -path "./programs/x86_64-linux/ghc-$GHC_VERSION/*" -exec rm '{}' \; && \
74+ find . -type d -print0 |sort -rz |xargs -0 rmdir 2>/dev/null || true
75+
76+#
77+# Install 'pid1' init daemon
78+#
79+
80+RUN wget -O- "https://github.com/fpco/pid1/releases/download/v$PID1_VERSION/pid1-$PID1_VERSION-linux-x86_64.tar.gz" | tar xzf - -C /usr/local && \
81+ chown root:root /usr/local/sbin && \
82+ chown root:root /usr/local/sbin/pid1
83+
84+#
85+# Set up pid1 entrypoint and default command
86+#
87+
88+ENTRYPOINT ["/usr/local/sbin/pid1"]
89+CMD ["bash"]