Skip to content

Commit

Permalink
Merge pull request #293 from kjsanger/chore/dockerfile-tidy
Browse files Browse the repository at this point in the history
Update Dockerfiles to current conventions
  • Loading branch information
kjsanger authored Jun 24, 2024
2 parents 4fb1e2e + 9d1f92a commit cf35246
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 152 deletions.
19 changes: 10 additions & 9 deletions Dockerfile-ubuntu-16.04 → Dockerfile.ubuntu-16.04-dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ FROM $BASE_IMAGE

ARG IRODS_VERSION="4.2.7"

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \
apt-get update && \
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -q -y --no-install-recommends \
apt-transport-https \
apt-utils \
Expand All @@ -20,23 +21,22 @@ RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selectio

ENV LANG=en_GB.UTF-8 \
LANGUAGE=en_GB \
LC_ALL=en_GB.UTF-8
LC_ALL=en_GB.UTF-8 \
TZ=Etc/UTC

RUN curl -sSL https://packages.irods.org/irods-signing-key.asc | apt-key add - && \
echo "deb [arch=amd64] https://packages.irods.org/apt/ $(lsb_release -sc) main" |\
tee /etc/apt/sources.list.d/renci-irods.list && \
apt-get update && \
tee /etc/apt/sources.list.d/renci-irods.list

RUN apt-get update && \
apt-get install -q -y --no-install-recommends \
irods-dev="${IRODS_VERSION}" \
irods-runtime="${IRODS_VERSION}" \
irods-icommands="${IRODS_VERSION}"

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "E1DD270288B4E6030699E45FA1715D88E1DF1F24" && \
echo "deb https://ppa.launchpadcontent.net/git-core/ppa/ubuntu $(lsb_release -sc) main" |\
tee /etc/apt/sources.list.d/git-core.list && \
apt-get update && \
apt-get install -q -y --no-install-recommends \
git
tee /etc/apt/sources.list.d/git-core.list

RUN apt-get update && \
apt-get install -q -y --no-install-recommends \
Expand All @@ -46,6 +46,7 @@ RUN apt-get update && \
check \
cmake \
gdb \
git \
jq \
lcov \
less \
Expand Down
32 changes: 12 additions & 20 deletions Dockerfile-ubuntu-18.04 → Dockerfile.ubuntu-18.04-dev
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM ubuntu:18.04

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \
apt-get update && \
ARG IRODS_VERSION="4.2.11"

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -q -y --no-install-recommends \
apt-utils \
ca-certificates \
Expand All @@ -16,25 +19,22 @@ RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selectio

ENV LANG=en_GB.UTF-8 \
LANGUAGE=en_GB \
LC_ALL=en_GB.UTF-8

ENV IRODS_VERSION=4.2.12
LC_ALL=en_GB.UTF-8 \
TZ=Etc/UTC

RUN curl -sSL https://packages.irods.org/irods-signing-key.asc | apt-key add - && \
echo "deb [arch=amd64] https://packages.irods.org/apt/ $(lsb_release -sc) main" |\
tee /etc/apt/sources.list.d/renci-irods.list && \
apt-get update && \
tee /etc/apt/sources.list.d/renci-irods.list

RUN apt-get update && \
apt-get install -q -y --no-install-recommends \
irods-dev="${IRODS_VERSION}-1~$(lsb_release -sc)" \
irods-runtime="${IRODS_VERSION}-1~$(lsb_release -sc)" \
irods-icommands="${IRODS_VERSION}-1~$(lsb_release -sc)"

RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "E1DD270288B4E6030699E45FA1715D88E1DF1F24" && \
echo "deb https://ppa.launchpadcontent.net/git-core/ppa/ubuntu $(lsb_release -sc) main" |\
tee /etc/apt/sources.list.d/git-core.list && \
apt-get update && \
apt-get install -q -y --no-install-recommends \
git
tee /etc/apt/sources.list.d/git-core.list

RUN apt-get update && \
apt-get install -q -y --no-install-recommends \
Expand All @@ -44,6 +44,7 @@ RUN apt-get update && \
check \
cmake \
gdb \
git \
jq \
lcov \
less \
Expand All @@ -56,15 +57,6 @@ RUN apt-get update && \
unattended-upgrades && \
unattended-upgrade -d -v

ARG USER=baton
ARG UID=1000
ARG GID=$UID

RUN groupadd --gid $GID $USER && \
useradd --uid $UID --gid $GID --shell /bin/bash --create-home $USER

USER $USER

ENV CPPFLAGS="-I/usr/include/irods" \
CK_DEFAULT_TIMEOUT=20

Expand Down
32 changes: 14 additions & 18 deletions Dockerfile-ubuntu-22.04 → Dockerfile.ubuntu-22.04-dev
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
FROM ubuntu:22.04

RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections && \
apt-get update && \
ARG IRODS_VERSION="4.3-nightly"

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && \
apt-get install -q -y --no-install-recommends \
apt-utils \
ca-certificates \
Expand All @@ -16,23 +19,25 @@ RUN echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selectio

ENV LANG=en_GB.UTF-8 \
LANGUAGE=en_GB \
LC_ALL=en_GB.UTF-8

ENV IRODS_VERSION=4.3-nightly
LC_ALL=en_GB.UTF-8 \
TZ=Etc/UTC

RUN curl -sSL https://packages.irods.org/irods-signing-key.asc | apt-key add - && \
echo "deb [arch=amd64] https://packages.irods.org/apt/ $(lsb_release -sc) main" |\
tee /etc/apt/sources.list.d/renci-irods.list && \
apt-get update
tee /etc/apt/sources.list.d/renci-irods.list

RUN apt-get update

ENV NIGHTLY_URL_BASE=https://github.com/wtsi-npg/irods_development_environment/releases/download/nightly/
ENV NIGHTLY_URL_BASE="https://github.com/wtsi-npg/irods_development_environment/releases/download/nightly/"

WORKDIR /app

RUN curl -sSL \
-O ${NIGHTLY_URL_BASE}irods-dev_4.3.0-1.jammy_amd64.deb \
-O ${NIGHTLY_URL_BASE}irods-runtime_4.3.0-1.jammy_amd64.deb \
-O ${NIGHTLY_URL_BASE}irods-icommands_4.3.0-1.jammy_amd64.deb

RUN ls -l && apt-get install -y ./*.deb
RUN ls -l && apt-get install -y ./*.deb && rm -f ./*.deb

RUN apt-get update && \
apt-get install -q -y --no-install-recommends \
Expand All @@ -54,15 +59,6 @@ RUN apt-get update && \
unattended-upgrades && \
unattended-upgrade -d -v

ARG USER=baton
ARG UID=1000
ARG GID=$UID

RUN groupadd --gid $GID $USER && \
useradd --uid $UID --gid $GID --shell /bin/bash --create-home $USER

USER $USER

ENV CPPFLAGS="-I/usr/include/irods" \
CK_DEFAULT_TIMEOUT=20

Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ services:
platform: linux/amd64
build:
context: .
dockerfile: ./Dockerfile-ubuntu-18.04
dockerfile: ./Dockerfile.ubuntu-18.04-dev
volumes:
- "${PWD}:/code"
- "${PWD}:/app"
environment:
IRODS_ENVIRONMENT_FILE: "/code/tests/.irods/irods_environment.json"
IRODS_ENVIRONMENT_FILE: "/app/tests/.irods/irods_environment.json"
depends_on:
- irods-server
13 changes: 0 additions & 13 deletions release/manifest.json

This file was deleted.

8 changes: 8 additions & 0 deletions release/manifest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
baton-chmod
baton-do
baton-get
baton-list
baton-metamod
baton-metaquery
baton-put
baton-specificquery
16 changes: 2 additions & 14 deletions release/singularity-run-docker
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
#!/bin/bash
#
# Running this script will start an instance of the container, if one is not
# already running, and then execute the command in the instance.
#
# Cleaning up unwanted instances afterwards is outside the scope of this script.

set -euo pipefail

DOCKER_REGISTRY=${DOCKER_REGISTRY:?required, but not set}
DOCKER_USER=${DOCKER_USER:?required, but not set}
DOCKER_IMAGE=${DOCKER_IMAGE:?required, but was not set}
DOCKER_TAG=${DOCKER_TAG:?required, but not set}

# Colons and slashes are not allowed in Singularity instance names
instance="$DOCKER_REGISTRY--$DOCKER_USER--$DOCKER_IMAGE--$DOCKER_TAG"

if ! singularity instance list | grep "$instance" 2>&1 >/dev/null ; then
singularity instance start \
"docker://$DOCKER_REGISTRY/$DOCKER_USER/$DOCKER_IMAGE:$DOCKER_TAG" "$instance" 2>&1 >/dev/null
fi

singularity exec "instance://$instance" "$@"
singularity run "docker://$DOCKER_REGISTRY/$DOCKER_USER/$DOCKER_IMAGE:$DOCKER_TAG" "$@"
56 changes: 37 additions & 19 deletions release/singularity-wrapper
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
#
# Copyright (C) 2023 Genome Research Ltd. All rights reserved.
#
Expand All @@ -17,17 +17,27 @@
#
# Author: Keith James <[email protected]>

set -euo pipefail

usage() {
cat 1>&2 << EOF
Install singularity proxy wrappers for the executables listed in a
container's manifest to a nominated directory.
Usage: $0 [-h] [-i <Docker image name>]
[-m <JSON manifest path>]
Two different types of wrapper are available which differ in how
they run singularity. The default type uses "singularity run",
while the alternative type uses "singularity exec".
If the "exec" type is used, the wrapper can additionally be made
to create a long-running service instance on first use and
subsequently "exec" within that instance.
Usage: $0
[-e]
[-h]
[-i <Docker image name>]
[-m <manifest path>]
[-p <wrapper install prefix>]
[-r <Docker registry name>]
[-s]
[-t <Docker image tag>]
[-u <Docker user name>] [-v] <operation>
Expand All @@ -40,6 +50,8 @@ Operation may be one of:
Options:
-h Print usage and exit.
-e Use "singularity exec", rather than "singularity run" in the
generated wrappers.
-i Docker image name. Required, defaults to the value of the
environment variable "\$DOCKER_IMAGE" ("$DOCKER_IMAGE").
-m Manifest file path. Optional, defaults to the value of the
Expand All @@ -48,6 +60,7 @@ Options:
environment variable \$PREFIX ("$PREFIX").
-r Docker registry name. Optional, defaults to the value of the
environment variable \$DOCKER_REGISTRY ("$DOCKER_REGISTRY").
-s Start a long-running service instance (implies use of exec).
-t Docker image tag. Optional, defaults to the value of the
environment variable \$DOCKER_TAG ("$DOCKER_TAG").
-u Docker user name. Optional, defaults to the value of the
Expand All @@ -58,7 +71,7 @@ EOF

# Print an application manifest
print_manifest() {
jq . "$MANIFEST_PATH"
cat "$MANIFEST_PATH"
}

# Write a bash script wrapping an application in a Docker container
Expand Down Expand Up @@ -86,7 +99,7 @@ export DOCKER_TAG="$DOCKER_TAG"
# time, be permanently set in the installed wrapper. E.g. a candidate
# is SINGULARITY_CACHEDIR.
"\$(dirname "\${BASH_SOURCE[0]}")/singularity-run-docker" "$exe" "\$@"
"\$(dirname "\${BASH_SOURCE[0]}")/$singularity_wrap_impl" "$exe" "\$@"
EOF

chmod +x "$dir/$exe"
Expand All @@ -96,11 +109,11 @@ chmod +x "$dir/$exe"
install_wrappers() {
local dir="$PREFIX/bin"
install -d "$dir"
cp /usr/local/bin/singularity-run-docker "$PREFIX/bin"
cp "/usr/local/bin/$singularity_wrap_impl" "$PREFIX/bin"

for exe in "${wrappers[@]}" ; do
while IFS= read -r exe; do
write_wrapper "$dir" "$exe"
done
done < "$MANIFEST_PATH"
}

DOCKER_REGISTRY=${DOCKER_REGISTRY:-ghcr.io}
Expand All @@ -109,10 +122,15 @@ DOCKER_IMAGE=${DOCKER_IMAGE:-""}
DOCKER_TAG=${DOCKER_TAG:-latest}

PREFIX=${PREFIX:-/opt/wtsi-npg}
MANIFEST_PATH=${MANIFEST_PATH:-"$PREFIX/etc/manifest.json"}
MANIFEST_PATH=${MANIFEST_PATH:-"$PREFIX/etc/manifest.txt"}

while getopts "hi:m:p:r:t:u:v" option; do
singularity_wrap_impl="singularity-run-docker"

while getopts "hei:m:p:r:st:u:v" option; do
case "$option" in
e)
singularity_wrap_impl="singularity-exec-docker"
;;
h)
usage
exit 0
Expand All @@ -129,6 +147,9 @@ while getopts "hi:m:p:r:t:u:v" option; do
r)
DOCKER_REGISTRY="$OPTARG"
;;
s)
singularity_wrap_impl="singularity-service-docker"
;;
t)
DOCKER_TAG="$OPTARG"
;;
Expand All @@ -148,22 +169,19 @@ done

shift $((OPTIND -1))

declare -a wrappers
if [ ! -e "$MANIFEST_PATH" ] ; then
echo -e "\nERROR:\n The manifest of executables at '$MANIFEST_PATH' does not exist"
exit 4
fi

wrappers=($(jq -j '.executable[] + " "' "$MANIFEST_PATH"))

OPERATION="$@"
if [ -z "$OPERATION" ] ; then
operation="$1"
if [ -z "$operation" ] ; then
usage
echo -e "\nERROR:\n An operation argument is required"
exit 4
fi

case "$OPERATION" in
case "$operation" in
list)
print_manifest
exit 0
Expand All @@ -173,7 +191,7 @@ case "$OPERATION" in
;;
*)
usage
echo -e "\nERROR:\n Invalid wrapper operation '$OPERATION'"
echo -e "\nERROR:\n Invalid wrapper operation '$operation'"
exit 4
;;
esac
Loading

0 comments on commit cf35246

Please sign in to comment.