# Copy and extract HEAVY.AI tarball. In own stage so that the temporary tarball
# isn't included in a layer.
FROM ubuntu:20.04 AS extract

WORKDIR /opt/heavyai/
COPY heavyai-latest-Linux-x86_64-cpu.tar.gz /opt/heavyai/
RUN tar xvf heavyai-latest-Linux-x86_64-cpu.tar.gz --strip-components=1 && \
    rm -rf heavyai-latest-Linux-x86_64-cpu.tar.gz

# Build final stage
FROM ubuntu:20.04
LABEL maintainer "HEAVY.AI Support <support@heavy.ai>"

RUN apt-get update && apt-get install -y --no-install-recommends \
        libldap-2.4-2 \
        bsdmainutils \
        wget \
        curl \
        libgeos-dev \
        default-jre-headless \
        libtinfo5 \
        software-properties-common && \
    add-apt-repository ppa:deadsnakes/ppa && \
    apt-get install -y --no-install-recommends \
        python3.10 \
        python3.10-venv \
        libpython3.10 && \
    apt-get remove --purge -y && \
    rm -rf /var/lib/apt/lists/*

COPY --from=extract /opt/heavyai /opt/heavyai

WORKDIR /opt/heavyai

EXPOSE 6274 6273

CMD /opt/heavyai/startheavy --non-interactive --data /var/lib/heavyai/storage --config /var/lib/heavyai/heavy.conf
