|
| 1 | +ARG SNP_DISTS_VER=1.2.0 |
| 2 | + |
| 3 | +### Builder stage |
| 4 | +FROM ubuntu:noble AS builder |
| 5 | + |
| 6 | +ARG SNP_DISTS_VER |
| 7 | + |
| 8 | +# install dependencies needed for compilation; cleanup apt garbage |
| 9 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 10 | +wget \ |
| 11 | +ca-certificates \ |
| 12 | +procps \ |
| 13 | +make \ |
| 14 | +zlib1g \ |
| 15 | +gcc \ |
| 16 | +libz-dev \ |
| 17 | +build-essential \ |
| 18 | +git && \ |
| 19 | +apt-get autoclean && rm -rf /var/lib/apt/lists/* |
| 20 | + |
| 21 | +# install (recent version of) bats for testing framework since version in apt for ubuntu:noble does not include the "bats --abort" option |
| 22 | +RUN git clone https://github.com/bats-core/bats-core.git && \ |
| 23 | +cd bats-core && \ |
| 24 | +./install.sh /usr/local |
| 25 | + |
| 26 | +# install snp-dists; run make check and bats tests |
| 27 | +# decided to run bats tests here since it uses binaries located within /snp-dists-<ver>/bin/ rather than installed version in /usr/local/bin/ |
| 28 | +RUN echo "Installing snp-dists version ${SNP_DISTS_VER}" && \ |
| 29 | +wget -q https://github.com/tseemann/snp-dists/archive/v${SNP_DISTS_VER}.tar.gz && \ |
| 30 | +tar -xzf v${SNP_DISTS_VER}.tar.gz && \ |
| 31 | +rm -v v${SNP_DISTS_VER}.tar.gz && \ |
| 32 | +cd /snp-dists-${SNP_DISTS_VER} && \ |
| 33 | +make && \ |
| 34 | +make check && \ |
| 35 | +make PREFIX=/usr/local install && \ |
| 36 | +echo "Running BATS tests..." && \ |
| 37 | +bats -T --abort test/test.sh |
| 38 | + |
| 39 | +### app stage |
| 40 | +FROM ubuntu:noble AS app |
| 41 | + |
| 42 | +ARG SNP_DISTS_VER |
| 43 | + |
| 44 | +LABEL base.image="ubuntu:noble" |
| 45 | +LABEL dockerfile.version="1" |
| 46 | +LABEL software="snp-dists" |
| 47 | +LABEL software.version="${SNP_DISTS_VER}" |
| 48 | +LABEL description="Convert a FASTA alignment to SNP distance matrix" |
| 49 | +LABEL website="https://github.com/tseemann/snp-dists" |
| 50 | +LABEL license="https://github.com/tseemann/snp-dists/blob/master/LICENSE" |
| 51 | +LABEL maintainer="Curtis Kapsak" |
| 52 | +LABEL maintainer.email= "[email protected]" |
| 53 | + |
| 54 | +# install dependencies; cleanup apt garbage |
| 55 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 56 | +wget \ |
| 57 | +ca-certificates \ |
| 58 | +procps \ |
| 59 | +zlib1g \ |
| 60 | +libgomp1 && \ |
| 61 | +apt-get autoclean && rm -rf /var/lib/apt/lists/* |
| 62 | + |
| 63 | +COPY --from=builder /usr/local/bin/snp-dists /usr/local/bin/snp-dists |
| 64 | + |
| 65 | +# make /data and set as default working directory |
| 66 | +RUN mkdir -v /data |
| 67 | +WORKDIR /data |
| 68 | + |
| 69 | +# set locale for singularity compatibility; no need to set PATH as /usr/local/bin is already there |
| 70 | +ENV LC_ALL=C |
| 71 | + |
| 72 | +CMD ["snp-dists", "--help"] |
| 73 | + |
| 74 | +### Test stage |
| 75 | +FROM app AS test |
| 76 | + |
| 77 | +ARG SNP_DISTS_VER |
| 78 | + |
| 79 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 80 | +wget \ |
| 81 | +ca-certificates && \ |
| 82 | +apt-get autoclean && rm -rf /var/lib/apt/lists/* |
| 83 | + |
| 84 | +# setting working directory to /test |
| 85 | +WORKDIR /test |
| 86 | + |
| 87 | +# Run a simple test from snp-dists testing framework |
| 88 | +RUN echo "Testing snp-dists with one test from testing framework..." && \ |
| 89 | +wget -q https://raw.githubusercontent.com/tseemann/snp-dists/refs/heads/master/test/good.aln && \ |
| 90 | +wget -q https://raw.githubusercontent.com/tseemann/snp-dists/refs/heads/master/test/good.res && \ |
| 91 | +snp-dists -b good.aln > good.out && \ |
| 92 | +diff -bB good.out good.res && \ |
| 93 | +echo "snp-dists version ${SNP_DISTS_VER} test completed successfully!" |
0 commit comments