|
| 1 | +# ref: https://github.com/mamba-org/micromamba-docker/blob/main/Dockerfile |
| 2 | + |
| 3 | +FROM condaforge/mambaforge:latest |
| 4 | + |
| 5 | +LABEL maintainer="Ivan Ogasawara <ivan.ogasawara@gmail.com>" |
| 6 | +LABEL org.opencontainers.image.title="EpiGraphHub" |
| 7 | +LABEL org.opencontainers.image.authors="EpiGraphHub Team" |
| 8 | +LABEL org.opencontainers.image.source="https://github.com/thegraphnetwork/python-shiny-app-template" |
| 9 | +LABEL org.opencontainers.image.version="latest" |
| 10 | +LABEL org.opencontainers.image.description="EpiGraphHub" |
| 11 | +LABEL org.thegraphnetwork.epigraphhub.version="latest" |
| 12 | + |
| 13 | +# it is the default, but using it here to have it explicitly |
| 14 | +USER root |
| 15 | + |
| 16 | +SHELL ["/bin/bash", "-c"] |
| 17 | +# Use bash in Dockerfile RUN commands and make sure bashrc is sourced when |
| 18 | +# executing commands with /bin/bash -c |
| 19 | +# Needed to have the micromamba activate command configured etc. |
| 20 | + |
| 21 | +ENV ENV_NAME=shinyapp |
| 22 | +ENV DEBIAN_FRONTEND=noninteractive |
| 23 | +ARG UID=1000 |
| 24 | +ARG GID=1000 |
| 25 | + |
| 26 | +RUN apt-get update -y \ |
| 27 | + && apt-get install -y \ |
| 28 | + build-essential \ |
| 29 | + curl \ |
| 30 | + tini \ |
| 31 | + && rm -rf /var/lib/apt/lists/* \ |
| 32 | + /var/cache/apt/archives \ |
| 33 | + /tmp/* |
| 34 | + |
| 35 | +RUN addgroup --gid ${GID} epigraphhub \ |
| 36 | + && useradd --uid ${UID} --gid ${GID} -ms /bin/bash epigraphhub \ |
| 37 | + && mkdir -p /opt/services \ |
| 38 | + && chmod -R a+rwx /opt/conda /opt/services \ |
| 39 | + && export ENV_NAME="$ENV_NAME" \ |
| 40 | + && chown epigraphhub:epigraphhub /opt/services |
| 41 | + |
| 42 | + |
| 43 | +USER epigraphhub |
| 44 | + |
| 45 | +COPY --chown=epigraphhub:epigraphhub ./conda/ /tmp/conda |
| 46 | + |
| 47 | +WORKDIR /opt/services/shinyapp |
| 48 | + |
| 49 | +ENV PATH /opt/conda/envs/$ENV_NAME/bin:$PATH |
| 50 | +ENV PYTHONPATH='/opt/services/shinyapp' |
| 51 | + |
| 52 | +RUN mamba env create -n $ENV_NAME --file /tmp/conda/local.yaml \ |
| 53 | + && conda clean --all \ |
| 54 | + && find /opt/conda/ -type f,l -name '*.a' -delete \ |
| 55 | + && find /opt/conda/ -type f,l -name '*.pyc' -delete \ |
| 56 | + && find /opt/conda/ -type f,l -name '*.js.map' -delete \ |
| 57 | + && rm -rf /opt/conda/pkgs /tmp/* |
| 58 | + |
| 59 | +COPY --chown=epigraphhub:epigraphhub ./ /opt/services/shinyapp/ |
| 60 | + |
| 61 | +RUN poetry config virtualenvs.create false \ |
| 62 | + && poetry install |
| 63 | + |
| 64 | +COPY --chown=epigraphhub:epigraphhub containers/entrypoint.sh /opt/entrypoint.sh |
| 65 | + |
| 66 | +RUN chmod +x /opt/entrypoint.sh \ |
| 67 | + && echo "source /opt/entrypoint.sh" > ~/.bashrc |
| 68 | + |
| 69 | +ENTRYPOINT ["tini", "--", "/opt/entrypoint.sh"] |
| 70 | +CMD ["shiny run app/app.py"] |
0 commit comments