add vite hmr to traefik reverse proxy

This commit is contained in:
Gregor Vostrak
2024-03-21 13:51:28 +01:00
parent fc5b35661d
commit e5922cdb0a
3 changed files with 19 additions and 3 deletions

View File

@@ -38,6 +38,7 @@ Add the following entry to your `/etc/hosts`
``` ```
127.0.0.1 solidtime.test 127.0.0.1 solidtime.test
127.0.0.1 playwright.solidtime.test 127.0.0.1 playwright.solidtime.test
127.0.0.1 vite.solidtime.test
127.0.0.1 mail.solidtime.test 127.0.0.1 mail.solidtime.test
``` ```
@@ -57,6 +58,7 @@ npx playwright codegen solidtime.test
## E2E Troubleshooting ## E2E Troubleshooting
If E2E tests are not working at all, make sure you do not have the Vite server running and just run `npm run build` to update the version.
If the E2E tests are not working consistently and fail with a timeout during the authentication, you might want to delete the `test-results/.auth` directory to force new test accounts to be created. If the E2E tests are not working consistently and fail with a timeout during the authentication, you might want to delete the `test-results/.auth` directory to force new test accounts to be created.
## Generate ZOD Client ## Generate ZOD Client

View File

@@ -12,19 +12,25 @@ services:
- "traefik.http.routers.solidtime.rule=Host(`${NGINX_HOST_NAME}`)" - "traefik.http.routers.solidtime.rule=Host(`${NGINX_HOST_NAME}`)"
- "traefik.http.routers.solidtime.entrypoints=web" - "traefik.http.routers.solidtime.entrypoints=web"
- "traefik.http.services.solidtime.loadbalancer.server.port=80" - "traefik.http.services.solidtime.loadbalancer.server.port=80"
- "traefik.http.routers.solidtime.service=solidtime"
- "traefik.http.routers.solidtime-https.rule=Host(`${NGINX_HOST_NAME}`)" - "traefik.http.routers.solidtime-https.rule=Host(`${NGINX_HOST_NAME}`)"
- "traefik.http.routers.solidtime-https.entrypoints=websecure" - "traefik.http.routers.solidtime-https.entrypoints=websecure"
- "traefik.http.routers.solidtime-https.tls=true" - "traefik.http.routers.solidtime-https.tls=true"
# vite
- "traefik.http.services.solidtime-vite.loadbalancer.server.port=5173"
# http
- "traefik.http.routers.solidtime-vite.rule=Host(`${VITE_HOST_NAME}`)"
- "traefik.http.routers.solidtime-vite.service=solidtime-vite"
- "traefik.http.routers.solidtime-vite.entrypoints=web"
extra_hosts: extra_hosts:
- 'host.docker.internal:host-gateway' - 'host.docker.internal:host-gateway'
ports:
- '${VITE_PORT:-5173}:${VITE_PORT:-5173}'
environment: environment:
WWWUSER: '${WWWUSER}' WWWUSER: '${WWWUSER}'
LARAVEL_SAIL: 1 LARAVEL_SAIL: 1
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}' XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}' XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
IGNITION_LOCAL_SITES_PATH: '${PWD}' IGNITION_LOCAL_SITES_PATH: '${PWD}'
VITE_HOST_NAME: '${VITE_HOST_NAME}'
volumes: volumes:
- '.:/var/www/html' - '.:/var/www/html'
networks: networks:
@@ -99,7 +105,8 @@ services:
command: ['npx', 'playwright', 'test', '--ui-port=8080', '--ui-host=0.0.0.0'] command: ['npx', 'playwright', 'test', '--ui-port=8080', '--ui-host=0.0.0.0']
working_dir: /src working_dir: /src
extra_hosts: extra_hosts:
- "solidtime.test:${REVERSE_PROXY_IP:-10.100.100.10}" - "${NGINX_HOST_NAME}:${REVERSE_PROXY_IP:-10.100.100.10}"
- "${VITE_HOST_NAME}:${REVERSE_PROXY_IP:-10.100.100.10}"
labels: labels:
- "traefik.enable=true" - "traefik.enable=true"
- "traefik.docker.network=${NETWORK_NAME}" - "traefik.docker.network=${NETWORK_NAME}"

View File

@@ -24,4 +24,11 @@ export default defineConfig({
lintCommand: 'eslint "./**/*.{ts,vue}"', lintCommand: 'eslint "./**/*.{ts,vue}"',
}), }),
], ],
server: {
host: true,
hmr: {
host: process.env.VITE_HOST_NAME,
clientPort: 80,
},
},
}); });