Skip to content
Snippets Groups Projects
Dockerfile 4.42 KiB
Newer Older
# This is nrao:workflow
ARG LOCAL_OR_SERVER_PEX=local-pex
FROM python:3.10-slim-buster as base
ARG WS_VERSION=unknown-version
ARG DEPLOY_ENV
ENV DEPLOY_ENV=${DEPLOY_ENV}
ARG ENV_HOST
ENV ENV_HOST=${ENV_HOST}

# Environment variables
ENV PIP_NO_CACHE_DIR false
ENV CAPO_PROFILE docker
ENV CAPO_PATH /home/ssa/capo

# Get postgres/mysql development stuff in the image
RUN apt update \
    && apt install -y --no-install-recommends \
    gcc \
    libmariadb-dev-compat \
    libpq-dev \
    && rm -rf /var/lib/apt/lists

# Create vlapipe group and create vlapipe user placed in vlapipe group
RUN addgroup --gid 6000 vlapipe && \
    useradd --create-home --comment "" --gid 6000 --uid 6000 vlapipe

# Create almapipe group and create almapipe user placed in almapipe group
RUN addgroup --gid 9233 almapipe && \
    useradd --create-home --comment "" --gid 9233 --uid 9233 almapipe

Charlotte Hausman's avatar
Charlotte Hausman committed
# needed for unit tests
USER vlapipe
WORKDIR /home/ssa/capo
COPY --chown=vlapipe:vlapipe docker.properties docker.properties


Andrew Kapuscinski's avatar
Andrew Kapuscinski committed
USER root
WORKDIR /code/
RUN chown vlapipe . && chgrp vlapipe .

# Switch to appuser and set ownership of docker.properties to vlapipe and the vlapipe group
RUN curl -sSL https://install.python-poetry.org | python3 -

ENV PATH "${PATH}:/home/vlapipe/.local/bin"
COPY --chown=vlapipe:vlapipe ./shared ./shared
COPY --chown=vlapipe:vlapipe ./apps/cli ./apps/cli
RUN pip install --upgrade pip
FROM base as local-pex
COPY --chown=vlapipe:vlapipe ./services/workflow/requirements.txt ./requirements.txt
Charlotte Hausman's avatar
Charlotte Hausman committed
COPY --chown=vlapipe:vlapipe ./test-requirements.txt ./test-requirements.txt
RUN SETUPTOOLS_SCM_PRETEND_VERSION=${WS_VERSION} pip install --user -r requirements.txt
Charlotte Hausman's avatar
Charlotte Hausman committed
RUN SETUPTOOLS_SCM_PRETEND_VERSION=${WS_VERSION} pip install --user -r test-requirements.txt

FROM base as server-pex
USER root
Charlotte Hausman's avatar
Charlotte Hausman committed

RUN echo look Mom, I broke the cache!
COPY --chown=vlapipe:vlapipe ./services/workflow/gitlab-requirements.txt ./requirements.txt
Charlotte Hausman's avatar
Charlotte Hausman committed
COPY --chown=vlapipe:vlapipe ./test-requirements.txt ./test-requirements.txt
RUN SETUPTOOLS_SCM_PRETEND_VERSION=${WS_VERSION} pip install --user -r requirements.txt --extra-index-url https://${API_TOKEN}@gitlab.nrao.edu/api/v4/projects/621/packages/pypi/simple
Charlotte Hausman's avatar
Charlotte Hausman committed
RUN SETUPTOOLS_SCM_PRETEND_VERSION=${WS_VERSION} pip install --user -r test-requirements.txt
Charlotte Hausman's avatar
Charlotte Hausman committed

#COPY --chown=vlapipe:vlapipe ./services/workflow/bin/install-pexes.sh ./install-pexes.sh
#RUN . ./install-pexes.sh

FROM ${LOCAL_OR_SERVER_PEX} as pex-base
# HTCondor install
RUN apt update && apt install -y curl gnupg apt-transport-https
RUN curl -fsSL https://research.cs.wisc.edu/htcondor/repo/keys/HTCondor-9.0-Key | apt-key add -
RUN echo "deb [arch=amd64] https://research.cs.wisc.edu/htcondor/repo/debian/9.0 buster main" > /etc/apt/sources.list.d/htcondor.list
RUN echo "deb-src https://research.cs.wisc.edu/htcondor/repo/debian/9.0 buster main" >> /etc/apt/sources.list.d/htcondor.list
RUN apt update && apt install -y procps htcondor nano

# HTCondor setup
# Copy over HTCondor submit node config
# 00-htcondor-9.0.config is environment specific, copy handled later
COPY /config/htcondor/submit/99-workspaces-submit.${DEPLOY_ENV}.conf /etc/condor/config.d/99-workspaces-submit.${DEPLOY_ENV}.conf
COPY /config/htcondor/submit/nrao-nofile.conf /etc/security/limits.d/nrao-nofile.conf
# set ownership of /code directory to vlapipe:vlapipe
# Copy service directory to /code in the image
# set ownership of content to vlapipe and the vlapipe group
COPY --chown=vlapipe:vlapipe ./services/workflow ./services/workflow
WORKDIR /code/services/workflow
RUN poetry install
# Needed for nraorsync to work with the RADIAL cluster
COPY /config/htcondor/submit/condor_ssh_config /home/vlapipe/.ssh/condor_ssh_config

FROM pex-base as prod
ARG WS_VERSION=unknown-version
ENV PYTHONPATH "${PYTHONPATH}:/home/vlapipe/.local"
ENV PATH "${PATH}:/home/vlapipe/.local/bin"

COPY /config/htcondor/00-htcondor-9.0.config /etc/condor/config.d/00-htcondor-9.0.config

CMD /code/services/workflow/bin/boot-condor-and-workflow.sh
FROM pex-base as dev
ARG WS_VERSION=unknown-version
ENV PYTHONPATH "${PYTHONPATH}:/home/vlapipe/.local"
ENV PATH "${PATH}:/home/vlapipe/.local/bin"
ENV PATH $PATH:/lustre/aoc/pipeline/$CAPO_PROFILE/workflow

USER root
COPY /config/htcondor/00-htcondor-9.0.local.config /etc/condor/config.d/00-htcondor-9.0.config

RUN condor_master
CMD /code/services/workflow/bin/boot-condor-and-workflow.sh