Skip to content

Commit

Permalink
Merge pull request #122 from umccr/docker_update
Browse files Browse the repository at this point in the history
docker: use multi-stage build
  • Loading branch information
pdiakumis authored Aug 20, 2024
2 parents ec41035 + 049fafd commit 10ec25d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3,551 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*
!conda
!conda/env/lock/dracarys-linux-64.lock
!.dockerignore
53 changes: 35 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
FROM condaforge/mambaforge:22.9.0-2 as conda
LABEL maintainer="https://github.com/pdiakumis"
FROM ubuntu:20.04
LABEL org.opencontainers.image.authors="[email protected]" \
org.opencontainers.image.description="Dracarys Workflow Output Tidier" \
org.opencontainers.image.source="https://github.com/umccr/dracarys" \
org.opencontainers.image.url="https://github.com/umccr/dracarys" \
org.opencontainers.image.documentation="https://umccr.github.io/dracarys" \
org.opencontainers.image.licenses="MIT"

# install conda-lock
RUN mamba config \
--set always_yes yes \
--set always_copy yes && \
mamba install \
-c conda-forge \
-c nodefaults \
conda-lock && \
mamba clean --all --force-pkgs-dirs
ARG MINIF="miniforge"
ARG MINIF_VERSION="24.3.0-0"
ARG MINIF_URL="https://github.com/conda-forge/${MINIF}/releases/download/${MINIF_VERSION}/Miniforge3-${MINIF_VERSION}-Linux-x86_64.sh"

# install core pkgs, miniforge
RUN apt-get update && \
apt-get install --yes --no-install-recommends \
bash bzip2 curl less wget zip ca-certificates && \
apt-get clean && \
curl --silent -L "${MINIF_URL}" -o "${MINIF}.sh" && \
/bin/bash "${MINIF}.sh" -b -p "/opt/${MINIF}/" && \
rm "${MINIF}.sh"

# create conda env
ENV PATH="/opt/${MINIF}/bin:$PATH"
ARG CONDA_ENV_DIR="/home/conda_envs"
ARG DRACARYS_LOCK="dracarys-linux-64.lock"
ARG ENV_NAME="dracarys_env"
COPY ./conda/env/lock/${DRACARYS_LOCK} .
RUN conda-lock install --name ${ENV_NAME} ${DRACARYS_LOCK} && \
mamba clean --all --force-pkgs-dirs
COPY "./conda/env/lock/${DRACARYS_LOCK}" "${CONDA_ENV_DIR}/"
RUN conda create -n "dracarys_env" --file "${CONDA_ENV_DIR}/${DRACARYS_LOCK}"
RUN conda clean --all --force-pkgs-dirs --yes

# Now copy env to smaller image
FROM quay.io/bioconda/base-glibc-debian-bash:3.1

COPY --from=0 "/opt/miniforge/envs/" "/opt/miniforge/envs/"

ARG MAMBA_PREFIX="/opt/conda"
ENV PATH="${MAMBA_PREFIX}/envs/${ENV_NAME}/bin:${PATH}"
ENV CONDA_PREFIX="${MAMBA_PREFIX}/envs/${ENV_NAME}"
# env is activated by default
ARG MINIF="miniforge"
ARG CONDA_ENV_NAME="dracarys_env"
ENV PATH="/opt/${MINIF}/envs/${CONDA_ENV_NAME}/bin:${PATH}"
ENV CONDA_PREFIX="/opt/${MINIF}/envs/${CONDA_ENV_NAME}"

CMD [ "dracarys.R" ]
Loading

0 comments on commit 10ec25d

Please sign in to comment.