-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yaml
71 lines (61 loc) · 3 KB
/
docker-compose.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
version: "3.7"
# This is a testing docker-compose as used as a dev playground to simulate kubernetes init containers.
# it makes use of the "service_completed_successfully" dependency condition.
# Refs:
# 1. https://github.com/compose-spec/compose-spec/blob/master/spec.md#long-syntax-1
# 2. https://github.com/docker/compose-cli/pull/1502
# I am simluating a kubernetes emptyDir using a shared tmpfs volume. This is not officially supported at the moment.
# I have managed to hack it to work by mounting the tmpfs volume on the "bootstrap-temp" service first and only then writing and reading for it from the other two service.
# Without it, the tmpfs gets wiped when the "bootstrap" service exits.
# The documentions (https://docs.docker.com/storage/tmpfs/) currently says:
# > Unlike volumes and bind mounts, you can’t share tmpfs mounts between containers.
#
# Edit sample_secrets_manifest.yaml or provider your own manifest listing your own secrets
services:
bootstrap:
build:
context: .
args:
- VERSION=local_dev_build
environment:
- AWS_REGION=us-east-1
- AWS_PROFILE=dev
- APP_LOGLEVEL=debug
volumes:
- secrets-volume:/secretsfetcher/secrets
- ~/.aws/:/home/appuser/.aws
- ./example/manifest/sample_secrets_manifest.yaml:/home/appuser/secrets_manifest.yaml
depends_on:
bootstrap-temp:
condition: service_started
command: "aws -m=/home/appuser/secrets_manifest.yaml -o=/secretsfetcher/secrets --consolelog"
#command: "aws --tags=app=api-verifier,secret-type=api-verifier-user --prefix=api-verifier-users/ -o=/secretsfetcher/secrets --consolelog"
# Sample service to consume the secrets off the tmpfs volume
sample-svc:
image: alpine:3.14.0
volumes:
- secrets-volume:/secretsfetcher/secrets:ro
depends_on:
bootstrap:
condition: service_completed_successfully
bootstrap-temp:
condition: service_started
#command: sh -c "echo "SAMPLE SERVICE" && ls -als /secretsfetcher/secrets/ && apk update && apk add jq && find /secretsfetcher/secrets/ -type f | xargs -I'{}' jq -s '.' \"{}\" | jq '. | { secrets":" .}'"
#command: ls -als /secretsfetcher/secrets/
command: sh -c "ls -als /secretsfetcher/secrets/ && apk update && apk add jq && find /secretsfetcher/secrets/ -type f | xargs -I'{}' jq -s '.' \"{}\" | jq '. | { secrets":" .}'"
# just a hack service to
bootstrap-temp:
image: busybox
volumes:
- secrets-volume:/secretsfetcher/secrets
command: sh -c 'echo "sleeping for 20 sec" && sleep 20 && echo "JKAJD*(AS&*( secret content" > "/secretsfetcher/secrets/secret1" && exit 0'
# top level tmpfs shared volumes: https://github.com/docker/compose/issues/5682
# this should work https://stackoverflow.com/questions/44284484/docker-compose-share-named-volume-between-multiple-containers
# and does work if bootstrap-temp is started
volumes:
secrets-volume:
driver: local
driver_opts:
type: tmpfs
device: tmpfs
# o: "size=256m,uid=1000"