generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dockerfile
92 lines (67 loc) · 3.05 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Create an argument to pull a particular version of micromamba image
ARG micromamba_version
ARG micromamba_version=${micromamba_version:-1.5.3}
############# micromamba image ##################
FROM mambaorg/micromamba:${micromamba_version} as micromamba
RUN echo "Getting micromamba image"
############# base image ##################
FROM ubuntu:focal as base
# if image defaults to a non-root user, then we may want to make the
# next 3 ARG commands match the values in our image.
ENV MAMBA_USER=$MAMBA_USER
ENV MAMBA_USER_ID=$MAMBA_USER_ID
ENV MAMBA_USER_GID=$MAMBA_USER_GID
ENV MAMBA_ROOT_PREFIX="/opt/conda"
ENV MAMBA_EXE="/bin/micromamba"
COPY --from=micromamba "$MAMBA_EXE" "$MAMBA_EXE"
COPY --from=micromamba /usr/local/bin/_activate_current_env.sh /usr/local/bin/_activate_current_env.sh
COPY --from=micromamba /usr/local/bin/_dockerfile_shell.sh /usr/local/bin/_dockerfile_shell.sh
COPY --from=micromamba /usr/local/bin/_entrypoint.sh /usr/local/bin/_entrypoint.sh
COPY --from=micromamba /usr/local/bin/_dockerfile_initialize_user_accounts.sh /usr/local/bin/_dockerfile_initialize_user_accounts.sh
COPY --from=micromamba /usr/local/bin/_dockerfile_setup_root_prefix.sh /usr/local/bin/_dockerfile_setup_root_prefix.sh
# Install system dependencies
ARG DEBIAN_FRONTEND=noninteractive
# local apt mirror support
# start every stage with updated apt sources
ARG APT_MIRROR_NAME=
RUN if [ -n "$APT_MIRROR_NAME" ]; then sed -i.bak -E '/security/! s^https?://.+?/(debian|ubuntu)^http://'"$APT_MIRROR_NAME"'/\1^' /etc/apt/sources.list && grep '^deb' /etc/apt/sources.list; fi
RUN apt-get update --allow-releaseinfo-change --fix-missing \
&& apt-get install --no-install-recommends -y \
dos2unix \
ca-certificates \
&& apt clean autoclean \
&& apt autoremove --yes \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/
# Create working directory
ENV WORKDIR=/data
# Set up volume directory
VOLUME ${WORKDIR}
# Set up working directory
WORKDIR ${WORKDIR}
# Allow permission to read and write to working directory
RUN chmod -R a+rwx ${WORKDIR}
# Create a program variable
ENV PROJECT_DIR=/seqsender
# Set up a volume directory
VOLUME ${PROJECT_DIR}
# Copy all files to project directory
COPY . ${PROJECT_DIR}
############ Set-up micromamba environment ##################
# Copy requirement files to program directory
COPY env.yaml "${PROJECT_DIR}/env.yaml"
# Set up environments
RUN micromamba install --yes --name base -f "${PROJECT_DIR}/env.yaml" \
&& micromamba clean --all --yes
############# Launch PROGRAM ##################
# Copy bash script to run PROGRAM to docker image
COPY seqsender-kickoff "${PROJECT_DIR}/seqsender-kickoff"
# Convert bash script from Windows style line endings to Unix-like control characters
RUN dos2unix "${PROJECT_DIR}/seqsender-kickoff"
# Allow permission to excute the bash script
RUN chmod a+x "${PROJECT_DIR}/seqsender-kickoff"
# Allow permission to read and write to program directory
RUN chmod a+rwx ${PROJECT_DIR}
# Export bash script to path
ENV PATH="$PATH:${PROJECT_DIR}"
# Activate conda environment
ENV PATH="$PATH:${MAMBA_ROOT_PREFIX}/bin"