Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

feat(infra): make webapp server part of fe container (#4843)

Shreyas390fc40ee08e
diff --git a/docker-compose.yml b/docker-compose.yml
index 65bdced24..8b15f1266 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -10,9 +10,8 @@
# - default: All-in-one service + database + auto-migration (recommended for most users)
# - default-no-db: All-in-one service without database (for users with external DB)
# - backend: The backend service only
-# - app: The main Hoppscotch application only
+# - app: The main Hoppscotch application and the webapp server
# - admin: The self-host admin dashboard only
-# - webapp: The static web app server only
# - database: Just the PostgreSQL database
# - just-backend: All services except webapp for local development
# - deprecated: All deprecated services (not recommended)
@@ -55,7 +54,8 @@ services:
- "3180:80"
- "3170:3170"
- # The main hoppscotch app. This will be hosted at port 3000
+ # The main hoppscotch app with integrated webapp server. This will be hosted at port 3000
+ # The webapp server will be accessible at port 3200
# NOTE: To do TLS or play around with how the app is hosted, you can look into the Caddyfile for
# the SH admin dashboard server at packages/hoppscotch-selfhost-web/Caddyfile
hoppscotch-app:
@@ -72,6 +72,7 @@ services:
ports:
- "3080:80"
- "3000:3000"
+ - "3200:3200"
# The Self Host dashboard for managing the app. This will be hosted at port 3100
# NOTE: To do TLS or play around with how the app is hosted, you can look into the Caddyfile for
@@ -91,19 +92,6 @@ services:
- "3280:80"
- "3100:3100"
- # The static server for serving web content to desktop shell, hosted at port 3200
- hoppscotch-webapp-server:
- profiles: ["webapp"]
- container_name: hoppscotch-webapp-server
- env_file:
- - ./.env
- build:
- dockerfile: prod.Dockerfile
- context: .
- target: webapp_server
- ports:
- - "3200:3200"
-
# The service that spins up all services at once in one container
hoppscotch-aio:
profiles: ["default", "default-no-db"]
@@ -227,9 +215,8 @@ services:
#
# 3. Individual service deployment:
# docker compose --profile backend up # Just the backend
-# docker compose --profile app up # Just the app
+# docker compose --profile app up # Just the app and webapp server
# docker compose --profile admin up # Just the admin dashboard
-# docker compose --profile webapp up # Just the static web server
# docker compose --profile database up # Just the database
#
# 4. Development deployment:
diff --git a/prod.Dockerfile b/prod.Dockerfile
index 49f9563f2..a92ec1aa0 100644
--- a/prod.Dockerfile
+++ b/prod.Dockerfile
@@ -114,6 +114,9 @@ RUN sh -c "curl -qL https://www.npmjs.com/install.sh | env npm_install=10.9.2 sh
# Install caddy
COPY --from=caddy_builder /tmp/caddy-build/cmd/caddy/caddy /usr/bin/caddy
+# Copy over webapp server bin
+COPY --from=webapp_server_builder /usr/src/app/packages/hoppscotch-selfhost-web/webapp-server/target/release/webapp-server /usr/local/bin/
+
COPY --from=fe_builder /usr/src/app/packages/hoppscotch-selfhost-web/prod_run.mjs /site/prod_run.mjs
COPY --from=fe_builder /usr/src/app/packages/hoppscotch-selfhost-web/selfhost-web.Caddyfile /etc/caddy/selfhost-web.Caddyfile
COPY --from=fe_builder /usr/src/app/packages/hoppscotch-selfhost-web/dist/ /site/selfhost-web
@@ -123,10 +126,12 @@ RUN npm install -g @import-meta-env/cli
EXPOSE 80
EXPOSE 3000
+EXPOSE 3200
WORKDIR /site
-CMD ["/bin/sh", "-c", "node /site/prod_run.mjs && caddy run --config /etc/caddy/selfhost-web.Caddyfile --adapter caddyfile"]
+# Run both webapp-server and Caddy after env processing (NOTE: env processing is required by both)
+CMD ["/bin/sh", "-c", "node /site/prod_run.mjs && (webapp-server & caddy run --config /etc/caddy/selfhost-web.Caddyfile --adapter caddyfile)"]
@@ -168,17 +173,6 @@ WORKDIR /site
CMD ["node","/site/prod_run.mjs"]
-FROM node:20-alpine AS webapp_server
-COPY --from=webapp_server_builder /usr/src/app/packages/hoppscotch-selfhost-web/webapp-server/target/release/webapp-server /usr/local/bin/
-RUN mkdir -p /site/selfhost-web
-COPY --from=fe_builder /usr/src/app/packages/hoppscotch-selfhost-web/dist /site/selfhost-web
-COPY --from=fe_builder /usr/src/app/packages/hoppscotch-selfhost-web/prod_run.mjs /site/prod_run.mjs
-RUN apk add nodejs npm
-RUN npm install -g @import-meta-env/cli
-WORKDIR /site
-CMD ["/bin/sh", "-c", "node /site/prod_run.mjs && webapp-server"]
-EXPOSE 3200
-
FROM alpine:3.19.7 AS aio
RUN apk add nodejs curl