|
| 1 | +# ########### |
| 2 | +# # BUILDER # |
| 3 | +# ########### |
| 4 | + |
| 5 | +# FROM python:3.11.3-slim-buster as builder |
| 6 | + |
| 7 | +# # install system dependencies |
| 8 | +# RUN apt-get update |
| 9 | +# RUN apt-get install -y --no-install-recommends gcc |
| 10 | + |
| 11 | +# # lint |
| 12 | +# RUN pip install --upgrade pip |
| 13 | +# RUN pip install flake8==6.0.0 |
| 14 | +# COPY . /usr/src/app/ |
| 15 | + |
| 16 | +# # By default, Flake8 has a list of error codes that it ignores. |
| 17 | +# # The list used by a version of Flake8 may be different than the list used by a different version |
| 18 | +# RUN flake8 --ignore=E501,E702,F401,F403,F405,F841,W504 ./usr/src/app |
| 19 | + |
| 20 | +# # install python dependencies |
| 21 | +# COPY ./requirements.txt . |
| 22 | +# RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt |
| 23 | + |
| 24 | +# # Change perimissions for /opt |
| 25 | +# RUN chmod +rx /opt |
| 26 | + |
| 27 | +# ######### |
| 28 | +# # FINAL # |
| 29 | +# ######### |
| 30 | + |
| 31 | +# # pull official base image |
| 32 | +# FROM python:3.11.3-slim-buster |
| 33 | + |
| 34 | +# # create directory for the app user |
| 35 | +# RUN mkdir -p /home/app |
| 36 | + |
| 37 | +# # create the app user |
| 38 | +# RUN addgroup --system app && adduser --system --group app |
| 39 | + |
| 40 | +# # create the appropriate directories |
| 41 | +# ENV HOME=/home/app |
| 42 | +# ENV APP_HOME=/home/app/web |
| 43 | +# RUN mkdir $APP_HOME |
| 44 | + |
| 45 | +# # install dependencies |
| 46 | +# RUN apt-get update && apt-get install -y --no-install-recommends netcat vim wget git |
| 47 | + |
| 48 | +# COPY --from=builder /usr/src/app/wheels /wheels |
| 49 | +# COPY --from=builder /usr/src/app/requirements.txt . |
| 50 | +# RUN pip install --upgrade pip |
| 51 | +# RUN pip install --no-cache /wheels/* |
| 52 | + |
| 53 | +# # install Julia and FlashWeave |
| 54 | +# WORKDIR /opt |
| 55 | +# RUN wget https://julialang-s3.julialang.org/bin/linux/x64/1.7/julia-1.7.1-linux-x86_64.tar.gz && \ |
| 56 | +# tar -zxvf julia-1.7.1-linux-x86_64.tar.gz && \ |
| 57 | +# echo "export PATH=/opt/julia-1.7.1/bin:$PATH" >> /home/.bashrc |
| 58 | + |
| 59 | +# ENV PATH="/opt/julia-1.7.1/bin:${PATH}" |
| 60 | + |
| 61 | +# # Get FlashWeave |
| 62 | +# RUN /opt/julia-1.7.1/bin/julia -e 'using Pkg;Pkg.add("FlashWeave")' |
| 63 | + |
| 64 | +# # Get NCBI taxdump |
| 65 | +# WORKDIR /opt/ncbi |
| 66 | +# RUN wget ftp://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz && \ |
| 67 | +# tar -zxvf taxdump.tar.gz && \ |
| 68 | +# mv nodes.dmp tmp && \ |
| 69 | +# rm *.dmp *.tar.gz &&\ |
| 70 | +# mv tmp nodes.tmp |
| 71 | + |
| 72 | +# # Get manta and fuzz |
| 73 | +# WORKDIR $APP_HOME |
| 74 | +# RUN python -m pip install fuzzywuzzy |
| 75 | +# RUN python -m pip install git+https://github.com/hariszaf/manta.git@scipy-version |
| 76 | + |
| 77 | +# # copy project |
| 78 | +# COPY . $APP_HOME |
| 79 | + |
| 80 | +# # # chown all the files to the app user -- UNMUTE THIS ONCE WE ARE IN THE PRODUCTION STAGE |
| 81 | +# # RUN chown -R app:app $APP_HOME |
| 82 | + |
| 83 | +# # # change to the app user |
| 84 | +# # USER app |
| 85 | +# WORKDIR $APP_HOME |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | +######################## |
| 110 | +# SINGLE-STAGE DOCKERFILE |
| 111 | +######################## |
| 112 | + |
| 113 | +FROM python:3.11.3-slim-buster |
| 114 | + |
| 115 | +# Install system dependencies, including wget, gcc, and Julia |
| 116 | +RUN apt-get update && apt-get install -y --no-install-recommends gcc wget netcat vim git |
| 117 | + |
| 118 | +# Install Python dependencies |
| 119 | +RUN pip install --upgrade pip flake8==6.0.0 |
| 120 | + |
| 121 | +# Set environment variables and directories |
| 122 | +ENV HOME=/home/app |
| 123 | +ENV APP_HOME=/home/app/web |
| 124 | +RUN mkdir -p $APP_HOME |
| 125 | + |
| 126 | +# Install Julia |
| 127 | +WORKDIR /opt |
| 128 | +RUN wget https://julialang-s3.julialang.org/bin/linux/x64/1.7/julia-1.7.1-linux-x86_64.tar.gz \ |
| 129 | + && tar -zxvf julia-1.7.1-linux-x86_64.tar.gz \ |
| 130 | + && rm julia-1.7.1-linux-x86_64.tar.gz \ |
| 131 | + && echo "export PATH=/opt/julia-1.7.1/bin:$PATH" >> /etc/bash.bashrc |
| 132 | + |
| 133 | +# Set PATH for Julia |
| 134 | +ENV PATH="/opt/julia-1.7.1/bin:${PATH}" |
| 135 | + |
| 136 | +# Install FlashWeave with Julia |
| 137 | +RUN julia -e 'using Pkg; Pkg.add("FlashWeave")' |
| 138 | + |
| 139 | +# Get NCBI taxdump |
| 140 | +WORKDIR /opt/ncbi |
| 141 | +RUN wget ftp://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz \ |
| 142 | + && tar -zxvf taxdump.tar.gz \ |
| 143 | + && mv nodes.dmp tmp \ |
| 144 | + && rm *.dmp *.tar.gz \ |
| 145 | + && mv tmp nodes.tmp |
| 146 | + |
| 147 | +# Install additional Python packages (manta, fuzzywuzzy) |
| 148 | +WORKDIR /usr/src/app |
| 149 | +RUN pip install fuzzywuzzy \ |
| 150 | + && pip install git+https://github.com/hariszaf/manta.git@scipy-version |
| 151 | + |
| 152 | + |
| 153 | +# Copy requirements |
| 154 | +COPY ./requirements.txt /tmp/requirements.txt |
| 155 | + |
| 156 | + |
| 157 | +# Install Python dependencies |
| 158 | +RUN pip wheel --no-cache-dir --no-deps --wheel-dir /wheels -r /tmp/requirements.txt |
| 159 | +RUN pip install --no-cache /wheels/* |
| 160 | + |
| 161 | + |
| 162 | +# Copy source code |
| 163 | +COPY . /usr/src/app/ |
| 164 | + |
| 165 | +# Lint code |
| 166 | +RUN flake8 --ignore=E501,E702,F401,F403,F405,F841,W504 /usr/src/app |
| 167 | + |
| 168 | + |
| 169 | +# Copy project files to the appropriate directory |
| 170 | +COPY . $APP_HOME |
| 171 | + |
| 172 | +# # Change ownership to app user -- uncomment in production |
| 173 | +# # RUN chown -R app:app $APP_HOME |
| 174 | + |
| 175 | +# # Change to the app user -- uncomment in production |
| 176 | +# # USER app |
| 177 | +WORKDIR $APP_HOME |
0 commit comments