-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompose.yaml
73 lines (67 loc) · 2.29 KB
/
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
71
72
73
# NOTE: rebuild all docker images and run docker compose:
# docker compose up --build --force-recreate --no-deps (rebuilds all the services)
services:
kvs:
container_name: "kvs-service"
image: 'kvs:latest'
build:
dockerfile: ./Dockerfile.kvs
ports:
# Port 8080 is accessible for servier-to-service communication,
# and the same port is available for accessing the container from outside the network.
# locahost has to be specified, otherwise some weird things happening,
# only occasionally I can reach the endpoint from outside, using other clients (python for example).
- "127.0.0.1:8080:8080"
# this is reserved for fiber service
# - "127.0.0.1:8080:4000"
depends_on:
- transaction-service
networks:
- backend
transaction-service:
container_name: "transaction-service"
image: "txn:latest"
build:
dockerfile: ./Dockerfile.txn
ports:
- "5051:5051"
depends_on:
postgres-db:
condition: service_healthy
networks:
- backend
postgres-db:
image: 'postgres:16.3'
restart: always
container_name: "postgres-emulator"
ports:
# https://docs.docker.com/compose/networking/
# HOST_PORT:CONTAINER_PORT
# Networked service-to-service communication uses the CONTAINER_PORT.
# Using the HOST_PORT, the container can be accessible from outside the network.
# Thus, in order for kvs server to connect to postgres database running in a separate
# docker container it should use URL: postgres://...@postgres-db:CONTAINER_PORT/...
- "4040:5432"
environment:
# Define environment variables inside the container.
# It can come from .env file as well using env_file: directive.
- POSTGRES_PORT=5432
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=nastish
- POSTGRES_DB=postgres
command: ["-c", "ssl=off"]
networks:
- backend
healthcheck:
# https://docs.docker.com/reference/dockerfile/#healthcheck
# https://www.postgresql.org/docs/9.4/app-pg-isready.html
test: ["CMD-SHELL", "pg_isready", "-d", "db_prod"]
interval: 10s
timeout: 2s
retries: 5
start_period: 0s
# volumes:
# - postgres-db:/var/lib/postgresql/data
networks:
backend:
driver: bridge