docker-compose.yml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. # To make it easier to self-host, we have a preset docker compose config that also
  2. # has a container with a Postgres instance running.
  3. # You can tweak around this file to match your instances
  4. # PROFILES EXPLANATION:
  5. #
  6. # We use Docker Compose profiles to manage different deployment scenarios and avoid port conflicts.
  7. #
  8. # These are all the available profiles:
  9. # - default: All-in-one service + database + auto-migration (recommended for most users)
  10. # - default-no-db: All-in-one service without database (for users with external DB)
  11. # - backend: The backend service only
  12. # - app: The main Hoppscotch application and the webapp server
  13. # - admin: The self-host admin dashboard only
  14. # - database: Just the PostgreSQL database
  15. # - just-backend: All services except webapp for local development
  16. # - deprecated: All deprecated services (not recommended)
  17. # USAGE:
  18. #
  19. # To run the default setup: docker compose --profile default up
  20. # To run without database: docker compose --profile default-no-db up
  21. # To run specific components: docker compose --profile backend up
  22. # To run all except webapp: docker compose --profile just-backend up
  23. # To run deprecated services: docker compose --profile deprecated up
  24. # NOTE: The default and default-no-db profiles should not be mixed with individual service
  25. # profiles as they would conflict on ports.
  26. services:
  27. # This service runs the backend app in the port 3170
  28. hoppscotch-backend:
  29. profiles: ["backend", "just-backend"]
  30. container_name: hoppscotch-backend
  31. build:
  32. dockerfile: prod.Dockerfile
  33. context: .
  34. target: backend
  35. env_file:
  36. - ./.env
  37. restart: always
  38. environment:
  39. # Edit the below line to match your PostgresDB URL if you have an outside DB (make sure to update the .env file as well)
  40. - DATABASE_URL=postgresql://postgres:testpass@hoppscotch-db:5432/hoppscotch?connect_timeout=300
  41. - PORT=8080
  42. volumes:
  43. # Uncomment the line below when modifying code. Only applicable when using the "dev" target.
  44. # - ./packages/hoppscotch-backend/:/usr/src/app
  45. - /usr/src/app/node_modules/
  46. depends_on:
  47. hoppscotch-db:
  48. condition: service_healthy
  49. ports:
  50. - "3180:80"
  51. - "3170:3170"
  52. # The main hoppscotch app with integrated webapp server. This will be hosted at port 3000
  53. # The webapp server will be accessible at port 3200
  54. # NOTE: To do TLS or play around with how the app is hosted, you can look into the Caddyfile for
  55. # the SH admin dashboard server at packages/hoppscotch-selfhost-web/Caddyfile
  56. hoppscotch-app:
  57. profiles: ["app"]
  58. container_name: hoppscotch-app
  59. build:
  60. dockerfile: prod.Dockerfile
  61. context: .
  62. target: app
  63. env_file:
  64. - ./.env
  65. depends_on:
  66. - hoppscotch-backend
  67. ports:
  68. - "3080:80"
  69. - "3000:3000"
  70. - "3200:3200"
  71. # The Self Host dashboard for managing the app. This will be hosted at port 3100
  72. # NOTE: To do TLS or play around with how the app is hosted, you can look into the Caddyfile for
  73. # the SH admin dashboard server at packages/hoppscotch-sh-admin/Caddyfile
  74. hoppscotch-sh-admin:
  75. profiles: ["admin"]
  76. container_name: hoppscotch-sh-admin
  77. build:
  78. dockerfile: prod.Dockerfile
  79. context: .
  80. target: sh_admin
  81. env_file:
  82. - ./.env
  83. depends_on:
  84. - hoppscotch-backend
  85. ports:
  86. - "3280:80"
  87. - "3100:3100"
  88. # The service that spins up all services at once in one container
  89. hoppscotch-aio:
  90. profiles: ["default", "default-no-db"]
  91. container_name: hoppscotch-aio
  92. restart: unless-stopped
  93. build:
  94. dockerfile: prod.Dockerfile
  95. context: .
  96. target: aio
  97. env_file:
  98. - ./.env
  99. depends_on:
  100. hoppscotch-db:
  101. condition: service_healthy
  102. ports:
  103. - "3000:3000"
  104. - "3100:3100"
  105. - "3170:3170"
  106. - "3200:3200"
  107. - "3080:80"
  108. # The preset DB service, you can delete/comment the below lines if
  109. # you are using an external postgres instance
  110. # This will be exposed at port 5432
  111. hoppscotch-db:
  112. profiles: ["default", "database", "just-backend"]
  113. image: postgres:15
  114. ports:
  115. - "5432:5432"
  116. user: postgres
  117. environment:
  118. # The default user defined by the docker image
  119. POSTGRES_USER: postgres
  120. # NOTE: Please UPDATE THIS PASSWORD!
  121. POSTGRES_PASSWORD: testpass
  122. POSTGRES_DB: hoppscotch
  123. healthcheck:
  124. test:
  125. [
  126. "CMD-SHELL",
  127. "sh -c 'pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}'",
  128. ]
  129. interval: 5s
  130. timeout: 5s
  131. retries: 10
  132. # Auto-migration service - handles database migrations automatically
  133. hoppscotch-migrate:
  134. profiles: ["default", "just-backend"]
  135. build:
  136. dockerfile: prod.Dockerfile
  137. context: .
  138. target: backend
  139. env_file:
  140. - ./.env
  141. depends_on:
  142. hoppscotch-db:
  143. condition: service_healthy
  144. command: sh -c "pnpx prisma migrate deploy"
  145. # All the services listed below are deprecated
  146. # These services are kept for backward compatibility but should not be used for new deployments
  147. hoppscotch-old-backend:
  148. profiles: ["deprecated"]
  149. container_name: hoppscotch-old-backend
  150. build:
  151. dockerfile: packages/hoppscotch-backend/Dockerfile
  152. context: .
  153. target: prod
  154. env_file:
  155. - ./.env
  156. restart: always
  157. environment:
  158. # Edit the below line to match your PostgresDB URL if you have an outside DB (make sure to update the .env file as well)
  159. - DATABASE_URL=postgresql://postgres:testpass@hoppscotch-db:5432/hoppscotch?connect_timeout=300
  160. - PORT=3000
  161. volumes:
  162. # Uncomment the line below when modifying code. Only applicable when using the "dev" target.
  163. # - ./packages/hoppscotch-backend/:/usr/src/app
  164. - /usr/src/app/node_modules/
  165. depends_on:
  166. hoppscotch-db:
  167. condition: service_healthy
  168. ports:
  169. - "3170:3000"
  170. hoppscotch-old-app:
  171. profiles: ["deprecated"]
  172. container_name: hoppscotch-old-app
  173. build:
  174. dockerfile: packages/hoppscotch-selfhost-web/Dockerfile
  175. context: .
  176. env_file:
  177. - ./.env
  178. depends_on:
  179. - hoppscotch-old-backend
  180. ports:
  181. - "3000:8080"
  182. hoppscotch-old-sh-admin:
  183. profiles: ["deprecated"]
  184. container_name: hoppscotch-old-sh-admin
  185. build:
  186. dockerfile: packages/hoppscotch-sh-admin/Dockerfile
  187. context: .
  188. env_file:
  189. - ./.env
  190. depends_on:
  191. - hoppscotch-old-backend
  192. ports:
  193. - "3100:8080"
  194. # DEPLOYMENT SCENARIOS:
  195. # 1. Default deployment (recommended):
  196. # docker compose --profile default up
  197. # This will start: AIO + database + auto-migration
  198. #
  199. # 2. Default deployment without database:
  200. # docker compose --profile default-no-db up
  201. # This will start: AIO only (use when you have an external database)
  202. #
  203. # 3. Individual service deployment:
  204. # docker compose --profile backend up # Just the backend
  205. # docker compose --profile app up # Just the app and webapp server
  206. # docker compose --profile admin up # Just the admin dashboard
  207. # docker compose --profile database up # Just the database
  208. #
  209. # 4. Development deployment:
  210. # docker compose --profile just-backend up # All services except webapp
  211. #
  212. # 5. Deprecated services:
  213. # docker compose --profile deprecated up
  214. # This will start all deprecated services (not recommended for new deployments)
  215. #
  216. # Remember: The default and default-no-db profiles should not be mixed with individual service
  217. # profiles as they would conflict on ports.