#*******************************************************************************
#
#  Dockerfile to build Maiko for Linux to be used by buildRelease github action
#  The output of this is intended to be a directory in the github workspace
#  file system it is not intended to be a useable Docker image.
#
#  Copyright 2023 by Interlisp.org
#
#  Frank Halasz 2023-02-21
#
# ******************************************************************************

FROM ghcr.io/interlisp/maiko-builder
ARG INSTALL_LOCATION=/usr/local/interlisp/maiko
SHELL ["/bin/bash", "-c"]
# Copy over / clean maiko repo
COPY . ${INSTALL_LOCATION}
# Build maiko
RUN cd ${INSTALL_LOCATION}/bin \
    && ./makeright x cleanup \
    && ./makeright x \
    && if [ "$(./machinetype)" = "x86_64" ]; then \
           ./makeright init; \
       fi
# Build specially for WSL1 by "fooling" a linux build
RUN cd ${INSTALL_LOCATION}/bin \
    && arch="$(./machinetype)" \
    && if [ "$arch" = "x86_64" ] || [ "$arch" = "aarch64" ]; then \
           export LDEARCH="${arch}-microsoft-wsl1" \
           && ./makeright x cleanup \
           && ./makeright x \
           && ./makeright init \
           ; \
       fi
