forked from LeahRoberts/MAG_pangenome_pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from bacpop/docker
Docker
- Loading branch information
Showing
6 changed files
with
160 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Build and push Docker image | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
- 'docker' | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: | ||
- 'main' | ||
create: | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
docker-upload: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: samhorsfield96/celebrimbor | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to DockerHub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_REGISTRY_USERNAME }} | ||
password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }} | ||
- name: Build and push | ||
id: docker_build | ||
uses: docker/build-push-action@v3 | ||
with: | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
file: docker/Dockerfile | ||
provenance: false | ||
- name: Image digest | ||
run: echo ${{ steps.docker_build.outputs.digest }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
../test/* | ||
test/* | ||
.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# From https://github.com/kaust-vislab/python-data-science-project | ||
FROM ubuntu:20.04 | ||
|
||
LABEL maintainer="Sam Horsfield <[email protected]>" | ||
|
||
SHELL [ "/bin/bash", "--login", "-c" ] | ||
|
||
RUN apt-get update --fix-missing && \ | ||
apt-get install -y wget bzip2 curl git && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Create a non-root user | ||
ARG username=celebrimbor-usr | ||
ARG uid=1000 | ||
ARG gid=100 | ||
ENV USER $username | ||
ENV UID $uid | ||
ENV GID $gid | ||
ENV HOME /home/$USER | ||
|
||
RUN adduser --disabled-password \ | ||
--gecos "Non-root user" \ | ||
--uid $UID \ | ||
--gid $GID \ | ||
--home $HOME \ | ||
$USER | ||
|
||
COPY environment.yml /tmp/ | ||
RUN chown $UID:$GID /tmp/environment.yml | ||
|
||
COPY docker/entrypoint.sh /usr/local/bin/ | ||
RUN chown $UID:$GID /usr/local/bin/entrypoint.sh && \ | ||
chmod u+x /usr/local/bin/entrypoint.sh | ||
|
||
USER $USER | ||
|
||
# install miniconda | ||
ENV MINICONDA_VERSION latest | ||
ENV CONDA_DIR $HOME/miniconda3 | ||
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-$MINICONDA_VERSION-Linux-x86_64.sh -O ~/miniconda.sh && \ | ||
chmod +x ~/miniconda.sh && \ | ||
~/miniconda.sh -b -p $CONDA_DIR && \ | ||
rm ~/miniconda.sh | ||
|
||
# make non-activate conda commands available | ||
ENV PATH=$CONDA_DIR/bin:$PATH | ||
|
||
# make conda activate command available from /bin/bash --login shells | ||
RUN echo ". $CONDA_DIR/etc/profile.d/conda.sh" >> ~/.profile | ||
|
||
# make conda activate command available from /bin/bash --interative shells | ||
RUN conda init bash | ||
|
||
# create a project directory inside user home | ||
# (this isn't used with a clone running snakemake) | ||
ENV PROJECT_DIR $HOME/app | ||
RUN mkdir $PROJECT_DIR | ||
# copy the code in | ||
COPY . $PROJECT_DIR | ||
WORKDIR $PROJECT_DIR | ||
|
||
# build the conda environment | ||
ENV ENV_PREFIX $PROJECT_DIR/env | ||
RUN conda update --name base --channel defaults conda && \ | ||
conda env create --prefix $ENV_PREFIX --file /tmp/environment.yml --yes && \ | ||
conda clean --all --yes && \ | ||
conda activate $ENV_PREFIX && \ | ||
cargo install cgt_bacpop && \ | ||
mkdir bakta_db && \ | ||
bakta_db download --output bakta_db --type light && \ | ||
conda deactivate | ||
|
||
# add rust binary to path | ||
ENV PATH="$HOME/.cargo/bin:${PATH}" | ||
|
||
# use an entrypoint script to insure conda environment is properly activated at runtime | ||
USER root | ||
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ] | ||
|
||
# default of running shell is fine | ||
#CMD [ "bash" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash --login | ||
set -e | ||
|
||
conda activate $HOME/app/env | ||
exec "$@" |