chore: generate multiple builds for sh-admin
Enables seamless transition to/from subpath based access
This commit is contained in:
@@ -61,4 +61,4 @@ VITE_APP_TOS_LINK=https://docs.hoppscotch.io/support/terms
|
||||
VITE_APP_PRIVACY_POLICY_LINK=https://docs.hoppscotch.io/support/privacy
|
||||
|
||||
# Set to `true` for subpath based access
|
||||
VITE_INCLUDE_ADMIN_PREFIX=false
|
||||
ENABLE_SUBPATH_BASED_ACCESS=false
|
||||
|
||||
@@ -1,40 +1,47 @@
|
||||
# TODO: Uncomment the below lines and update the subpath-based implementation to use standard HTTP/HTTPS ports
|
||||
|
||||
# :3000 {
|
||||
# try_files {path} /
|
||||
# root * /site/selfhost-web
|
||||
# file_server
|
||||
# }
|
||||
|
||||
# :3100 {
|
||||
# try_files {path} /
|
||||
# root * /site/sh-admin
|
||||
# file_server
|
||||
# }
|
||||
# TODO: Update the subpath-based implementation to use standard HTTP(S) ports
|
||||
|
||||
:3000 {
|
||||
# Serve the `selfhost-web` SPA by default
|
||||
root * /site/selfhost-web
|
||||
file_server
|
||||
|
||||
# Handle requests under `/admin*`
|
||||
handle_path /admin* {
|
||||
root * /site/sh-admin
|
||||
file_server
|
||||
|
||||
# Ensures any non-existent file in the server is routed to the SPA
|
||||
try_files {path} /
|
||||
}
|
||||
|
||||
# Handle requests under `/backend*` path
|
||||
handle_path /backend* {
|
||||
reverse_proxy localhost:3170
|
||||
}
|
||||
|
||||
# Catch-all route for unknown paths, serves `selfhost-web` SPA
|
||||
handle {
|
||||
root * /site/selfhost-web
|
||||
file_server
|
||||
try_files {path} /
|
||||
}
|
||||
try_files {path} /
|
||||
root * /site/selfhost-web
|
||||
file_server
|
||||
}
|
||||
|
||||
:3100 {
|
||||
try_files {path} /
|
||||
root * /site/sh-admin
|
||||
file_server
|
||||
}
|
||||
|
||||
:8080 {
|
||||
# Serve the `selfhost-web` SPA by default
|
||||
root * /site/selfhost-web
|
||||
file_server
|
||||
|
||||
handle_path /admin* {
|
||||
# Check the ENABLE_SUBPATH_BASED_ACCESS environment variable
|
||||
@enabledSubpathBasedAccess {
|
||||
expression {env.ENABLE_SUBPATH_BASED_ACCESS} == "true"
|
||||
}
|
||||
|
||||
# Conditionally serve /site/sh-admin-subpath-access if ENABLE_SUBPATH_BASED_ACCESS is true
|
||||
handle @enabledSubpathBasedAccess {
|
||||
root * /site/sh-admin-subpath-access
|
||||
file_server
|
||||
|
||||
# Ensures any non-existent file in the server is routed to the SPA
|
||||
try_files {path} /
|
||||
}
|
||||
}
|
||||
|
||||
# Handle requests under `/backend*` path
|
||||
handle_path /backend* {
|
||||
reverse_proxy localhost:3170
|
||||
}
|
||||
|
||||
# Catch-all route for unknown paths, serves `selfhost-web` SPA
|
||||
handle {
|
||||
root * /site/selfhost-web
|
||||
file_server
|
||||
try_files {path} /
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@ services:
|
||||
- "3000:3000"
|
||||
- "3100:3100"
|
||||
- "3170:3170"
|
||||
- "3500:8080"
|
||||
|
||||
# The preset DB service, you can delete/comment the below lines if
|
||||
# you are using an external postgres instance
|
||||
|
||||
@@ -41,7 +41,9 @@ CMD ["/bin/sh", "-c", "node /usr/prod_run.mjs && caddy run --config /etc/caddy/C
|
||||
|
||||
FROM base_builder as sh_admin_builder
|
||||
WORKDIR /usr/src/app/packages/hoppscotch-sh-admin
|
||||
# Generate two builds for `sh-admin`, one based on subpath-access and the regular build
|
||||
RUN pnpm run build
|
||||
RUN pnpm run build --outDir dist-subpath-access --base /admin/
|
||||
|
||||
FROM caddy:2-alpine as sh_admin
|
||||
WORKDIR /site
|
||||
@@ -58,6 +60,7 @@ RUN apk add caddy tini
|
||||
RUN npm install -g @import-meta-env/cli
|
||||
COPY --from=fe_builder /usr/src/app/packages/hoppscotch-selfhost-web/dist /site/selfhost-web
|
||||
COPY --from=sh_admin_builder /usr/src/app/packages/hoppscotch-sh-admin/dist /site/sh-admin
|
||||
COPY --from=sh_admin_builder /usr/src/app/packages/hoppscotch-sh-admin/dist-subpath-access /site/sh-admin-subpath-access
|
||||
COPY aio.Caddyfile /etc/caddy/Caddyfile
|
||||
ENTRYPOINT [ "tini", "--" ]
|
||||
RUN apk --no-cache add curl
|
||||
@@ -67,3 +70,4 @@ CMD ["node", "/usr/src/app/aio_run.mjs"]
|
||||
EXPOSE 3170
|
||||
EXPOSE 3000
|
||||
EXPOSE 3100
|
||||
EXPOSE 3500
|
||||
|
||||
Reference in New Issue
Block a user