|
| 1 | +name: ${COMPOSE_PROJECT_NAME:?error} |
| 2 | +# https://docs.docker.com/reference/compose-file/networks/ |
| 3 | +networks: |
| 4 | + api: |
| 5 | + minio: |
| 6 | + postgres: |
| 7 | +# https://docs.docker.com/reference/compose-file/services |
| 8 | +services: |
| 9 | + api: |
| 10 | + # https://docs.docker.com/reference/compose-file/build/ |
| 11 | + build: |
| 12 | + # https://docs.docker.com/reference/compose-file/build/#args |
| 13 | + args: |
| 14 | + - API_GID=${API_GID:?error} |
| 15 | + - API_UID=${API_UID:?error} |
| 16 | + # https://docs.docker.com/reference/compose-file/build/#context |
| 17 | + context: ./ |
| 18 | + # https://docs.docker.com/reference/compose-file/build/#dockerfile |
| 19 | + dockerfile: ./api.Containerfile |
| 20 | + # https://docs.docker.com/reference/compose-file/build/#target |
| 21 | + target: production |
| 22 | + # https://docs.docker.com/reference/compose-file/services/#depends_on |
| 23 | + depends_on: |
| 24 | + minio: |
| 25 | + condition: service_healthy |
| 26 | + # Should be set to false when a third party minio service could be used in the api service and the `minio` compose profile is disabled. |
| 27 | + required: false |
| 28 | + postgres: |
| 29 | + condition: service_healthy |
| 30 | + # Should be set to false when a third party postgres service could be used in the api service the and the `postgres` compose profile is disabled. |
| 31 | + required: false |
| 32 | + # https://docs.docker.com/compose/environment-variables/ |
| 33 | + # https://docs.docker.com/reference/compose-file/services/#environment |
| 34 | + environment: |
| 35 | + - API_ADMINISTRATOR_USER_EMAIL_ADDRESS=${API_ADMINISTRATOR_USER_EMAIL_ADDRESS:?error} |
| 36 | + - API_ADMINISTRATOR_USER_NAME=${API_ADMINISTRATOR_USER_NAME:?error} |
| 37 | + - API_ADMINISTRATOR_USER_PASSWORD=${API_ADMINISTRATOR_USER_PASSWORD:?error} |
| 38 | + - API_BASE_URL=${API_BASE_URL:?error} |
| 39 | + - API_COMMUNITY_FACEBOOK_URL=${API_COMMUNITY_FACEBOOK_URL:?error} |
| 40 | + - API_COMMUNITY_GITHUB_URL=${API_COMMUNITY_GITHUB_URL:?error} |
| 41 | + - API_COMMUNITY_INACTIVITY_TIMEOUT_DURATION=${API_COMMUNITY_INACTIVITY_TIMEOUT_DURATION:?error} |
| 42 | + - API_COMMUNITY_INSTAGRAM_URL=${API_COMMUNITY_INSTAGRAM_URL:?error} |
| 43 | + - API_COMMUNITY_LINKEDIN_URL=${API_COMMUNITY_LINKEDIN_URL:?error} |
| 44 | + - API_COMMUNITY_NAME=${API_COMMUNITY_NAME:?error} |
| 45 | + - API_COMMUNITY_REDDIT_URL=${API_COMMUNITY_REDDIT_URL:?error} |
| 46 | + - API_COMMUNITY_SLACK_URL=${API_COMMUNITY_SLACK_URL:?error} |
| 47 | + - API_COMMUNITY_WEBSITE_URL=${API_COMMUNITY_WEBSITE_URL:?error} |
| 48 | + - API_COMMUNITY_X_URL=${API_COMMUNITY_X_URL:?error} |
| 49 | + - API_COMMUNITY_YOUTUBE_URL=${API_COMMUNITY_YOUTUBE_URL:?error} |
| 50 | + - API_HOST=${API_HOST:?error} |
| 51 | + - API_IS_APPLY_DRIZZLE_MIGRATIONS=${API_IS_APPLY_DRIZZLE_MIGRATIONS:?error} |
| 52 | + - API_IS_GRAPHIQL=${API_IS_GRAPHIQL:?error} |
| 53 | + - API_IS_PINO_PRETTY=${API_IS_PINO_PRETTY:?error} |
| 54 | + - API_JWT_EXPIRES_IN=${API_JWT_EXPIRES_IN:?error} |
| 55 | + - API_JWT_SECRET=${API_JWT_SECRET:?error} |
| 56 | + - API_LOG_LEVEL=${API_LOG_LEVEL:?error} |
| 57 | + - API_MINIO_ACCESS_KEY=${API_MINIO_ACCESS_KEY:?error} |
| 58 | + - API_MINIO_END_POINT=${API_MINIO_END_POINT:?error} |
| 59 | + - API_MINIO_PORT=${API_MINIO_PORT:?error} |
| 60 | + - API_MINIO_SECRET_KEY=${API_MINIO_SECRET_KEY:?error} |
| 61 | + - API_MINIO_USE_SSL=${API_MINIO_USE_SSL:?error} |
| 62 | + - API_PORT=${API_PORT:?error} |
| 63 | + - API_POSTGRES_DATABASE=${API_POSTGRES_DATABASE:?error} |
| 64 | + - API_POSTGRES_HOST=${API_POSTGRES_HOST:?error} |
| 65 | + - API_POSTGRES_PASSWORD=${API_POSTGRES_PASSWORD:?error} |
| 66 | + - API_POSTGRES_PORT=${API_POSTGRES_PORT:?error} |
| 67 | + - API_POSTGRES_SSL_MODE=${API_POSTGRES_SSL_MODE:?error} |
| 68 | + - API_POSTGRES_USER=${API_POSTGRES_USER:?error} |
| 69 | + - CI=${CI:?error} |
| 70 | + - NODE_ENV=${NODE_ENV:?error} |
| 71 | + # https://docs.docker.com/reference/compose-file/build/#using-build-and-image |
| 72 | + # https://docs.docker.com/reference/compose-file/build/#publishing-built-images |
| 73 | + # https://docs.docker.com/reference/compose-file/services/#image |
| 74 | + # image: ghcr.io/talawa/api:latest |
| 75 | + # https://docs.docker.com/reference/dockerfile/#healthcheck |
| 76 | + # https://docs.docker.com/reference/compose-file/services/#healthcheck |
| 77 | + healthcheck: |
| 78 | + interval: 10s |
| 79 | + retries: 3 |
| 80 | + start_interval: 1s |
| 81 | + start_period: 5s |
| 82 | + test: ["CMD-SHELL", "node /home/talawa/api/docker/apiHealthcheck.js"] |
| 83 | + timeout: 10s |
| 84 | + # https://docs.docker.com/reference/compose-file/services/#init |
| 85 | + # https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#handling-kernel-signals |
| 86 | + init: true |
| 87 | + # https://docs.docker.com/reference/compose-file/services/#networks |
| 88 | + networks: |
| 89 | + - api |
| 90 | + - minio |
| 91 | + - postgres |
| 92 | + # https://docs.docker.com/reference/compose-file/services/#ports |
| 93 | + ports: |
| 94 | + - host_ip: ${API_MAPPED_HOST_IP:?error} |
| 95 | + name: api |
| 96 | + published: ${API_MAPPED_PORT:?error} |
| 97 | + target: ${API_PORT} |
| 98 | + # https://docs.docker.com/reference/compose-file/services/#profiles |
| 99 | + profiles: |
| 100 | + - api |
| 101 | + # https://docs.docker.com/reference/compose-file/services/#restart |
| 102 | + restart: unless-stopped |
| 103 | + caddy: |
| 104 | + # https://docs.docker.com/reference/compose-file/services/#depends_on |
| 105 | + depends_on: |
| 106 | + api: |
| 107 | + condition: service_healthy |
| 108 | + required: true |
| 109 | + # https://docs.docker.com/compose/environment-variables/ |
| 110 | + # https://docs.docker.com/reference/compose-file/services/#environment |
| 111 | + environment: |
| 112 | + - CADDY_TALAWA_API_DOMAIN_NAME=${CADDY_TALAWA_API_DOMAIN_NAME:?error} |
| 113 | + - CADDY_TALAWA_API_EMAIL=${CADDY_TALAWA_API_EMAIL:?error} |
| 114 | + - CADDY_TALAWA_API_HOST=${CADDY_TALAWA_API_HOST:?error} |
| 115 | + - CADDY_TALAWA_API_PORT=${CADDY_TALAWA_API_PORT:?error} |
| 116 | + # https://caddyserver.com/docs/install#docker |
| 117 | + # https://hub.docker.com/_/caddy |
| 118 | + image: caddy:2.8.4-alpine |
| 119 | + # https://docs.docker.com/reference/compose-file/services/#networks |
| 120 | + networks: |
| 121 | + - api |
| 122 | + # https://docs.docker.com/reference/compose-file/services/#ports |
| 123 | + ports: |
| 124 | + - name: caddy_http |
| 125 | + published: ${CADDY_HTTP_MAPPED_PORT:?error} |
| 126 | + target: 80 |
| 127 | + - name: caddy_https |
| 128 | + published: ${CADDY_HTTPS_MAPPED_PORT:?error} |
| 129 | + target: 443 |
| 130 | + - name: caddy_http3 |
| 131 | + protocol: udp |
| 132 | + published: ${CADDY_HTTP3_MAPPED_PORT:?error} |
| 133 | + target: 443 |
| 134 | + # https://docs.docker.com/reference/compose-file/services/#profiles |
| 135 | + profiles: |
| 136 | + - caddy |
| 137 | + # https://docs.docker.com/reference/compose-file/services/#restart |
| 138 | + restart: unless-stopped |
| 139 | + # https://docs.docker.com/reference/compose-file/services/#volumes |
| 140 | + volumes: |
| 141 | + - source: caddy_config |
| 142 | + target: /config |
| 143 | + type: volume |
| 144 | + - source: caddy_data |
| 145 | + target: /data |
| 146 | + type: volume |
| 147 | + - source: ./Caddyfile |
| 148 | + target: /etc/caddy/Caddyfile |
| 149 | + type: bind |
| 150 | + minio: |
| 151 | + # https://docs.docker.com/compose/environment-variables/ |
| 152 | + # https://docs.docker.com/reference/compose-file/services/#environment |
| 153 | + environment: |
| 154 | + - MINIO_BROWSER=${MINIO_BROWSER:?error} |
| 155 | + # https://min.io/docs/minio/linux/reference/minio-server/settings/root-credentials.html#envvar.MINIO_ROOT_PASSWORD |
| 156 | + - MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD:?error} |
| 157 | + # https://min.io/docs/minio/linux/reference/minio-server/settings/root-credentials.html#root-user |
| 158 | + - MINIO_ROOT_USER=${MINIO_ROOT_USER:?error} |
| 159 | + # https://docs.docker.com/reference/compose-file/services/#command |
| 160 | + command: server /data --console-address ":9001" |
| 161 | + # https://docs.docker.com/reference/dockerfile/#healthcheck |
| 162 | + # https://docs.docker.com/reference/compose-file/services/#healthcheck |
| 163 | + healthcheck: |
| 164 | + interval: 10s |
| 165 | + retries: 3 |
| 166 | + start_interval: 1s |
| 167 | + start_period: 5s |
| 168 | + # https://github.com/minio/minio/issues/18373 |
| 169 | + # https://min.io/docs/minio/linux/reference/minio-mc/mc-ready.html |
| 170 | + test: ["CMD-SHELL", "mc ready local"] |
| 171 | + timeout: 10s |
| 172 | + # https://docs.docker.com/reference/compose-file/services/#image |
| 173 | + # https://hub.docker.com/r/minio/minio |
| 174 | + image: minio/minio:RELEASE.2024-12-18T13-15-44Z |
| 175 | + # https://docs.docker.com/reference/compose-file/services/#networks |
| 176 | + networks: |
| 177 | + - minio |
| 178 | + # https://docs.docker.com/reference/compose-file/services/#profiles |
| 179 | + profiles: |
| 180 | + - minio |
| 181 | + # https://docs.docker.com/reference/compose-file/services/#restart |
| 182 | + restart: unless-stopped |
| 183 | + # https://docs.docker.com/reference/compose-file/services/#volumes |
| 184 | + volumes: |
| 185 | + - source: minio_data |
| 186 | + target: /data |
| 187 | + type: volume |
| 188 | + postgres: |
| 189 | + # https://docs.docker.com/compose/environment-variables/ |
| 190 | + # https://docs.docker.com/reference/compose-file/services/#environment |
| 191 | + environment: |
| 192 | + # https://github.com/docker-library/docs/blob/master/postgres/README.md#postgres_db |
| 193 | + - POSTGRES_DB=${POSTGRES_DB:?error} |
| 194 | + # https://github.com/docker-library/docs/blob/master/postgres/README.md#postgres_password |
| 195 | + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:?error} |
| 196 | + # https://github.com/docker-library/docs/blob/master/postgres/README.md#postgres_user |
| 197 | + - POSTGRES_USER=${POSTGRES_USER:?error} |
| 198 | + # https://docs.docker.com/reference/dockerfile/#healthcheck |
| 199 | + # https://docs.docker.com/reference/compose-file/services/#healthcheck |
| 200 | + healthcheck: |
| 201 | + interval: 10s |
| 202 | + retries: 3 |
| 203 | + start_interval: 1s |
| 204 | + start_period: 5s |
| 205 | + # https://stackoverflow.com/questions/60193781/postgres-with-docker-compose-gives-fatal-role-root-does-not-exist-error |
| 206 | + # https://www.postgresql.org/docs/current/app-pg-isready.html |
| 207 | + test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"] |
| 208 | + timeout: 10s |
| 209 | + # https://docs.docker.com/reference/compose-file/services/#image |
| 210 | + # https://hub.docker.com/_/postgres |
| 211 | + image: postgres:17.2-alpine3.21 |
| 212 | + # https://docs.docker.com/reference/compose-file/services/#networks |
| 213 | + networks: |
| 214 | + - postgres |
| 215 | + # https://docs.docker.com/reference/compose-file/services/#profiles |
| 216 | + profiles: |
| 217 | + - postgres |
| 218 | + # https://docs.docker.com/reference/compose-file/services/#restart |
| 219 | + restart: unless-stopped |
| 220 | + # https://docs.docker.com/reference/compose-file/services/#volumes |
| 221 | + volumes: |
| 222 | + - source: postgres_data |
| 223 | + target: /var/lib/postgresql/data |
| 224 | + type: volume |
| 225 | +# https://docs.docker.com/reference/compose-file/volumes/ |
| 226 | +volumes: |
| 227 | + caddy_config: |
| 228 | + caddy_data: |
| 229 | + minio_data: |
| 230 | + postgres_data: |
0 commit comments