From 1f7db2388c2b33c5038033cfa6a5361df53b71ff Mon Sep 17 00:00:00 2001 From: Marat Abrarov Date: Fri, 13 Nov 2020 16:29:14 +0300 Subject: [PATCH] Enhanced file sharing b/w containers in Docker Compose project and read-only rootfs for Redis configuration generator container. --- README.md | 12 ++++++------ docker-compose.yml | 19 ++++++++++++------- helper-image/pom.xml | 2 +- j2cli-builder-image/pom.xml | 2 +- j2cli-dist/pom.xml | 2 +- j2cli-image/pom.xml | 2 +- pom.xml | 2 +- redis-builder-image/pom.xml | 2 +- redis-dist/pom.xml | 2 +- redis-image/pom.xml | 2 +- redis-init-image/pom.xml | 2 +- 11 files changed, 27 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index e805032..86b0b17 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ mvnw.cmd clean package -Ddocker-maven-plugin.version=0.34-SNAPSHOT 1. Redis version ```bash - docker run --rm abrarov/redis:6.0.9-1.0.3 + docker run --rm abrarov/redis:6.0.9-1.0.4 ``` Expected output looks like: @@ -53,7 +53,7 @@ mvnw.cmd clean package -Ddocker-maven-plugin.version=0.34-SNAPSHOT 1. [Redis CLI](https://github.com/redis/redis#playing-with-redis) ```bash - container_id="$(docker run -d abrarov/redis:6.0.9-1.0.3 redis-server)" && \ + container_id="$(docker run -d abrarov/redis:6.0.9-1.0.4 redis-server)" && \ docker exec "${container_id}" redis-cli ping && \ docker rm -fv "${container_id}" > /dev/null ``` @@ -67,7 +67,7 @@ mvnw.cmd clean package -Ddocker-maven-plugin.version=0.34-SNAPSHOT 1. j2cli version ```bash - docker run --rm abrarov/j2cli:0.3.10-1.0.3 + docker run --rm abrarov/j2cli:0.3.10-1.0.4 ``` Expected output is: @@ -89,7 +89,7 @@ Assuming the current directory is a directory where this repository is cloned. * Test connection to Redis ```bash - docker run --rm --network redis_default abrarov/redis:6.0.9-1.0.3 redis-cli -h redis ping + docker run --rm --network redis_default abrarov/redis:6.0.9-1.0.4 redis-cli -h redis ping ``` Expected output is: @@ -101,7 +101,7 @@ Assuming the current directory is a directory where this repository is cloned. * Put some data into Redis ```bash - docker run --rm --network redis_default abrarov/redis:6.0.9-1.0.3 redis-cli -h redis set foo bar + docker run --rm --network redis_default abrarov/redis:6.0.9-1.0.4 redis-cli -h redis set foo bar ``` Expected output is: @@ -125,7 +125,7 @@ Assuming the current directory is a directory where this repository is cloned. * Test persistence of stored data ```bash - docker run --rm --network redis_default abrarov/redis:6.0.9-1.0.3 redis-cli -h redis get foo + docker run --rm --network redis_default abrarov/redis:6.0.9-1.0.4 redis-cli -h redis get foo ``` Expected output is: diff --git a/docker-compose.yml b/docker-compose.yml index b9af817..51bdb79 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,7 @@ version: '2.1' -x-redis-conf-dir: &redis-conf-dir '/config' +x-redis-conf-producer-volume: &redis-conf-producer-volume 'redis-config:/config:rw' +x-redis-conf-consumer-volume: &redis-conf-consumer-volume 'redis-config:/config:ro' x-redis-conf-file: &redis-conf-file '/config/redis.conf' x-redis-port: &redis-port '6379' x-redis-port-mapping: &redis-port-mapping '6379:6379' @@ -9,16 +10,18 @@ x-helper-dir: &helper-dir '/helper' x-helper-wrapper-script: &helper-wrapper-script '/helper/run.sh' x-helper-dockerize: &helper-dockerize '/helper/dockerize' -services: +volumes: + redis-config: +services: helper: - image: '${IMAGE_REGISTRY:-abrarov}/redis-helper:${PROJECT_VERSION:-1.0.3}' + image: '${IMAGE_REGISTRY:-abrarov}/redis-helper:${PROJECT_VERSION:-1.0.4}' read_only: true volumes: - *helper-dir init: - image: '${IMAGE_REGISTRY:-abrarov}/redis-init:${PROJECT_VERSION:-1.0.3}' + image: '${IMAGE_REGISTRY:-abrarov}/redis-init:${PROJECT_VERSION:-1.0.4}' command: *helper-wrapper-script environment: INIT_COMMAND: '/run.sh' @@ -27,13 +30,15 @@ services: REDIS_LISTEN_BACKLOG: '128' REDIS_PROTECTED_MODE: 'no' REDIS_DATA_DIR: *redis-data-dir + read_only: true volumes: - - *redis-conf-dir + - '/tmp' + - *redis-conf-producer-volume volumes_from: - 'helper:ro' redis: - image: '${IMAGE_REGISTRY:-abrarov}/redis:${REDIS_VERSION:-6.0.9}-${PROJECT_VERSION:-1.0.3}' + image: '${IMAGE_REGISTRY:-abrarov}/redis:${REDIS_VERSION:-6.0.9}-${PROJECT_VERSION:-1.0.4}' command: - *helper-dockerize - '-wait' @@ -57,9 +62,9 @@ services: read_only: true volumes: - '/tmp' + - *redis-conf-consumer-volume - *redis-data-dir volumes_from: - 'helper:ro' - - 'init:ro' ports: - *redis-port-mapping diff --git a/helper-image/pom.xml b/helper-image/pom.xml index 9c157bf..c6adbb3 100644 --- a/helper-image/pom.xml +++ b/helper-image/pom.xml @@ -5,7 +5,7 @@ io.fabric8.dmp.samples redis-builder-parent - 1.0.3 + 1.0.4 helper-image diff --git a/j2cli-builder-image/pom.xml b/j2cli-builder-image/pom.xml index 405c3f6..bb000e7 100644 --- a/j2cli-builder-image/pom.xml +++ b/j2cli-builder-image/pom.xml @@ -5,7 +5,7 @@ io.fabric8.dmp.samples redis-builder-parent - 1.0.3 + 1.0.4 j2cli-builder-image diff --git a/j2cli-dist/pom.xml b/j2cli-dist/pom.xml index 7351923..2234bcc 100644 --- a/j2cli-dist/pom.xml +++ b/j2cli-dist/pom.xml @@ -5,7 +5,7 @@ io.fabric8.dmp.samples redis-builder-parent - 1.0.3 + 1.0.4 j2cli-dist diff --git a/j2cli-image/pom.xml b/j2cli-image/pom.xml index 85d6e85..93a8ba1 100644 --- a/j2cli-image/pom.xml +++ b/j2cli-image/pom.xml @@ -5,7 +5,7 @@ io.fabric8.dmp.samples redis-builder-parent - 1.0.3 + 1.0.4 j2cli-image diff --git a/pom.xml b/pom.xml index 87d7eeb..00d4fea 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.fabric8.dmp.samples redis-builder-parent - 1.0.3 + 1.0.4 pom diff --git a/redis-builder-image/pom.xml b/redis-builder-image/pom.xml index 7b5988f..285cdf2 100644 --- a/redis-builder-image/pom.xml +++ b/redis-builder-image/pom.xml @@ -5,7 +5,7 @@ io.fabric8.dmp.samples redis-builder-parent - 1.0.3 + 1.0.4 redis-builder-image diff --git a/redis-dist/pom.xml b/redis-dist/pom.xml index b4efb1d..fbc0052 100644 --- a/redis-dist/pom.xml +++ b/redis-dist/pom.xml @@ -5,7 +5,7 @@ io.fabric8.dmp.samples redis-builder-parent - 1.0.3 + 1.0.4 redis-dist diff --git a/redis-image/pom.xml b/redis-image/pom.xml index 65a87c8..2763b7b 100644 --- a/redis-image/pom.xml +++ b/redis-image/pom.xml @@ -5,7 +5,7 @@ io.fabric8.dmp.samples redis-builder-parent - 1.0.3 + 1.0.4 redis-image diff --git a/redis-init-image/pom.xml b/redis-init-image/pom.xml index 94cd964..48e908e 100644 --- a/redis-init-image/pom.xml +++ b/redis-init-image/pom.xml @@ -5,7 +5,7 @@ io.fabric8.dmp.samples redis-builder-parent - 1.0.3 + 1.0.4 redis-init-image