From 741a13eeb732842425392cf8e0d64399b889d3e9 Mon Sep 17 00:00:00 2001 From: FinnStutzenstein Date: Fri, 28 Feb 2020 12:55:21 +0100 Subject: [PATCH] Production build uses commit hashes from submodules --- .gitignore | 1 + DEVELOPMENT.md | 9 +++++++++ Makefile | 3 ++- docker-compose.prod.yml | 10 ++++++++-- openslides-client | 2 +- openslides-datastore-service | 2 +- 6 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 9a94f7cbc..c10bb2817 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *~ .DS_Store .idea +.env # Old OS3 files and folders .coverage diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 4e5d25661..a61a7a922 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -56,6 +56,15 @@ required (phony) targets are: - `run-tests`: Execute all tests from the submodule - `build-dev`: Build an image with the tag `openslides--dev` +### Build arguments in the Dockerfile + +These build arguments should be supported by every service: + +- `REPOSITORY_URL`: The git-url for the repository to use +- `GIT_CHECKOUT`: A branch/tag/commit to check out during the build + +Note that meaningful defaults should be provided in the Dockerfile. + ## Developing on a single service Go to the serivce and create a new branch (from master): diff --git a/Makefile b/Makefile index 290e1d0fc..1d8b8df5b 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# TESTS +SHELL := /bin/bash run-system-tests: echo "TODO: write complete system tests" @@ -14,6 +14,7 @@ run-dev: | build-dev docker-compose -f docker-compose.yml -f docker-compose.dev.yml -p 127.0.0.1:8000:8000/tcp up build-prod: + git submodule status | awk '{ gsub(/[^0-9a-f]/, "", $$1); gsub("-","_",$$2); print toupper($$2)"_COMMIT_HASH="$$1 }' > .env docker-compose -f docker-compose.yml -f docker-compose.prod.yml build run-prod: | build-prod diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 7e09bb737..191c52ff4 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -1,10 +1,16 @@ version: '3' services: datastore-writer: - build: https://github.com/OpenSlides/openslides-datastore-service.git#:writer + build: + context: "https://github.com/OpenSlides/openslides-datastore-service.git#:writer" + args: + GIT_CHECKOUT: "${OPENSLIDES_DATASTORE_SERVICE_COMMIT_HASH}" image: openslides-datastore-writer client: - build: https://github.com/OpenSlides/openslides-client.git + build: + context: "https://github.com/OpenSlides/openslides-client.git" + args: + GIT_CHECKOUT: "${OPENSLIDES_CLIENT_COMMIT_HASH}" image: openslides-client haproxy: build: ./haproxy diff --git a/openslides-client b/openslides-client index e75e72b50..049920af1 160000 --- a/openslides-client +++ b/openslides-client @@ -1 +1 @@ -Subproject commit e75e72b50c66cd59ca6aac8cea1cf8c6c998d954 +Subproject commit 049920af19dd88d83548e710d25f07dacd3b56f4 diff --git a/openslides-datastore-service b/openslides-datastore-service index 51af334dd..4325e10af 160000 --- a/openslides-datastore-service +++ b/openslides-datastore-service @@ -1 +1 @@ -Subproject commit 51af334ddc7c7a57616263e8d56e27c21c0e5e65 +Subproject commit 4325e10af1f7ecad911c9f3ded195ba08f7eef86