mirror of
https://github.com/KevinMidboe/infra-map.git
synced 2025-10-29 17:40:28 +00:00
cleanup console & landing page
This commit is contained in:
@@ -91,12 +91,15 @@ steps:
|
|||||||
settings:
|
settings:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
repo: ghcr.io/kevinmidboe/varnish-infra-map
|
repo: ghcr.io/kevinmidboe/varnish-infra-map
|
||||||
dockerfile: varnish/Dockerfile
|
contexT: varnish
|
||||||
|
dockerfile: Dockerfile
|
||||||
compress: true
|
compress: true
|
||||||
username:
|
username:
|
||||||
from_secret: GITHUB_USERNAME
|
from_secret: GITHUB_USERNAME
|
||||||
password:
|
password:
|
||||||
from_secret: GHCR_UPLOAD_TOKEN
|
from_secret: GHCR_UPLOAD_TOKEN
|
||||||
|
build_args_from_env:
|
||||||
|
-
|
||||||
tags:
|
tags:
|
||||||
- latest
|
- latest
|
||||||
- ${DRONE_COMMIT_SHA}
|
- ${DRONE_COMMIT_SHA}
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
|
DATABASE_URL=
|
||||||
|
TRAEFIK_URL=
|
||||||
|
HTTP_HEALTH_ENDPOINTS=
|
||||||
PROXMOX_URL=
|
PROXMOX_URL=
|
||||||
PROXMOX_TOKEN=
|
PROXMOX_TOKEN=
|
||||||
HOMEASSISTANT_URL=
|
HOMEASSISTANT_URL=
|
||||||
HOMEASSISTANT_TOKEN=
|
HOMEASSISTANT_TOKEN=
|
||||||
TRAEFIK_URL=
|
KUBERNETES_SERVICE_HOST=
|
||||||
|
KUBERNETES_SA_TOKEN=
|
||||||
|
KUBERNETES_CA_CERT_PATH=
|
||||||
|
|
||||||
|
|||||||
@@ -16,5 +16,6 @@ COPY --from=builder /app/build build
|
|||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
|
ENV PORT=3000
|
||||||
|
|
||||||
CMD [ "node", "build/index.js" ]
|
CMD [ "node", "build/index.js" ]
|
||||||
|
|||||||
46
README.md
46
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:
|
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run dev
|
yarn dev
|
||||||
|
|
||||||
# or start the server and open the app in a new browser tab
|
|
||||||
npm run dev -- --open
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
To create a production version of your app:
|
To create a production version to be run from node:
|
||||||
|
|
||||||
```bash
|
```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
|
||||||
|
```
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ services:
|
|||||||
context: varnish
|
context: varnish
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
args:
|
args:
|
||||||
HASS_HOST: 10.0.0.82
|
# sets build variables. Overridden by env, but has sane defaults
|
||||||
FRONTEND_HOST: app
|
IMAGE_HOST: ${IMAGE_HOST:-homeassistant.local}
|
||||||
|
PROXY_HOST: ${PROXY_HOST:-app}
|
||||||
ports:
|
ports:
|
||||||
- '6081:6081'
|
- '6081:6081'
|
||||||
depends_on:
|
depends_on:
|
||||||
@@ -17,8 +18,9 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
env_file: '.env'
|
env_file: .env # sets container's environment
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=production
|
||||||
- PORT=3000
|
- PROTOCOL_HEADER=x-forwarded-proto
|
||||||
- ORIGIN=http://localhost:3000
|
- HOST_HEADER=x-forwarded-host
|
||||||
|
- PORT_HEADER=x-forwarded-port
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
import User from '$lib/icons/user.svelte';
|
|
||||||
import { derived } from 'svelte/store';
|
import { derived } from 'svelte/store';
|
||||||
|
|
||||||
// Create a derived store to extract breadcrumb data
|
// Create a derived store to extract breadcrumb data
|
||||||
@@ -9,14 +8,6 @@
|
|||||||
|
|
||||||
return segments.map((segment, index) => {
|
return segments.map((segment, index) => {
|
||||||
let label = decodeURI(segment);
|
let label = decodeURI(segment);
|
||||||
|
|
||||||
// if not uuid pattern, this is weird order of ops
|
|
||||||
/*
|
|
||||||
if (!segment.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/)) {
|
|
||||||
label = label.replace(/-/g, ' ')
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
label,
|
label,
|
||||||
path: '/' + segments.slice(0, index + 1).join('/')
|
path: '/' + segments.slice(0, index + 1).join('/')
|
||||||
@@ -40,10 +31,6 @@
|
|||||||
<a href={crumb.path}>{crumb.label}</a>
|
<a href={crumb.path}>{crumb.label}</a>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="right">
|
|
||||||
<User />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|||||||
@@ -23,15 +23,13 @@ RUN git clone https://github.com/varnish/libvmod-digest.git /opt/libvmod-digest
|
|||||||
|
|
||||||
COPY --from=hairyhenderson/gomplate:stable /gomplate /bin/gomplate
|
COPY --from=hairyhenderson/gomplate:stable /gomplate /bin/gomplate
|
||||||
|
|
||||||
ARG HASS_HOST
|
|
||||||
ARG FRONTEND_HOST
|
|
||||||
ENV HASS_HOST=$HASS_HOST
|
|
||||||
ENV FRONTEND_HOST=$FRONTEND_HOST
|
|
||||||
|
|
||||||
COPY default.vcl.tmpl /etc/varnish/
|
COPY default.vcl.tmpl /etc/varnish/
|
||||||
COPY *.vcl /etc/varnish/
|
COPY *.vcl /etc/varnish/
|
||||||
COPY includes /etc/varnish/includes
|
COPY includes /etc/varnish/includes
|
||||||
|
|
||||||
|
ARG PROXY_HOST=$PROXY_HOST
|
||||||
|
ARG IMAGE_HOST=$IMAGE_HOST
|
||||||
|
|
||||||
RUN gomplate -f /etc/varnish/default.vcl.tmpl -o /etc/varnish/default.vcl
|
RUN gomplate -f /etc/varnish/default.vcl.tmpl -o /etc/varnish/default.vcl
|
||||||
RUN rm /etc/varnish/default.vcl.tmpl
|
RUN rm /etc/varnish/default.vcl.tmpl
|
||||||
|
|
||||||
|
|||||||
@@ -2,18 +2,19 @@ vcl 4.0;
|
|||||||
|
|
||||||
import std;
|
import std;
|
||||||
import digest;
|
import digest;
|
||||||
|
import directors;
|
||||||
|
|
||||||
include "includes/x-cache-header.vcl";
|
include "includes/x-cache-header.vcl";
|
||||||
include "vcl_deliver.vcl";
|
include "vcl_deliver.vcl";
|
||||||
|
|
||||||
# Define backend pointing to Home Assistant IP
|
# Define backend pointing to Home Assistant IP
|
||||||
backend hass_backend {
|
backend hass_backend {
|
||||||
.host = "{{ getenv `HASS_HOST` `homeassistant.local` }}";
|
.host = "{{ getenv `IMAGE_HOST` `homeassistant.local` }}";
|
||||||
.port = "8123";
|
.port = "8123";
|
||||||
}
|
}
|
||||||
|
|
||||||
backend app_frontend {
|
backend app_frontend {
|
||||||
.host = "{{ getenv `FRONTEND_HOST` `localhost` }}";
|
.host = "{{ getenv `PROXY_HOST` `localhost` }}";
|
||||||
.port = "3000";
|
.port = "3000";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,6 +46,17 @@ sub vcl_recv {
|
|||||||
unset req.http.Cookie;
|
unset req.http.Cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Svelte-kit needs to distinguish between it's own files and the Host header.
|
||||||
|
// The X-Forwarded-* headers below are to tell svelte-kit where it's local files are,
|
||||||
|
// and the Host header is included in the returned html & js referencing the external
|
||||||
|
// domain or proxy requested by client.
|
||||||
|
// https://svelte.dev/docs/kit/adapter-node#Environment-variables-ORIGIN-PROTOCOL_HEADER-HOST_HEADER-and-PORT_HEADER
|
||||||
|
sub vcl_backend_fetch {
|
||||||
|
set bereq.http.X-Forwarded-Host = "localhost";
|
||||||
|
set bereq.http.X-Forwarded-Port = "3000";
|
||||||
|
set bereq.http.X-Forwarded-Proto = "http";
|
||||||
|
}
|
||||||
|
|
||||||
sub vcl_synth {
|
sub vcl_synth {
|
||||||
if (resp.status == 204) {
|
if (resp.status == 204) {
|
||||||
set resp.http.Access-Control-Allow-Origin = "*";
|
set resp.http.Access-Control-Allow-Origin = "*";
|
||||||
|
|||||||
Reference in New Issue
Block a user