# Copy and extract HEAVY.AI tarball. In own stage so that the temporary tarball
# isn't included in a layer.
FROM ubuntu:18.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:18.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 \
        default-jre-headless && \
    apt-get remove --purge -y && \
    rm -rf /var/lib/apt/lists/*

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

WORKDIR /opt/heavyai

EXPOSE 6277

CMD /opt/heavyai/bin/heavydb_sd_server --port 6277 --path /var/lib/heavyai/storage/sds
