vitess.io/vitess@v0.16.2/examples/compose/docker-compose.beginners.yml (about) 1 version: "2.1" 2 services: 3 consul1: 4 image: consul:latest 5 hostname: "consul1" 6 ports: 7 - "8400:8400" 8 - "8500:8500" 9 - "8600:8600" 10 command: "agent -server -bootstrap-expect 3 -ui -disable-host-node-id -client 0.0.0.0" 11 consul2: 12 image: consul:latest 13 hostname: "consul2" 14 expose: 15 - "8400" 16 - "8500" 17 - "8600" 18 command: "agent -server -retry-join consul1 -disable-host-node-id" 19 depends_on: 20 - consul1 21 consul3: 22 image: consul:latest 23 hostname: "consul3" 24 expose: 25 - "8400" 26 - "8500" 27 - "8600" 28 command: "agent -server -retry-join consul1 -disable-host-node-id" 29 depends_on: 30 - consul1 31 # This is a convenience container to quickly test vitess against an external database. 32 # In practice you will point Vitess to your existing database and migrate to a Vitess managed cluster. 33 external_db_host: 34 build: 35 context: ./external_db/mysql 36 dockerfile: Dockerfile 37 restart: always 38 environment: 39 MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-pass} 40 MYSQL_DATABASE: ${DB:-commerce} 41 MYSQL_USER: ${DB_USER:-external_db_user} 42 MYSQL_PASSWORD: ${DB_PASS:-external_db_password} 43 volumes: 44 - ./external_db/mysql/:/docker-entrypoint-initdb.d/ 45 - ./external_db/mysql/log:/var/log/mysql 46 command: 47 - --server-id=1 48 - --log-bin=mysql-bin 49 - --gtid_mode=ON 50 - --enforce_gtid_consistency 51 - --general_log=1 52 - --slow_query_log=1 53 healthcheck: 54 test: "/usr/bin/mysql --user=root --password=$${MYSQL_ROOT_PASSWORD} --execute \"SHOW DATABASES;\"" 55 timeout: 10s 56 retries: 10 57 ports: 58 - "3306" 59 60 vtctld: 61 image: vitess/lite:v16.0.2 62 ports: 63 - "15000:$WEB_PORT" 64 - "$GRPC_PORT" 65 command: ["sh", "-c", " /vt/bin/vtctld \ 66 $TOPOLOGY_FLAGS \ 67 --cell $CELL \ 68 --service_map 'grpc-vtctl,grpc-vtctld' \ 69 --backup_storage_implementation file \ 70 --file_backup_storage_root /vt/vtdataroot/backups \ 71 --logtostderr=true \ 72 --port $WEB_PORT \ 73 --grpc_port $GRPC_PORT 74 "] 75 depends_on: 76 - consul1 77 - consul2 78 - consul3 79 depends_on: 80 external_db_host: 81 condition: service_healthy 82 83 vtgate: 84 image: vitess/lite:v16.0.2 85 ports: 86 - "15099:$WEB_PORT" 87 - "$GRPC_PORT" 88 - "15306:$MYSQL_PORT" 89 command: ["sh", "-c", "/vt/bin/vtgate \ 90 $TOPOLOGY_FLAGS \ 91 --logtostderr=true \ 92 --port $WEB_PORT \ 93 --grpc_port $GRPC_PORT \ 94 --mysql_server_port $MYSQL_PORT \ 95 --mysql_auth_server_impl none \ 96 --cell $CELL \ 97 --cells_to_watch $CELL \ 98 --tablet_types_to_wait PRIMARY,REPLICA \ 99 --service_map 'grpc-vtgateservice' \ 100 --enable_system_settings=true \ 101 "] 102 volumes: 103 - ".:/script" 104 environment: 105 - KEYSPACE 106 - DB 107 depends_on: 108 - vtctld 109 depends_on: 110 vttablet101: 111 condition: service_healthy 112 113 schemaload: 114 image: vitess/lite:v16.0.2 115 command: 116 - sh 117 - -c 118 - /script/schemaload.sh 119 environment: 120 - TOPOLOGY_FLAGS 121 - WEB_PORT 122 - GRPC_PORT 123 - CELL 124 - KEYSPACE 125 - TARGETTAB 126 - SLEEPTIME 127 - VSCHEMA_FILE 128 - SCHEMA_FILES 129 - POST_LOAD_FILE 130 - EXTERNAL_DB 131 volumes: 132 - .:/script 133 depends_on: 134 vttablet101: 135 condition: service_healthy 136 137 set_keyspace_durability_policy: 138 command: 139 - sh 140 - -c 141 - /script/set_keyspace_durability_policy.sh 142 depends_on: 143 - vttablet100 144 environment: 145 - KEYSPACES=$KEYSPACE 146 - GRPC_PORT=15999 147 image: vitess/lite:v16.0.2 148 volumes: 149 - .:/script 150 151 vttablet100: 152 image: vitess/lite:v16.0.2 153 ports: 154 - "15100:$WEB_PORT" 155 - "$GRPC_PORT" 156 - "3306" 157 volumes: 158 - ".:/script" 159 - "./backups:/vt/vtdataroot/backups" 160 environment: 161 - TOPOLOGY_FLAGS 162 - WEB_PORT 163 - GRPC_PORT 164 - CELL 165 - KEYSPACE 166 - DB 167 - EXTERNAL_DB 168 - DB_PORT 169 - DB_HOST 170 - DB_USER 171 - DB_PASS 172 - DB_CHARSET 173 - ROLE=primary 174 command: ["sh", "-c", "[ $$EXTERNAL_DB -eq 1 ] && /script/vttablet-up.sh 100 || exit 0"] 175 depends_on: 176 - vtctld 177 healthcheck: 178 test: ["CMD-SHELL","curl -s --fail --show-error localhost:$$WEB_PORT/debug/health"] 179 interval: 30s 180 timeout: 10s 181 retries: 15 182 183 vttablet101: 184 image: vitess/lite:v16.0.2 185 ports: 186 - "15101:$WEB_PORT" 187 - "$GRPC_PORT" 188 - "3306" 189 volumes: 190 - ".:/script" 191 - "./backups:/vt/vtdataroot/backups" 192 environment: 193 - TOPOLOGY_FLAGS 194 - WEB_PORT 195 - GRPC_PORT 196 - CELL 197 - KEYSPACE 198 - DB 199 - EXTERNAL_DB 200 - DB_PORT 201 - DB_HOST 202 - DB_USER 203 - DB_PASS 204 - DB_CHARSET 205 - ROLE=primary 206 command: ["sh", "-c", "/script/vttablet-up.sh 101"] 207 depends_on: 208 - vtctld 209 healthcheck: 210 test: ["CMD-SHELL","curl -s --fail --show-error localhost:$$WEB_PORT/debug/health"] 211 interval: 30s 212 timeout: 10s 213 retries: 15 214 215 vttablet102: 216 image: vitess/lite:v16.0.2 217 ports: 218 - "15102:$WEB_PORT" 219 - "$GRPC_PORT" 220 - "3306" 221 volumes: 222 - ".:/script" 223 - "./backups:/vt/vtdataroot/backups" 224 environment: 225 - TOPOLOGY_FLAGS 226 - WEB_PORT 227 - GRPC_PORT 228 - CELL 229 - KEYSPACE 230 - DB 231 - EXTERNAL_DB 232 - DB_PORT 233 - DB_HOST 234 - DB_USER 235 - DB_PASS 236 - DB_CHARSET 237 command: ["sh", "-c", "/script/vttablet-up.sh 102"] 238 depends_on: 239 - vtctld 240 - vttablet101 241 healthcheck: 242 test: ["CMD-SHELL","curl -s --fail --show-error localhost:$$WEB_PORT/debug/health"] 243 interval: 30s 244 timeout: 10s 245 retries: 15 246 247 vttablet103: 248 image: vitess/lite:v16.0.2 249 ports: 250 - "15103:$WEB_PORT" 251 - "$GRPC_PORT" 252 - "3306" 253 volumes: 254 - ".:/script" 255 - "./backups:/vt/vtdataroot/backups" 256 environment: 257 - TOPOLOGY_FLAGS 258 - WEB_PORT 259 - GRPC_PORT 260 - CELL 261 - KEYSPACE 262 - DB 263 - EXTERNAL_DB 264 - DB_PORT 265 - DB_HOST 266 - DB_USER 267 - DB_PASS 268 - DB_CHARSET 269 command: ["sh", "-c", "/script/vttablet-up.sh 103"] 270 depends_on: 271 - vtctld 272 - vttablet101 273 healthcheck: 274 test: ["CMD-SHELL","curl -s --fail --show-error localhost:$$WEB_PORT/debug/health"] 275 interval: 30s 276 timeout: 10s 277 retries: 15 278 279 vtorc: 280 image: vitess/lite:v16.0.2 281 command: ["sh", "-c", "/script/vtorc-up.sh"] 282 depends_on: 283 - vtctld 284 - set_keyspace_durability_policy 285 ports: 286 - "13000:8080" 287 volumes: 288 - ".:/script" 289 environment: 290 - WEB_PORT=8080 291 - TOPOLOGY_FLAGS 292 - WEB_PORT 293 - GRPC_PORT 294 - CELL 295 - KEYSPACE 296 - DB 297 - EXTERNAL_DB 298 - DB_PORT 299 - DB_HOST 300 - DB_USER 301 - DB_PASS 302 - DB_CHARSET 303 healthcheck: 304 test: ["CMD-SHELL","curl -s --fail --show-error localhost:8080/debug/health"] 305 interval: 5s 306 timeout: 10s 307 retries: 15 308 309 vreplication: 310 image: vitess/lite:v16.0.2 311 volumes: 312 - ".:/script" 313 environment: 314 - TOPOLOGY_FLAGS 315 - WEB_PORT 316 - GRPC_PORT 317 - CELL 318 - KEYSPACE 319 - DB 320 - EXTERNAL_DB 321 - DB_PORT 322 - DB_HOST 323 - DB_USER 324 - DB_PASS 325 - DB_CHARSET 326 command: ["sh", "-c", "[ $$EXTERNAL_DB -eq 1 ] && /script/externaldb_vreplication.sh || exit 0"] 327 depends_on: 328 - vtctld