# This is nrao:notification
ARG TAGNAME="tmp"
FROM cache:${TAGNAME}

# Build arg that sets environment; sets to "dev" if no build arg is given
ARG env=dev
ENV ENV=${env}
# Build arg that sets Workspace version; sets to "unknown-version" if no build arg is given
ARG WS_VERSION=unknown-version
ENV WS_VERSION=${WS_VERSION}

# Change working directory to /code
WORKDIR /code

# set ownership of /code directory to vlapipe:vlapipe
RUN chown vlapipe . && chgrp vlapipe .

# Install nano for editing
USER root
RUN apt update -y && apt install -y nano

# Switch to vlapipe
USER vlapipe

# Copy service directory to /code in the image
# set ownership of content to vlapipe and the vlapipe group
COPY --chown=vlapipe:vlapipe ./services/notification ./

ENV PYTHONPATH "${PYTHONPATH}:/home/vlapipe/.local"
ENV PATH "${PATH}:/home/vlapipe/.local/bin"

RUN SETUPTOOLS_SCM_PRETEND_VERSION=${WS_VERSION} python setup.py develop --user

# Set Capo for build stage
# Gets reset to proper environment's profile in the deploy stage
ENV CAPO_PROFILE docker

CMD pserve --reload ${ENV}.ini