More information about Docker
[rnaseq-cwl-training.git] / assets / answers / ep8 / Dockerfile.multi-stage
1 # Build the base image.  This is the starting point for both the build
2 # stage and the final stage.
3 # the "AS base" names the image within the Dockerfile
4 FROM debian:10-slim AS base
5 MAINTAINER Peter Amstutz <peter.amstutz@curii.com>
6
7 # Install libz, because the bwa binary will depend on it.
8 # As it happens, this already included in the base Debian distribution
9 # because lots of things use libz specifically, but it is good practice
10 # to explicitly declare that we need it.
11 RUN apt-get update -qy
12 RUN apt-get install -qy zlib1g
13
14
15 # This is the builder image.  It has the commands to install the
16 # prerequisites and then build the bwa binary.
17 FROM base as builder
18 RUN apt-get install -qy build-essential wget unzip zlib1g-dev
19
20 # Install BWA 07.7.17
21 RUN wget https://github.com/lh3/bwa/archive/v0.7.17.zip
22 RUN unzip v0.7.17
23 RUN cd bwa-0.7.17 && \
24     make && \
25     cp bwa /usr/bin
26
27
28 # Build the final image.  It starts from base (where we ensured that
29 # libz was installed) and then copies the bwa binary from the builder
30 # image.  The result is the final image only has the compiled bwa
31 # binary, but not the clutter from build-essentials or from compiling
32 # the program.
33 FROM base AS final
34
35 # This is the key command, we use the COPY command described earlier,
36 # but instead of copying from the host, the --from option copies from
37 # the builder image.
38 COPY --from=builder /usr/bin/bwa /usr/bin/bwa