Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: conditional base url subpath for flexible deployments #11

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/calm-ligers-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@caravan/coordinator": patch
---

Enable caravan coordinator to be run without the subpath which is primarily just for supporting github pages hosting but causes issues in other environments
4 changes: 2 additions & 2 deletions apps/coordinator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ ENV NODE_OPTIONS=--max-old-space-size=32768

RUN npx turbo run build --filter=coordinator...

# Serve the production build files via nginx (will be served at http://localhost:80/caravan/#
# Serve the production build files via nginx (will be served at http://localhost:80/#
# in docker vm. Map port 80 to a different port on the host machine to access the app)
FROM nginx:1.23 AS runner
WORKDIR /app
COPY --from=installer /app/apps/coordinator/build /usr/share/nginx/html/caravan
COPY --from=installer /app/apps/coordinator/build /usr/share/nginx/html/
6 changes: 3 additions & 3 deletions apps/coordinator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ $ npm run dev
...
```

Now visit http://localhost:5173/caravan/# to interact with your local copy of
Now visit http://localhost:5173/# to interact with your local copy of
Caravan.

### Host Remotely
Expand Down Expand Up @@ -97,10 +97,10 @@ docker build -t caravan:latest -f apps/coordinator/Dockerfile .
To run the built docker image:

```bash
docker run -p 80:8000 caravan:latest
docker run -p 8000:80 caravan:latest
```

Caravan should then be accessible at http://localhost:8000/caravan/#
Caravan should then be accessible at http://localhost:8000/#

## Usage

Expand Down
6 changes: 5 additions & 1 deletion apps/coordinator/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import path from "path";

// https://vitejs.dev/config/
export default defineConfig({
base: "/caravan/#",
// only need to set the base to a subdirectory when deploying to GitHub Pages
// otherwise, if running locally or deploying via alternative like vercel or replit,
// then the sub-path can cause issues
base:
process.env.GH_PAGES || process.env.GITHUB_ACTIONS ? "/caravan/#" : "/#",
resolve: {
alias: {
utils: path.resolve(__dirname, "./src/utils"),
Expand Down
Loading