rust-musl-builder/hooks/build
Eric Kidd e50cbda169 Allow building with OpenSSL 1.0 or 1.1
It turns out that some popular libaries still have problems with OpenSSL
1.1, particularly `postgres` 0.15. So we'll build two sets of images
now.

We also explain the new image tagging scheme, and fix a bug wher the
test script didn't test the newly built image.
2019-04-27 09:21:32 -04:00

48 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
#
# This script is responsible for calling `docker build` on behalf of GitHub. But
# what it _really_ does is translate `DOCKER_TAG` into the builds args `TARGET`
# and `OPENSSL_VERSION`.
# Abort if anything goes wrong.
set -euo pipefail
# Default to using OpenSSL 1.0 for a while longer, because 1.1 is
# incompatible with the crates postgres 0.15 and openssl 0.9, which
# are still widely used.
OPENSSL_VERSION=1.0.2r
# Pick an appropriate Docker tag
case "$DOCKER_TAG" in
*-openssl11)
DOCKER_TAG_WITHOUT_OPENSSL="${DOCKER_TAG/-openssl11/}"
OPENSSL_VERSION=1.1.1b
;;
*)
DOCKER_TAG_WITHOUT_OPENSSL="$DOCKER_TAG"
;;
esac
# Decide what Rust toolchain to use.
case "$DOCKER_TAG_WITHOUT_OPENSSL" in
# Always map the Docker tags `latest` and `experimental` to stable Rust.
latest)
TOOLCHAIN=stable
;;
# Strip `experimental-` from other `experimental-*` tags.
experimental-*)
TOOLCHAIN="${DOCKER_TAG_WITHOUT_OPENSSL/experimental-/}"
;;
# Pass all other tags through.
*)
TOOLCHAIN="$DOCKER_TAG_WITHOUT_OPENSSL"
;;
esac
# Run the build.
docker build \
--build-arg TOOLCHAIN="$TOOLCHAIN" \
--build-arg OPENSSL_VERSION="$OPENSSL_VERSION" \
-t "$IMAGE_NAME" \
.