#! /bin/bash

# Script for running the tests in a container and producing a Docker image with
# the "local-build" tag that contains the installed packages.

set -ex

cat <<EOF > Dockerfile.test
FROM ocaml/opam:${DISTRO}_ocaml-${OCAML_VERSION}
COPY . /xs-opam
ENV BASE_REMOTE=${BASE_REMOTE}
ENV EXTRA_REMOTES=${EXTRA_REMOTES}
ENV COMPILE_ALL=${COMPILE_ALL}
ENV OPAM_LINT=${OPAM_LINT}
ENV CHECK_UNUSED=${CHECK_UNUSED}
ENV CHECK_TEST_DEPENDENCIES=${CHECK_TEST_DEPENDENCIES}
ENV OCAML_VERSION=${OCAML_VERSION}
ENV DISTRO=${DISTRO}
ENV SAFE_STRING=${SAFE_STRING}
WORKDIR /xs-opam
RUN bash tools/travis.sh
EOF
docker build -t local-build -f Dockerfile.test .

#! /bin/bash

# Script for running the tests in a container and producing a Docker image with
# the "local-build" tag that contains the installed packages.

set -ex

cat <<EOF > Dockerfile.test
FROM ocaml/opam2:${DISTRO}
COPY . /xs-opam
ENV BASE_REMOTE=${BASE_REMOTE}
ENV EXTRA_REMOTES=${EXTRA_REMOTES}
ENV COMPILE_ALL=${COMPILE_ALL}
ENV OPAM_LINT=${OPAM_LINT}
ENV CHECK_UNUSED=${CHECK_UNUSED}
ENV CHECK_TEST_DEPENDENCIES=${CHECK_TEST_DEPENDENCIES}
ENV OCAML_VERSION=${OCAML_VERSION}
ENV DISTRO=${DISTRO}
ENV SAFE_STRING=${SAFE_STRING}
WORKDIR /xs-opam
RUN bash tools/travis.sh
EOF
docker build -t local-build -f Dockerfile.test .

Use opam2 as base for docker containers
Use opam2 as base for docker containers

Opam2 uses 4.06.1 as compiler by default, and doesn't have per compiler
version containers for all distros anymore, see:
https://hub.docker.com/r/ocaml/opam2/tags/

The preferred way to use another ocaml version is to use opam switch
create:
https://github.com/ocaml/ocaml-ci-scripts/blob/master/.travis-docker.sh#L62

Since we are using 4.06.1 now doing so would be redundant, but when we
switch to 4.07 this would unfortunately slow down our build times as
we'd need to build the compiler itself too.

Signed-off-by: Edwin Török <c8d178016cbaf8a6ef23c2cbc9db96123c48b7dc@citrix.com>
