From cdb01b26ceaecb049d923059214c0d315cb27706 Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Tue, 20 Jun 2023 11:47:20 -0400 Subject: [PATCH 1/5] Build custom image for client dev server --- client/.dockerignore | 2 ++ client/Dockerfile | 10 ++++++++++ docker-compose_dev.yml | 6 ++---- 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 client/.dockerignore create mode 100644 client/Dockerfile diff --git a/client/.dockerignore b/client/.dockerignore new file mode 100644 index 0000000..04c01ba --- /dev/null +++ b/client/.dockerignore @@ -0,0 +1,2 @@ +node_modules/ +dist/ \ No newline at end of file diff --git a/client/Dockerfile b/client/Dockerfile new file mode 100644 index 0000000..1a44d67 --- /dev/null +++ b/client/Dockerfile @@ -0,0 +1,10 @@ +FROM node +# user node has UID 1000 in the container +USER node +EXPOSE 5173 +VOLUME /client +WORKDIR /client +ADD package.json yarn.lock tsconfig.json tsconfig.node.json vite.config.ts /client/ +RUN yarn +ADD public/ src/ index.html /client/ + diff --git a/docker-compose_dev.yml b/docker-compose_dev.yml index 780b9be..93d4bf1 100644 --- a/docker-compose_dev.yml +++ b/docker-compose_dev.yml @@ -37,11 +37,9 @@ services: - ./db.mount:/var/lib/postgresql/data client_devserver: - image: node + build: ./client volumes: [ ./client:/client/ ] - working_dir: /client - command: [ "sh", "-c", "yarn && yarn dev --host 0.0.0.0" ] - expose: [ 5173 ] + command: "yarn dev --host 0.0.0.0" networks: [ web ] labels: traefik.enable: true -- 2.43.5 From 7d4dcf15c159e0102ebd8a0ed5a125b73c0aab03 Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Tue, 20 Jun 2023 11:48:02 -0400 Subject: [PATCH 2/5] Remove a bit of cruft --- client/src/state.ts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/client/src/state.ts b/client/src/state.ts index e0ad4ad..d9c00e7 100644 --- a/client/src/state.ts +++ b/client/src/state.ts @@ -18,12 +18,6 @@ export const state = reactive({ source.addEventListener('TickAdded', event => { console.log(event) const tick: Tick = JSON.parse(event.data) - // for (const track of this.tracks) { - // if (track.id === tick.track_id) { - // console.debug('pushing tick') - // track.ticks?.push(tick) - // } - // } const tracks = this.tracks.map(track => { if (track.id === tick.track_id) { const ticks = track.ticks ?? [] @@ -33,22 +27,17 @@ export const state = reactive({ } return track }) - console.debug(tracks) this.tracks = tracks }) source.addEventListener('TickDropped', event => { console.log(event) const tick: Tick = JSON.parse(event.data) - // for (const track of this.tracks) - // if (track.id === tick.track_id) - // track.ticks = track.ticks?.filter($tick => $tick.id === tick.id) const tracks = this.tracks.map(track => { if (track.id === tick.track_id) { track.ticks = track.ticks?.filter($tick => $tick.id !== tick.id) } return track }) - console.debug(tracks) this.tracks = tracks }) source.addEventListener('Lagged', event => { -- 2.43.5 From 9c255b5f6834b8a5fa925f14aa164eb1e07303b8 Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Wed, 21 Jun 2023 06:23:36 -0400 Subject: [PATCH 3/5] Cleanly disconnect from the update stream if possible --- client/src/state.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/state.ts b/client/src/state.ts index d9c00e7..cc140cd 100644 --- a/client/src/state.ts +++ b/client/src/state.ts @@ -49,6 +49,7 @@ export const state = reactive({ error(event) window.location = window.location }) + window.addEventListener('beforeunload', () => source.close()) }, async repopulate() { this.state = State.Fetching -- 2.43.5 From afacdaa3dd07817b45014ba4d2c9d39513245baa Mon Sep 17 00:00:00 2001 From: "D. Scott Boggs" Date: Wed, 21 Jun 2023 06:26:52 -0400 Subject: [PATCH 4/5] Move state initialization from App.vue to main.ts --- client/src/App.vue | 3 --- client/src/main.ts | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/src/App.vue b/client/src/App.vue index b7adb44..a7b1c04 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -1,8 +1,5 @@