From 21cd1aceefc5784bf36cb2ea93a23a1bcbbe6409 Mon Sep 17 00:00:00 2001 From: Roman Prykhodchenko Date: Thu, 7 Mar 2019 16:16:39 +0100 Subject: [PATCH] Implement snapshot builds for docker images --- Makefile | 14 ++++++++++++++ docker/Dockerfile-prod | 2 ++ docker/Dockerfile-static | 2 +- docker/provision/install_ralph.sh | 5 ++++- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5308566750..d502b2db3d 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,20 @@ build-docker-image: -t $(DOCKER_REPO_NAME)/ralph-static-nginx:latest \ -t "$(DOCKER_REPO_NAME)/ralph-static-nginx:$(version)" . +build-snapshot-docker-image: version = $(shell ./get_version.sh show) +build-snapshot-docker-image: build-snapshot-package + docker build \ + -f docker/Dockerfile-prod \ + --build-arg RALPH_VERSION="$(version)" \ + --build-arg SNAPSHOT="1" \ + -t $(DOCKER_REPO_NAME)/ralph:latest \ + -t "$(DOCKER_REPO_NAME)/ralph:$(version)" . + docker build \ + -f docker/Dockerfile-static \ + --build-arg RALPH_VERSION="$(version)" \ + -t $(DOCKER_REPO_NAME)/ralph-static-nginx:latest \ + -t "$(DOCKER_REPO_NAME)/ralph-static-nginx:$(version)" . + install-js: npm install diff --git a/docker/Dockerfile-prod b/docker/Dockerfile-prod index 6da1114e41..704ca1c634 100644 --- a/docker/Dockerfile-prod +++ b/docker/Dockerfile-prod @@ -5,6 +5,7 @@ ENV DEBIAN_FRONTEND=noninteractive # Ralph configuration and paths ARG RALPH_LOCAL_DIR="/var/local/ralph" ARG RALPH_VERSION="" +ARG SNAPSHOT="0" ENV PATH=/opt/ralph/ralph-core/bin/:$PATH ENV RALPH_CONF_DIR="/etc/ralph" ENV RALPH_LOCAL_DIR="$RALPH_LOCAL_DIR" @@ -33,6 +34,7 @@ COPY contrib/common/apt/ralph.list \ docker/provision/start-ralph.sh \ docker/provision/wait-for-it.sh \ docker/provision/install_ralph.sh \ + build/*$RALPH_VERSION*.deb \ docker/provision/init-ralph.sh $RALPH_IMAGE_TMP_DIR/ RUN "$RALPH_IMAGE_TMP_DIR/install_ralph.sh" diff --git a/docker/Dockerfile-static b/docker/Dockerfile-static index 3fa0d09c72..7f2053ba44 100644 --- a/docker/Dockerfile-static +++ b/docker/Dockerfile-static @@ -7,5 +7,5 @@ LABEL authors="Allegro.pl Sp. z o.o. and Contributors opensource@allegro.pl" LABEL description="Static files for Ralph DCIM served by Nginx HTTP server." LABEL version="$RALPH_VERSION" -COPY --from=allegro/ralph /usr/share/ralph/static /opt/static +COPY --from=allegro/ralph:latest /usr/share/ralph/static /opt/static COPY contrib/docker/ralph.conf.nginx /etc/nginx/conf.d/default.conf diff --git a/docker/provision/install_ralph.sh b/docker/provision/install_ralph.sh index 9d52bb7de2..22e6c8637c 100755 --- a/docker/provision/install_ralph.sh +++ b/docker/provision/install_ralph.sh @@ -31,13 +31,16 @@ install_release() { install_snapshot() { - echo "Snapshot builds are not implemented yet" + local deb_file=$(ls -t ${RALPH_IMAGE_TMP_DIR}/*${RALPH_VERSION}*.deb | head -1) + apt-get update + apt-get -y install "${deb_file}" } cleanup() { rm -rf /var/lib/apt/lists/* rm -f "${RALPH_IMAGE_TMP_DIR}/ralph.list" + rm -f "${RALPH_IMAGE_TMP_DIR}/*.deb" rm -- "$0" }