File size: 3,198 Bytes
83a59ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
services:
  cockroachdb:
    image: cockroachdb/cockroach:latest
    command: start-single-node --insecure --store=type=mem,size=640MiB
    ports:
      - "26257:26257"
      - "8081:8080"
    healthcheck:
      test:
        [
          "CMD",
          "cockroach",
          "sql",
          "--insecure",
          "--host=localhost",
          "--execute=SELECT 1;",
        ]
      interval: 5s
      timeout: 5s
      retries: 10
      start_period: 10s

  cockroachdb-init:
    image: cockroachdb/cockroach:latest
    depends_on:
      cockroachdb:
        condition: service_healthy
    entrypoint:
      [
        "cockroach",
        "sql",
        "--insecure",
        "--host=cockroachdb",
        "--execute=CREATE DATABASE IF NOT EXISTS httpsms;",
      ]
    restart: "no"

  redis:
    image: redis:latest
    command: redis-server
    ports:
      - "6379:6379"
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 5s
      retries: 10

  mongodb:
    image: mongo:7
    ports:
      - "27017:27017"
    environment:
      MONGO_INITDB_ROOT_USERNAME: httpsms
      MONGO_INITDB_ROOT_PASSWORD: testpassword
    healthcheck:
      test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
      interval: 5s
      timeout: 5s
      retries: 10
      start_period: 5s

  wiremock:
    image: wiremock/wiremock:3x
    ports:
      - "8080:8080"
    volumes:
      - ./wiremock/mappings:/home/wiremock/mappings:ro
    networks:
      default:
        aliases:
          - wiremock.local
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8080/__admin/health"]
      interval: 5s
      timeout: 5s
      retries: 10

  adapter-emulator:
    build:
      context: ./adapter-emulator
    ports:
      - "9092:9092"
    environment:
      API_BASE_URL: http://api:8000
      ADAPTER_TLS_CERT: /certs/server.pem
      ADAPTER_TLS_KEY: /certs/server-key.pem
    volumes:
      - ./certs:/certs:ro
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://localhost:9092/health"]
      interval: 5s
      timeout: 5s
      retries: 10

  api:
    build:
      context: ../api
    ports:
      - "8000:8000"
    depends_on:
      cockroachdb-init:
        condition: service_completed_successfully
      redis:
        condition: service_healthy
      wiremock:
        condition: service_healthy
      mongodb:
        condition: service_healthy
      adapter-emulator:
        condition: service_healthy
    env_file:
      - .env.test
    environment:
      FIREBASE_CREDENTIALS: "${FIREBASE_CREDENTIALS}"
      SSL_CERT_FILE: /adapter-certs/ca.pem
    volumes:
      - ./certs/ca.pem:/adapter-certs/ca.pem:ro
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
      interval: 5s
      timeout: 10s
      retries: 20
      start_period: 30s

  seed:
    image: cockroachdb/cockroach:latest
    depends_on:
      api:
        condition: service_healthy
    volumes:
      - ./seed.sql:/seed.sql:ro
    entrypoint:
      [
        "cockroach",
        "sql",
        "--insecure",
        "--host=cockroachdb",
        "--database=httpsms",
        "--file=/seed.sql",
      ]
    restart: "no"