ARG BUILD_IMAGE=artefact.skao.int/ska-build-python:0.3.2
ARG BASE_IMAGE=artefact.skao.int/ska-tango-images-tango-python:0.3.1
FROM $BUILD_IMAGE AS build

ENV VIRTUAL_ENV=/app
RUN set -xe; \
    apt-get update; \
    apt-get install -y --no-install-recommends \
        python3-venv; \
    python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN pip install pytango>=10.1.0

# We don't want to copy pip into the runtime image
RUN pip uninstall -y pip

COPY ./MyServer.py /app/bin/MyServer
RUN chmod +x /app/bin/MyServer

FROM $BASE_IMAGE

ENV VIRTUAL_ENV=/app
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

COPY --from=build $VIRTUAL_ENV $VIRTUAL_ENV
