on master help sign in
Merge pull request #5265 from jeffhappily/update-docker-build

Update docker build

commit286bdeea5755883d6bde3166504fc63f52daf14c authorEmanuel Borsboom <manny@fpcomplete.com> dateSun 12 Apr 2020, 11:45 (7 years ago) parentdefe4fb82cc9d3
2 files changed+38−5
CURATORS.md+2 automated/dockerfiles/build.sh+36−5
CURATORS.md+2
@@ -294,6 +294,8 @@ problems on nightly or LTS major, you need to fix build-constraints.yaml (see
294294info above).
295295
296296### Building LTS minor releases
297+Before running the build, please make sure that the Dockerfile in `automated/dockerfiles/lts-X.Y` is up to date, where X is the major version that you're building and Y is the latest minor version of X for which a Dockerfile exists. If any changes need to be made, (eg, new GHC version), copy `lts-X.Y/Dockerfile` to `lts-X.Z/Dockerfile`, where Z is the minor version you're building, and include the new changes.
298+
297299First run `build.sh` to regenerate updated `ltsXX/work/constraints.yaml` and `ltsXX/work/snapshot-incomplete.yaml` files.
298300
299301For an LTS minor bump, you'll typically want to:
automated/dockerfiles/build.sh+36−5
@@ -90,10 +90,36 @@ case "$LTS_SLUG_ARG" in
9090 ;;
9191esac
9292
93+#
94+# Determine if lts slug is latest
95+#
96+
97+SNAPSHOTS="$(mktemp "lts-snapshots.json.XXXXXX")"
98+trap "rm -f \"$SNAPSHOTS\"" EXIT
99+wget -qO- https://www.stackage.org/download/lts-snapshots.json >"$SNAPSHOTS"
100+
93101LTS_VERSION="${LTS_SLUG#lts-}"
94102LTS_MAJOR="${LTS_VERSION%.*}"
95103LTS_MINOR="${LTS_VERSION#*.}"
96104
105+#
106+# Determine latest LTS version
107+#
108+
109+LATEST_LTS_SLUG=$(jq -r ".[\"lts\"]" $SNAPSHOTS)
110+LATEST_LTS_VERSION="${LATEST_LTS_SLUG#lts-}"
111+LATEST_LTS_MAJOR="${LATEST_LTS_VERSION%.*}"
112+LATEST_LTS_MINOR="${LATEST_LTS_VERSION#*.}"
113+
114+#
115+# Determine latest minor version of the selected major version
116+#
117+
118+MAJOR_LATEST_LTS_SLUG=$(jq -r ".[\"lts-$LTS_MAJOR\"]" $SNAPSHOTS)
119+MAJOR_LATEST_LTS_VERSION="${MAJOR_LATEST_LTS_SLUG#lts-}"
120+MAJOR_LATEST_LTS_MAJOR="${MAJOR_LATEST_LTS_VERSION%.*}"
121+MAJOR_LATEST_LTS_MINOR="${MAJOR_LATEST_LTS_VERSION#*.}"
122+
97123#
98124# Find the Dockerfile for the selected snapshot
99125#
@@ -128,9 +154,14 @@ fi
128154# Create and push additional tags
129155#
130156
131−# Create and push an 'lts-X' tag.
132−tagpush "$DOCKER_REPO:$LTS_SLUG" "$DOCKER_REPO:lts-$LTS_MAJOR"
157+# If we select the latest minor version for the selected major version, then
158+# also create and push an 'lts-X' tag.
159+if [[ $LTS_MINOR -ge $MAJOR_LATEST_LTS_MINOR ]]; then
160+ tagpush "$DOCKER_REPO:$LTS_SLUG" "$DOCKER_REPO:lts-$LTS_MAJOR"
161+fi
133162
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"
163+# If we selected the latest LTS snapshot, also create and push the 'lts' and 'latest' tags.
164+if [[ "$LTS_MAJOR" = "$LATEST_LTS_MAJOR" ]] && [[ $LTS_MINOR -ge $LATEST_LTS_MINOR ]]; then
165+ tagpush "$DOCKER_REPO:$LTS_SLUG" "$DOCKER_REPO:lts"
166+ tagpush "$DOCKER_REPO:$LTS_SLUG" "$DOCKER_REPO:latest"
167+fi