Skip to content
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
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ jobs:
id-token: write

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Docker Build and Push
uses: cartoway/docker-compose-build-push-action@main
with:
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ build/
/docker/osrm/landuses
/docker/osrm/profiles
/docker/otp/data
/docker/access.rb
/docker/production.rb

## Environment normalisation:
Expand Down Expand Up @@ -52,3 +53,8 @@ local.env

# Redis
*.aof

## Submodules build
public/assets/
public/*.svg
public/route.html
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "router-demo"]
path = router-demo
url = https://github.com/cartoway/router-demo.git
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,40 @@ docker compose -f docker-compose-tools.yml down redis-build
```
docker compose run --rm gh-car-iceland gh-build.sh
```

## Local router-demo submodule

To work on with the router-demo locally, you must load the front-end submodule `router-demo` (web interface).

### 1. Initialize the submodule

Before using Docker or building, run:

```bash
git submodule update --init --recursive
```

### 2. Build the docker image

You can use the following script to automate everything:

```bash
docker-compose up --build
```

The build of the `router-demo` submodule is automatically handled by the `router-demo-build` service in `docker-compose.yml`. The generated files are copied into the `public/` folder and served by the API.

### 4. Access the web interface

After launching, access the front-end at:
- [http://localhost:8082/route.html](http://localhost:8082/route.html)

JS/CSS assets are served automatically.

### 5. Update the submodule

To update the front-end:

```bash
git submodule update --remote --merge
```
18 changes: 18 additions & 0 deletions config/router-demo.vite.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/vite.config.ts b/vite.config.ts
index 0cc309f..a2d3e55 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -28,4 +28,13 @@ export default defineConfig({
host: '0.0.0.0',
port: 5173,
},
+ build: {
+ rollupOptions: {
+ output: {
+ entryFileNames: 'assets/route-[hash].js',
+ chunkFileNames: 'assets/route-[hash].js',
+ assetFileNames: 'assets/route-[hash][extname]'
+ }
+ }
+ }
});
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ services:
- "8082:80" # HOST:CONTAINER, edit only HOST part
volumes:
- .:/srv/app
- ./router-demo/dist:/srv/app/public
- ./docker/access.rb:/srv/app/config/access.rb
- ./docker/production.rb:/srv/app/config/environments/production.rb
- ./docker/production.rb:/srv/app/config/environments/development.rb
- ./docker/poly:/srv/app/poly
depends_on:
- redis-cache
- router-demo-build
environment:
REDIS_HOST: redis-cache
APP_ENV: ${APP_ENV:-development}
Expand All @@ -21,6 +23,21 @@ services:
command: bundle exec puma -v -p 80 --pidfile 'tmp/server.pid'
restart: unless-stopped

router-demo-build:
image: node:20
working_dir: /srv/app/router-demo
volumes:
- .:/srv/app
command: >
sh -c "\
patch vite.config.ts < ../config/router-demo.vite.patch && \
npm install && \
npm run build && \
mv dist/index.html dist/route.html && \
cp -r dist/* ../public/ && \
patch -R vite.config.ts < ../config/router-demo.vite.patch\
"

redis-cache:
image: redis:${REDIS_VERSION:-7-alpine}
command: redis-server --save ""
Expand Down
137 changes: 0 additions & 137 deletions public/js/route.js

This file was deleted.

41 changes: 0 additions & 41 deletions public/route.html.erb

This file was deleted.

1 change: 1 addition & 0 deletions router-demo
Submodule router-demo added at 9e0132
Loading