diff --git a/.drone.yml b/.drone.yml index 6ffbdb1..bd0d1f0 100644 --- a/.drone.yml +++ b/.drone.yml @@ -91,12 +91,15 @@ steps: settings: registry: ghcr.io repo: ghcr.io/kevinmidboe/varnish-infra-map - dockerfile: varnish/Dockerfile + contexT: varnish + dockerfile: Dockerfile compress: true username: from_secret: GITHUB_USERNAME password: from_secret: GHCR_UPLOAD_TOKEN + build_args_from_env: + - tags: - latest - ${DRONE_COMMIT_SHA} diff --git a/.env.example b/.env.example index e7e736f..b5f902c 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,11 @@ +DATABASE_URL= +TRAEFIK_URL= +HTTP_HEALTH_ENDPOINTS= PROXMOX_URL= PROXMOX_TOKEN= HOMEASSISTANT_URL= HOMEASSISTANT_TOKEN= -TRAEFIK_URL= +KUBERNETES_SERVICE_HOST= +KUBERNETES_SA_TOKEN= +KUBERNETES_CA_CERT_PATH= + diff --git a/Dockerfile b/Dockerfile index 7f697a8..8c4a168 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,5 +16,6 @@ COPY --from=builder /app/build build EXPOSE 3000 ENV NODE_ENV=production +ENV PORT=3000 CMD [ "node", "build/index.js" ] diff --git a/README.md b/README.md index f144204..2436a65 100644 --- a/README.md +++ b/README.md @@ -61,20 +61,50 @@ Follow hass documentation on generating a api token: https://developers.home-ass Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: ```bash -npm run dev - -# or start the server and open the app in a new browser tab -npm run dev -- --open +yarn dev ``` ## Building -To create a production version of your app: +To create a production version to be run from node: ```bash -npm run build +yarn build ``` -You can preview the production build with `npm run preview`. +To preview either use vite to serve or execute node entrypoint: -> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment. +```bash +yarn preview +``` + +or + +```bash +node build/index.js +``` + +## Run using docker + +The application is configure to be used either standalone or behind a webserver. To build the svelte-application docker image run: + +> NB! Remember to configure .env, which is automatically picked up by docker-compose. Set and override for both containers in this file. + +Svelte-kit application: + +```bash +docker build -t infra-map . +``` + +Varnish cache: + +```bash +cd varnish +docker build -t infra-varnish-cache . +``` + +Or both using docker compose: + +```bash +docker compose up +``` diff --git a/docker-compose.yml b/docker-compose.yml index 474549f..3d78c91 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,8 +6,9 @@ services: context: varnish dockerfile: Dockerfile args: - HASS_HOST: 10.0.0.82 - FRONTEND_HOST: app + # sets build variables. Overridden by env, but has sane defaults + IMAGE_HOST: ${IMAGE_HOST:-homeassistant.local} + PROXY_HOST: ${PROXY_HOST:-app} ports: - '6081:6081' depends_on: @@ -17,8 +18,9 @@ services: build: context: . dockerfile: Dockerfile - env_file: '.env' + env_file: .env # sets container's environment environment: - NODE_ENV=production - - PORT=3000 - - ORIGIN=http://localhost:3000 + - PROTOCOL_HEADER=x-forwarded-proto + - HOST_HEADER=x-forwarded-host + - PORT_HEADER=x-forwarded-port diff --git a/src/lib/components/Header.svelte b/src/lib/components/Header.svelte index 2edc0ae..a92d870 100644 --- a/src/lib/components/Header.svelte +++ b/src/lib/components/Header.svelte @@ -1,6 +1,5 @@