docker-compose.yml 7.7 KB

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