Skip to content

Commit

Permalink
Using Docker Hub and renaming the images
Browse files Browse the repository at this point in the history
  • Loading branch information
silverdaz committed Oct 28, 2018
1 parent 69adcb4 commit 36b09ff
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 160 deletions.
4 changes: 2 additions & 2 deletions deploy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ private/lega.yml private bootstrap bootstrap-dev:
-v /dev/urandom:/dev/random \
${ENVS} \
-v ${PWD}:/ega \
--entrypoint /ega/bootstrap/boot.sh \
crg/ega-base --prefix $(PROJECT_NAME) ${ARGS}
--entrypoint /ega/bootstrap/run.sh \
egarchive/lega --prefix $(PROJECT_NAME) ${ARGS}


up: private/lega.yml
Expand Down
8 changes: 7 additions & 1 deletion deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ default).

## Docker images

[Create the EGA docker images](images) with
docker-compose will pull the appropriate images from [docker hub](https://hub.docker.com/u/egarchive/).
However, before it can, you need to bootstrap the project, and the latter requires one image. So run, first:

docker pull egarchive/lega


If you prefer, you can [create the EGA docker images](images), locally, with

make -C images

Expand Down
66 changes: 0 additions & 66 deletions deploy/bootstrap/boot.sh

This file was deleted.

80 changes: 74 additions & 6 deletions deploy/bootstrap/lega.sh → deploy/bootstrap/run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,70 @@
#!/usr/bin/env bash
set -e

[ ${BASH_VERSINFO[0]} -lt 4 ] && echo 'Bash 4 (or higher) is required' 1>&2 && exit 1

HERE=$(dirname ${BASH_SOURCE[0]})
PRIVATE=${HERE}/../private
DOT_ENV=${HERE}/../.env

# Defaults
VERBOSE=no
FORCE=yes
OPENSSL=openssl
COMPOSE_PROJECT_NAME=crg

function usage {
echo "Usage: $0 [options]"
echo -e "\nOptions are:"
echo -e "\t--openssl <value> \tPath to the Openssl executable [Default: ${OPENSSL}]"
echo -e "\t--prefix <value> \tPrefix used for the project name [Default: ${COMPOSE_PROJECT_NAME}]"
echo ""
echo -e "\t--verbose, -v \tShow verbose output"
echo -e "\t--polite, -p \tDo not force the re-creation of the subfolders. Ask instead"
echo -e "\t--help, -h \tOutputs this message and exits"
echo -e "\t-- ... \tAny other options appearing after the -- will be ignored"
echo ""
}


# While there are arguments or '--' is reached
while [[ $# -gt 0 ]]; do
case "$1" in
--help|-h) usage; exit 0;;
--verbose|-v) VERBOSE=yes;;
--polite|-p) FORCE=no;;
--openssl) OPENSSL=$2; shift;;
--prefix) COMPOSE_PROJECT_NAME=$2; shift;;
--) shift; break;;
*) echo "$0: error - unrecognized option $1" 1>&2; usage; exit 1;; esac
shift
done

[[ $VERBOSE == 'no' ]] && echo -en "Bootstrapping "

#########################################################################
source ${HERE}/defs.sh

[[ -x $(readlink ${OPENSSL}) ]] && echo "${OPENSSL} is not executable. Adjust the setting with --openssl" && exit 3

rm_politely ${PRIVATE}
mkdir -p ${PRIVATE}
exec 2>${PRIVATE}/.err
backup ${DOT_ENV}
cat > ${DOT_ENV} <<EOF
COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}
COMPOSE_FILE=private/lega.yml
#COMPOSE_IGNORE_ORPHANS=1
EOF
# Don't use ${PRIVATE}, since it's running in a container: wrong path then.

#########################################################################
source ${HERE}/settings.rc

#########################################################################
# Generate the configuration for each instance
echomsg "Generating private data for a LocalEGA instance"
#########################################################################

echomsg "\t* the keys"

Expand Down Expand Up @@ -171,7 +237,7 @@ services:
ports:
- "${DOCKER_PORT_inbox}:9000"
container_name: inbox
image: crg/ega-inbox
image: ${DOCKER_IMAGE_PREFIX:-egarchive/}inbox
volumes:
- ./conf.ini:/etc/ega/conf.ini:ro
- inbox:/ega/inbox
Expand All @@ -186,7 +252,7 @@ services:
ingest:
# depends_on:
# - mq
image: crg/ega-base
image: ${DOCKER_IMAGE_PREFIX:-egarchive/}lega
container_name: ingest
environment:
- S3_ACCESS_KEY=${S3_ACCESS_KEY}
Expand All @@ -206,7 +272,7 @@ services:
verify:
hostname: verify
container_name: verify
image: crg/ega-base
image: ${DOCKER_IMAGE_PREFIX:-egarchive/}lega
environment:
- S3_ACCESS_KEY=${S3_ACCESS_KEY}
- S3_SECRET_KEY=${S3_SECRET_KEY}
Expand All @@ -226,7 +292,7 @@ services:
finalize:
# depends_on:
# - mq
image: crg/ega-base
image: ${DOCKER_IMAGE_PREFIX:-egarchive/}lega
container_name: finalize
volumes:
- ./conf.ini:/etc/ega/conf.ini:ro
Expand All @@ -253,7 +319,7 @@ services:
outgest:
hostname: outgest
container_name: outgest
image: crg/ega-base
image: ${DOCKER_IMAGE_PREFIX:-egarchive/}lega
ports:
- "${DOCKER_PORT_outgest}:8443"
volumes:
Expand All @@ -270,7 +336,7 @@ services:
streamer:
hostname: streamer
container_name: streamer
image: crg/ega-base
image: ${DOCKER_IMAGE_PREFIX:-egarchive/}lega
environment:
- S3_ACCESS_KEY=${S3_ACCESS_KEY}
- S3_SECRET_KEY=${S3_SECRET_KEY}
Expand Down Expand Up @@ -320,3 +386,5 @@ S3_SECRET_KEY = ${S3_SECRET_KEY}
DOCKER_PORT_inbox = ${DOCKER_PORT_inbox}
DOCKER_PORT_outgest = ${DOCKER_PORT_outgest}
EOF

task_complete "Bootstrap complete"
28 changes: 14 additions & 14 deletions deploy/images/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,36 @@ endif

CHECKOUT=$(shell git rev-parse --abbrev-ref HEAD)
TAG=$(shell git rev-parse --short HEAD)
TARGET_PREFIX=crg/ega
TARGET_PREFIX=egarchive/

BUILD_ARGS=--build-arg checkout=$(CHECKOUT)

.PHONY: all erase delete clean cleanall os base inbox
.PHONY: all erase delete clean cleanall base lega inbox

all: os base inbox
all: base lega inbox

os: BUILD_ARGS+=--build-arg DEV_PACKAGES="$(DEV_PACKAGES)"
base: os
inbox: os
base: BUILD_ARGS+=--build-arg DEV_PACKAGES="$(DEV_PACKAGES)"
lega: base
inbox: base
inbox: BUILD_ARGS+=--build-arg cryptor_checkout=master
os base inbox:
base lega inbox:
docker build ${BUILD_ARGS} \
--cache-from $(TARGET_PREFIX)-$@:latest \
--tag $(TARGET_PREFIX)-$@:$(TAG) \
--tag $(TARGET_PREFIX)-$@:latest \
--cache-from $(TARGET_PREFIX)$@:latest \
--tag $(TARGET_PREFIX)$@:$(TAG) \
--tag $(TARGET_PREFIX)$@:latest \
$@

remove-%:
@docker rmi $(TARGET_PREFIX)-$(@:remove-%=%):latest
@docker rmi $(TARGET_PREFIX)$(@:remove-%=%):latest

clean:
@docker images $(TARGET_PREFIX)-* -f "dangling=true" -q | uniq | while read n; do docker rmi -f $$n; done
@docker images $(TARGET_PREFIX)* -f "dangling=true" -q | uniq | while read n; do docker rmi -f $$n; done

cleanall:
@docker images -f "dangling=true" -q | uniq | while read n; do docker rmi -f $$n; done

delete:
@docker images $(TARGET_PREFIX)-* --format "{{.Repository}} {{.Tag}}" | awk '{ if ($$2 != "$(TAG)" && $$2 != "latest") print $$1":"$$2; }' | uniq | while read n; do docker rmi $$n; done
@docker images $(TARGET_PREFIX)* --format "{{.Repository}} {{.Tag}}" | awk '{ if ($$2 != "$(TAG)" && $$2 != "latest") print $$1":"$$2; }' | uniq | while read n; do docker rmi $$n; done

erase: # erasing all including base
@docker images $(TARGET_PREFIX)-* -q | uniq | while read n; do docker rmi -f $$n; done
@docker images $(TARGET_PREFIX)* -q | uniq | while read n; do docker rmi -f $$n; done
58 changes: 44 additions & 14 deletions deploy/images/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,55 @@
FROM crg/ega-os
FROM centos:7.5.1804
LABEL maintainer "EGA System Developers"

#################################################
##
## Install LocalEGA stuff
## Upgrade CentOS 7, and install Python 3.6
##
#################################################

RUN groupadd -r lega && \
useradd -M -r -g lega lega
ARG DEV_PACKAGES=
RUN yum -y install https://centos7.iuscommunity.org/ius-release.rpm && \
yum -y install epel-release && \
yum -y update && \
yum -y install git gcc make bzip2 curl ${DEV_PACKAGES} \
zlib-devel bzip2-devel unzip \
wget dpkg \
openssl \
python36u python36u-devel python36u-pip

ARG checkout=master
ARG cryptor_checkout=master
RUN [[ -e /lib64/libpython3.6m.so ]] || ln -s /lib64/libpython3.6m.so.1.0 /lib64/libpython3.6m.so

RUN git clone https://github.com/EGA-archive/LocalEGA.git /root/LocalEGA
RUN git clone https://github.com/EGA-archive/crypt4gh.git /root/cryptor
RUN pip3.6 install --upgrade pip && \
pip3.6 install PyYaml

RUN cd /root/LocalEGA && git checkout ${checkout}
RUN pip3.6 install -r /root/LocalEGA/requirements.txt
RUN pip3.6 install /root/LocalEGA
#################################################
##
## Install GOSU
##
#################################################

ENV GOSU_VERSION 1.10
ENV GPG_KEYS B42F6819007F00F88E364FD4036A9C25BF357DD4
RUN set -ex && \
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" && \
wget -O /usr/bin/gosu "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${dpkgArch}" && \
wget -O /tmp/gosu.asc "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-${dpkgArch}.asc"

# verify the signature
RUN export GNUPGHOME="$(mktemp -d)" && \
(gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEYS" \
|| gpg --keyserver pgp.mit.edu --recv-keys "$GPG_KEYS" \
|| gpg --keyserver keyserver.pgp.com --recv-keys "$GPG_KEYS") && \
gpg --keyserver hkps://hkps.pool.sks-keyservers.net --recv-keys && \
gpg --batch --verify /tmp/gosu.asc /usr/bin/gosu && \
rm -r "$GNUPGHOME" /tmp/gosu.asc && \
chmod +x /usr/bin/gosu

# verify that the binary works
RUN gosu nobody true && \
yum -y remove dpkg

#################################################
# Clean up

RUN cd /root/cryptor && git checkout ${cryptor_checkout}
RUN pip3.6 install -r /root/cryptor/requirements.txt
RUN pip3.6 install /root/cryptor
RUN yum clean all && rm -rf /var/cache/yum
2 changes: 1 addition & 1 deletion deploy/images/inbox/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM crg/ega-os
FROM egarchive/base
LABEL maintainer "EGA System Developers"

RUN groupadd -r lega && \
Expand Down
22 changes: 22 additions & 0 deletions deploy/images/lega/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM egarchive/base
LABEL maintainer "EGA System Developers"

#################################################
##
## Install LocalEGA stuff
##
#################################################

RUN groupadd -r lega && \
useradd -M -r -g lega lega

RUN git clone https://github.com/EGA-archive/LocalEGA.git /root/LocalEGA

ARG checkout=master

RUN cd /root/LocalEGA && git checkout ${checkout}

# Requirements include crypt4gh (from https://github.com/EGA-archive/crypt4gh.git)
RUN pip3.6 install -r /root/LocalEGA/requirements.txt && \
pip3.6 install /root/LocalEGA && \
rm -rf /root/LocalEGA

0 comments on commit 36b09ff

Please sign in to comment.