Skip to content

Commit

Permalink
add Docker support for Alpine Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
genscale-admin committed Jul 12, 2017
1 parent 2897e4c commit 7b0c20e
Show file tree
Hide file tree
Showing 4 changed files with 424 additions and 0 deletions.
98 changes: 98 additions & 0 deletions docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#########################################################################################
#
# P R O D U C T I O N R E A D Y
#
# Docker container fully based on Alpine Linux: contained PLAST software compiled
# using native Alpine c/c++ tools.
#
#########################################################################################
#
# == Docker build command:
#
# docker build -f Dockerfile.alpine -t plast_alpine_machine .
#
# == Running a PLAST job
#
# docker run --rm -i -t plast_alpine_machine <args>
#
# where <args> are the PLAST command-line arguments.
# See https://plast.inria.fr/user-guide/plast-command-line-arguments/
#
# == Sample PLAST job with provided data
#
# docker run --rm -i -t -v $PWD:/tmp plast_alpine_machine -p plastp -i /opt/plastbinary/db/query.fa -d /opt/plastbinary/db/query.fa -o /tmp/test.out -a 4
#
# -> you should have a 'test.out' file when PLAST job is done.
#
# This command-line line explained:
#
# docker run [1]
# --rm [2]
# -i -t [3]
# -v $PWD:/tmp [4]
# plast_machine [5]
# -p plastp [6]
# -i /opt/plastbinary/db/query.fa [7]
# -d /opt/plastbinary/db/tursiops.fa [8]
# -o /tmp/test.out [9]
# -a 4 [10]
#
# [1]-[5]: Docker arguments
# [6]-[10]: PLAST arguments
#
# [1]: start Docker container
# [2]: destroy container when Docker finishes
# (it does NOT delete the 'plast_machine' image)
# [3]: start an interactive job
# (for instance, you'll see messages on stdout, if any)
# [4]: mount a volume. This is required to get the results from PLAST.
# Here, we say that current local directory will be viewed as '/tmp'
# from the inside of the container.
# [5]: tell Docker which image to start: the 'plast_machine' of course.
# [6]: run a plastp job, i.e. protein query vs. protein reference bank
# [7]: the query; this file is provided inside the container.
# [8]: the reference bank; this file is provided inside the container.
# [9]: the result file.
# Created within the '/tmp' directory inside the container, this file
# will be available in the current local directory, thanks to argument [4].
# [10]: request to use up to 4 threads
# (adapt the value to your computer!)
#
#########################################################################################

FROM alpine:3.6
# (image size after: 4Mb)

# who to blame?
MAINTAINER Patrick Durand [email protected]

# ###
# Package installation and configuration
#
RUN apk update && \
apk add --no-cache libstdc++ && \
mkdir -p /opt
# (image size after: 6.5Mb)

# ###
# PLAST tarball is supposed to be located in this directory.
#
ENV PLAST_VERSION=2.3.2
ENV PLAST_PACKAGE=plastbinary_v${PLAST_VERSION}-Alpine
COPY ${PLAST_PACKAGE}.tar.gz /opt

# ###
# PLAST installation.
#
RUN cd /opt \
&& gunzip ${PLAST_PACKAGE}.tar.gz \
&& tar -xf ${PLAST_PACKAGE}.tar \
&& rm -f ${PLAST_PACKAGE}.tar \
&& mv ${PLAST_PACKAGE} plastbinary
# (image size after: 9.6Mb)

# ###
# Start a GATB-Tool. See "run-tool.sh" header for more information.
#
ENTRYPOINT ["/opt/plastbinary/plast"]

64 changes: 64 additions & 0 deletions docker/Dockerfile.alpine-compiler
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#########################################################################################
#
# P R O D U C T I O N R E A D Y
#
# Docker container based on Alpine Linux. It aims at compiling PLAST software using
# Alpine c/c++ compiler.
#
#########################################################################################
#
# == Docker build command:
#
# docker build -f Dockerfile.alpine-compiler -t plast_alpine_compiler .
#
# == Docker run command:
#
# see companion scripts "build.sh" to review how to use this Alpine c/c++ complier.
#
#########################################################################################

# Base image to compile PLAST using an Alpine Linux OS.
# JDK is required since PLAST contains JNI interface, natively.
# JDK is required to compile PLAST source code... however, it is not to run PLAST binary.
# Alpine/JDK8 Docker from: https://hub.docker.com/r/frolvlad/alpine-oraclejdk8/
FROM frolvlad/alpine-oraclejdk8:full

# who to blame?
MAINTAINER Patrick Durand [email protected]

# ###
#
# Package installation and configuration:
#
# 1. We need libc and libc++ to compile PLAST
# 2. We also need cmake, make and c/c++ compiler
# 3. We need perl (used by cmake to get current build date)
# 4. We need bash (compile script) and curl (to get tarballs from Github)
#
RUN apk update && \
apk add --no-cache \
bash \
curl \
perl \
cmake make g++
#make cmake gcc g++ libstdc++ libgcc

# Add the build script
COPY build.sh /usr/bin

# Fix: ensure script has exec permission
RUN chmod +x /usr/bin/build.sh

# Run this container as non-root
# testing machine: use pdurand account
# production machine: use Jenkins account
RUN adduser -D -H -u 502 pdurand
RUN adduser -D -H -u 1000 ci
# Note: we do not use Docker 'USER' command here. Instead, use "--user xxx"
# with "docker run" command.

# ###
# Start to make a PLAST Tool. See "build.sh" header for more information.
#
ENTRYPOINT ["/usr/bin/build.sh"]

39 changes: 39 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Introduction

This directory contains Docker material aims at creating a PLAST Docker container.

# CentOS container

Genscale Team uses a CentOS 6 Linux system to compile and to test the PLAST software.

As a consequence, we first designed a Dockerfile relying on that OS.

You simply create the Docker image as follows:

docker build -f Dockerfile -t plast_machine .

Image size is 230 Mb.

Then to run PLAST jobs using that container, refer to the header of Dockerfile.

# Alpine Linux container

In order to provide a more compact version of the PLAST Docker container, we designed another Dockerfile to use the compact Alpine Linux system.

For that purpose, we actually made two Dockerfiles:

* Dockerfile.alpine-compiler: use to compile PLAST source code into Alpine-based binary
* Dockerfile.alpine: use to package the previous binary into a ready-to-use PLAST job machine

So, you create the PLAST machine as follows:

docker build -f Dockerfile.alpine-compiler -t plast_alpine_compiler .
docker run --rm -i -t -v $PWD:/tmp plast_alpine_compiler \
"plast-library;plastbinary;plast_source;2.3.2"
docker build -f Dockerfile.alpine -t plast_alpine_machine .

You'll end up with a very, very compact PLAST machine sizing only 9.6 Mb!

To use that Docker container, please refer to the header of Dockerfile.alpine


Loading

0 comments on commit 7b0c20e

Please sign in to comment.