Skip to content

Commit

Permalink
fixed issues with Docker and added Apptainer/Singularity support
Browse files Browse the repository at this point in the history
  • Loading branch information
fethalen committed Oct 20, 2023
1 parent 3a3be98 commit 5c5c3ce
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 169 deletions.
112 changes: 50 additions & 62 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ FROM ubuntu:22.04 AS builder
# System is non-interactive when building the Docker image
ENV DEBIAN_FRONTEND noninteractive

# Set time zone to Zurich, Europe
ENV TZ=Europe/Zurich
RUN ln -snf "/usr/share/zoneinfo/${TZ}" /etc/localtime && echo "$TZ" > /etc/timezone

# Update the repository sources and install required tools and libraries
RUN apt-get update && apt-get install --yes --no-install-recommends \
apt-utils \
wget \
gcc \
ca-certificates \
python3-matplotlib \
libqt5widgets5

# RUN groupadd --gid 1000 patchwork \
# && useradd --uid 1000 --gid patchwork --shell /bin/bash --create-home patchwork \
# && chmod -R a+rwx /home/patchwork
# USER patchwork
libqt5widgets5 \
git

# Set work directory
WORKDIR '/opt'
Expand All @@ -32,67 +32,55 @@ WORKDIR '/opt'
RUN wget --quiet 'https://julialang-s3.julialang.org/bin/linux/x64/1.9/julia-1.9.3-linux-x86_64.tar.gz' \
&& tar -xvzf 'julia-1.9.3-linux-x86_64.tar.gz' \
&& rm 'julia-1.9.3-linux-x86_64.tar.gz'
ENV PATH "/opt/julia-1.9.3-rc3/bin:${PATH}"
ENV PATH "/opt/julia-1.9.3/bin:${PATH}"

# Download and install DIAMOND
RUN wget 'http://github.com/bbuchfink/diamond/releases/download/v2.1.8/diamond-linux64.tar.gz' \
&& tar -xvzf 'diamond-linux64.tar.gz' \
&& mv 'diamond' '/usr/local/bin' \
&& rm 'diamond-linux64.tar.gz'

# Doad and install Patchwork
ARG PATCHWORK_VERSION='0.5.2'
RUN wget -O "patchwork-${PATCHWORK_VERSION}.tar.gz" "https://github.com/fethalen/Patchwork/archive/refs/tags/v${PATCHWORK_VERSION}.tar.gz" \
&& tar -xvzf "patchwork-${PATCHWORK_VERSION}.tar.gz" \
&& rm "patchwork-${PATCHWORK_VERSION}.tar.gz" \
&& cd "Patchwork-${PATCHWORK_VERSION}" \
&& julia --project=. -e "import Pkg; Pkg.instantiate()" \
&& julia --project=. src/compile.jl . src/precompiled.jl ../patchwork-$VERSION

# Download and install Patchwork
RUN git clone 'https://github.com/fethalen/patchwork' \
&& cd patchwork \
&& julia --project=. -e 'import Pkg; Pkg.instantiate()' \
&& julia --project=. src/compile.jl . src/precompiled.jl ../patchwork-$VERSION

# # Stage 2/2: Production
# # ---------------------

# # Set the base image
# FROM ubuntu:22.04

# # File maintainer
# MAINTAINER Felix Thalén <[email protected]>

# # System is non-interactive when building the Docker image
# ENV DEBIAN_FRONTEND noninteractive

# # Set time zone to Zurich, Europe
# ENV TZ=Europe/Zurich
# RUN ln -snf "/usr/share/zoneinfo/${TZ}" /etc/localtime && echo "$TZ" > /etc/timezone

# # Metadata
# LABEL base_image="ubuntu:20.04"
# LABEL version="1"
# LABEL software="Patchwork"
# LABEL software.version="0.5.2"
# LABEL about.author="Felix Thalén <[email protected]>"
# LABEL about.summary="Alignment-based Exon Retrieval and Concatenation with Phylogenomic Applications"
# LABEL about.home="https://github.com/fethalen/Patchwork"
# LABEL about.documentation="https://github.com/fethalen/Patchwork#readme"
# LABEL about.license="SPDX:GPL-3.0"
# LABEL about.license_file="https://github.com/fethalen/Patchwork/blob/main/LICENSE"
# LABEL about.tags="phylogenomics"

# RUN groupadd --gid 1000 patchwork \
# && useradd --uid 1000 --gid patchwork --shell /bin/bash --create-home patchwork \
# && chmod -R a+rwx /home/patchwork
# WORKDIR /home/patchwork
# USER patchwork
# ENV VERSION 0.5.2

# COPY --from=builder /home/patchwork/patchwork-$VERSION patchwork-$VERSION
# COPY --from=builder /home/patchwork/diamond diamond
# RUN ln -s patchwork-$VERSION/bin/patchwork patchwork
# ENV PATH /home/patchwork:$PATH

# CMD patchwork --help
&& cd patchwork/build \
&& ./build_app.jl

# Stage 2/2: Production
# ---------------------

# Set the base image
FROM ubuntu:22.04 AS production

# Metadata
LABEL org.opencontainers.image.authors="[email protected]"
LABEL version="1"
LABEL software="Patchwork"
LABEL software.version="0.5.5"
LABEL about.author="Felix Thalén <[email protected]>"
LABEL about.summary="Alignment-based Exon Retrieval and Concatenation with Phylogenomic Applications"
LABEL about.home="https://github.com/fethalen/patchwork"
LABEL about.documentation="https://github.com/fethalen/patchwork#readme"
LABEL about.license="SPDX:GPL-3.0"
LABEL about.tags="phylogenomics, phylogenetics, genomics, alignment"

# System is non-interactive when building the Docker image
ENV DEBIAN_FRONTEND noninteractive

# Set time zone to Zurich, Europe
ENV TZ=Europe/Zurich
RUN ln -snf "/usr/share/zoneinfo/${TZ}" /etc/localtime && echo "$TZ" > /etc/timezone

# Create the user
RUN useradd --create-home --shell /bin/bash --user-group --uid 1000 patchwork

# Set the default user
USER patchwork

# Set the working directory
WORKDIR /home/patchwork

COPY --from=builder /opt/patchwork/build/compiled /opt/patchwork
COPY --from=builder /usr/local/bin/diamond /usr/local/bin/diamond
ENV PATH /opt/patchwork/bin:$PATH

ENTRYPOINT ["patchwork"]
106 changes: 0 additions & 106 deletions docker/Singularity.def

This file was deleted.

112 changes: 112 additions & 0 deletions docker/patchwork.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
Bootstrap: docker
From: ubuntu:22.04
Stage: builder

%post
# To reduce the final image size, the build process has been split into a build
# stage and a production stage. After compiling Patchwork, the Julia
# installation is no longer needed and is therefore removed in the second stage.

# Stage 1/2: Build
# ----------------

# Set the base image

# System is non-interactive when building the Docker image
DEBIAN_FRONTEND=noninteractive

# Set time zone to Zurich, Europe
TZ=Europe/Zurich
ln -snf "/usr/share/zoneinfo/${TZ}" /etc/localtime && echo "$TZ" > /etc/timezone

# Update the repository sources and install required tools and libraries
apt-get update && apt-get install --yes --no-install-recommends \
apt-utils \
wget \
gcc \
ca-certificates \
python3-matplotlib \
libqt5widgets5 \
git

# Set work directory
mkdir -p '/opt'
cd '/opt'

# Download and install Julia
wget --quiet 'https://julialang-s3.julialang.org/bin/linux/x64/1.9/julia-1.9.3-linux-x86_64.tar.gz' \
&& tar -xvzf 'julia-1.9.3-linux-x86_64.tar.gz' \
&& rm 'julia-1.9.3-linux-x86_64.tar.gz'
PATH="/opt/julia-1.9.3/bin:${PATH}"

# Download and install DIAMOND
wget 'http://github.com/bbuchfink/diamond/releases/download/v2.1.8/diamond-linux64.tar.gz' \
&& tar -xvzf 'diamond-linux64.tar.gz' \
&& mv 'diamond' '/usr/local/bin' \
&& rm 'diamond-linux64.tar.gz'

# Download and install Patchwork
git clone 'https://github.com/fethalen/patchwork' \
&& cd patchwork/build \
&& ./build_app.jl

# Stage 2/2: Production
# ---------------------

# Set the base image
%environment
export DEBIAN_FRONTEND=noninteractive
export TZ=Europe/Zurich
export PATH="/opt/julia-1.9.3/bin:${PATH}"

Bootstrap: docker
From: ubuntu:22.04
Stage: production

%files from builder
/opt/patchwork/build/compiled /opt/patchwork
/usr/local/bin/diamond /usr/local/bin/diamond
%labels
org.opencontainers.image.authors="[email protected]"
version="1"
software="Patchwork"
software.version="0.5.4"
about.author="Felix Thalén <[email protected]>"
about.summary="Alignment-based Exon Retrieval and Concatenation with Phylogenomic Applications"
about.home="https://github.com/fethalen/patchwork"
about.documentation="https://github.com/fethalen/patchwork#readme"
about.license="SPDX:GPL-3.0"
about.tags="phylogenomics, phylogenetics, genomics, alignment"
%post

# Metadata

# System is non-interactive when building the Docker image
DEBIAN_FRONTEND=noninteractive

# Set time zone to Zurich, Europe
TZ=Europe/Zurich
ln -snf "/usr/share/zoneinfo/${TZ}" /etc/localtime && echo "$TZ" > /etc/timezone

# Create the user
useradd --create-home --shell /bin/bash --user-group --uid 1000 patchwork

# Set the default user
su - patchwork # USER patchwork

# Set the working directory
mkdir -p /home/patchwork
cd /home/patchwork

PATH=/opt/patchwork/bin:$PATH

%environment
export DEBIAN_FRONTEND=noninteractive
export TZ=Europe/Zurich
export PATH=/opt/patchwork/bin:$PATH
%runscript
cd /home/patchwork
exec patchwork "$@"
%startscript
cd /home/patchwork
exec patchwork "$@"
2 changes: 1 addition & 1 deletion src/Patchwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function parse_parameters()
whole-genome sequencing data
"""
settings = ArgParseSettings(description = overview,
version = "0.5.4",
version = "0.5.5",
add_version = true)
@add_arg_table! settings begin
"--contigs"
Expand Down

0 comments on commit 5c5c3ce

Please sign in to comment.