diff --git a/docker/Dockerfile.win32 b/docker/Dockerfile.win32 index 1973066c..640acbca 100644 --- a/docker/Dockerfile.win32 +++ b/docker/Dockerfile.win32 @@ -1,30 +1,35 @@ ARG IMAGE -FROM $IMAGE +FROM $IMAGE AS base -ARG RELEASE=master -ARG BUILD -ARG HOST +USER opam -WORKDIR /tmp +ENV OPAM_MXE_DEPS=ao-windows,ffmpeg-windows,portaudio-windows,samplerate-windows,ssl-windows,srt-windows,winsvc-windows -USER opam +RUN eval `opam config env` && opam repository remove windows --all && \ + cd /home/opam/ && rm -rf opam-cross-windows && \ + git clone https://github.com/ocaml-cross/opam-cross-windows.git && \ + cd /home/opam/opam-cross-windows/ && \ + opam repository add windows . && \ + opam list --short --recursive --external --vars os-distribution=mxe,os-family=mingw --required-by=$OPAM_MXE_DEPS > /home/opam/mxe-deps -ENV CC "" +USER root -RUN eval `opam config env` && opam update && opam reinstall -y pandoc `echo $OPAM_DEPS | sed -e 's#,# #g'` +# We had pick our own HEAD for mxe +RUN cd /usr/src/mxe/ && \ + git remote add savonet https://github.com/savonet/mxe.git && \ + git fetch savonet && \ + git reset --hard 5b255aa669ac479aebfd00377eb5ef95c1c6622f -RUN git clone --recursive https://github.com/savonet/liquidsoap.git && \ - cd liquidsoap && git checkout $RELEASE && ./bootstrap +RUN cd /usr/src/mxe/ && \ + cat /home/opam/mxe-deps | xargs make curl fdk-aac -RUN eval `opam config env` && cd /tmp/liquidsoap && \ - ./configure --enable-custom-path --host=$HOST OCAMLFIND_TOOLCHAIN=windows && \ - env OCAMLFIND_TOOLCHAIN=windows make +FROM base AS build -RUN mkdir /tmp/win32 +USER opam + +ENV PKG_CONFIG_PATH /usr/src/mxe/usr/x86_64-w64-mingw32.static/lib/pkgconfig -COPY --chown=opam:root win32 /tmp/win32 +RUN export OPAMSOLVERTIMEOUT=320 && eval `opam config env` && opam update && opam reinstall -y --verbose pandoc `echo $OPAM_MXE_DEPS | sed -e 's#,# #g'` -RUN eval `opam config env` && mv /tmp/win32 /tmp/liquidsoap-$BUILD && \ - cd /tmp/liquidsoap-$BUILD && cp /tmp/liquidsoap/src/liquidsoap.exe . && cp /tmp/liquidsoap/libs/*.liq libs && \ - cp -rf `ocamlfind -toolchain windows ocamlc -where`/../../share/camomile . && \ - cd .. && zip -r liquidsoap-$BUILD.zip liquidsoap-$BUILD +FROM $IMAGE +COPY --from=build / / diff --git a/docker/Dockerfile.win32-deps b/docker/Dockerfile.win32-deps deleted file mode 100644 index 133eb72a..00000000 --- a/docker/Dockerfile.win32-deps +++ /dev/null @@ -1,46 +0,0 @@ -ARG IMAGE -FROM $IMAGE AS base - -USER opam - -ENV OPAM_MXE_DEPS=ao-windows,camomile-windows,cry-windows,dtools-windows,duppy-windows,ffmpeg-windows,menhir-windows,mm-windows,ocurl-windows,re-windows,portaudio-windows,samplerate-windows,sedlex-windows,ssl-windows,srt-windows,taglib-windows,winsvc-windows - -RUN git config --global user.email "savonet@rastageeks.org" && git config --global user.name "Romain Beauxis" - -RUN eval `opam config env` && opam repository remove windows --all && \ - cd /home/opam/ && rm -rf opam-cross-windows && \ - git clone https://github.com/ocaml-cross/opam-cross-windows.git && \ - cd /home/opam/opam-cross-windows/ && \ - opam repository add windows . && \ - opam list --short --recursive --external --vars os-distribution=mxe,os-family=mingw --required-by=$OPAM_MXE_DEPS > /home/opam/mxe-deps - -USER root - -RUN apt-get -y update && apt-get -y install python3-mako - -# This is until all cherry-picks below are removed. -RUN cd /usr/src/mxe/ && git config --global user.email "savonet@rastageeks.org" && git config --global user.name "Romain Beauxis" && git remote add savonet https://github.com/savonet/mxe.git && git fetch savonet - -RUN cd /usr/src/mxe/ && git reset --hard 5b255aa669ac479aebfd00377eb5ef95c1c6622f - -RUN cd /usr/src/mxe/ && \ - cat /home/opam/mxe-deps | xargs make curl fdk-aac - -FROM base AS build - -USER root - -RUN apt-get install -y wine64 - -USER opam - -ENV CC "" - -ENV PKG_CONFIG_PATH /usr/src/mxe/usr/x86_64-w64-mingw32.static/lib/pkgconfig - -ENV TOOLPREF64=/usr/src/mxe/usr/bin/x86_64-w64-mingw32.static- - -RUN export OPAMSOLVERTIMEOUT=320 && eval `opam config env` && opam update && opam reinstall -y --verbose pandoc `echo $OPAM_MXE_DEPS | sed -e 's#,# #g' | sed -e 's#ffmpeg-windows##' | sed -e 's#ocurl-windows##' | sed -e 's#src-windows##'` - -FROM $IMAGE -COPY --from=build / / diff --git a/docker/build-win32.sh b/docker/build-win32.sh index f9770c0c..530e9a01 100755 --- a/docker/build-win32.sh +++ b/docker/build-win32.sh @@ -1,39 +1,17 @@ #!/bin/sh -BUILD=$1 -RELEASE=$2 -SYSTEM=$3 -OCAML_VERSION=$4 - -if [ -z "${RELEASE}" ]; then - RELEASE="main" -fi - -if [ -z "${SYSTEM}" ]; then - SYSTEM="x64" -fi - -if [ -z "${OCAML_VERSION}" ]; then - OCAML_VERSION=4.12.0 -fi - +SYSTEM="x64" +OCAML_VERSION=4.14.1 BASE_IMAGE="ocamlcross/windows-${SYSTEM}-base:${OCAML_VERSION}" -DEPS_IMAGE="savonet/liquidsoap-win32-deps-${SYSTEM}" IMAGE="savonet/liquidsoap-win32-${SYSTEM}" - -if [ "${SYSTEM}" = "x64" ]; then - HOST="x86_64-w64-mingw32.static" -else - HOST="i686-w64-mingw32.static" -fi - -echo docker build -f Dockerfile.win32-deps -t ${DEPS_IMAGE} \ - --build-arg IMAGE=${BASE_IMAGE} . - -exit 0 - -docker build -f Dockerfile.win32 -t ${IMAGE} --no-cache --build-arg RELEASE=${RELEASE} \ - --build-arg IMAGE=${DEPS_IMAGE} --build-arg HOST=${HOST} --build-arg BUILD=${BUILD} . -id=$(docker create ${IMAGE}) -docker cp ${id}:/tmp/liquidsoap-${BUILD}.zip . -docker rm -v ${id} +HOST="x86_64-w64-mingw32.static" + +depot build \ + -f Dockerfile.win32 \ + -t ${IMAGE} \ + --platform linux/amd64 \ + --build-arg RELEASE=${RELEASE} \ + --build-arg IMAGE=${BASE_IMAGE} \ + --build-arg HOST=${HOST} \ + --build-arg BUILD=${BUILD} \ + .