mirror of
https://github.com/ckaczor/HomeMonitor.git
synced 2026-01-13 17:22:54 -05:00
Try setting config for dual deployment
This commit is contained in:
@@ -13,4 +13,7 @@ COPY nginx/default.conf /etc/nginx/conf.d/
|
|||||||
RUN rm -rf /usr/share/nginx/html/*
|
RUN rm -rf /usr/share/nginx/html/*
|
||||||
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
COPY --from=build-stage /app/dist /usr/share/nginx/html
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
COPY ./entrypoint.sh ./entrypoint.sh
|
||||||
|
RUN chmod +x ./entrypoint.sh
|
||||||
|
ENTRYPOINT ["./entrypoint.sh"]
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
@@ -43,6 +43,15 @@ stages:
|
|||||||
PathtoPublish: 'WebDisplay/deploy/manifest.yaml'
|
PathtoPublish: 'WebDisplay/deploy/manifest.yaml'
|
||||||
ArtifactName: 'Manifest'
|
ArtifactName: 'Manifest'
|
||||||
publishLocation: 'Container'
|
publishLocation: 'Container'
|
||||||
|
- task: Bash@3
|
||||||
|
inputs:
|
||||||
|
targetType: 'inline'
|
||||||
|
script: 'sed -i s/#BUILD_BUILDNUMBER#/$BUILD_BUILDNUMBER/ WebDisplay/deploy/manifest-internal.yaml'
|
||||||
|
- task: PublishBuildArtifacts@1
|
||||||
|
inputs:
|
||||||
|
PathtoPublish: 'WebDisplay/deploy/manifest-internal.yaml'
|
||||||
|
ArtifactName: 'Manifest-Internal'
|
||||||
|
publishLocation: 'Container'
|
||||||
|
|
||||||
- stage: Deploy
|
- stage: Deploy
|
||||||
jobs:
|
jobs:
|
||||||
@@ -66,3 +75,23 @@ stages:
|
|||||||
configuration: '$(System.ArtifactsDirectory)/Manifest/manifest.yaml'
|
configuration: '$(System.ArtifactsDirectory)/Manifest/manifest.yaml'
|
||||||
secretType: 'dockerRegistry'
|
secretType: 'dockerRegistry'
|
||||||
containerRegistryType: 'Container Registry'
|
containerRegistryType: 'Container Registry'
|
||||||
|
- job: Deploy Internal
|
||||||
|
pool:
|
||||||
|
vmImage: 'ubuntu-latest'
|
||||||
|
steps:
|
||||||
|
- task: DownloadBuildArtifacts@0
|
||||||
|
inputs:
|
||||||
|
artifactName: 'Manifest-Internal'
|
||||||
|
buildType: 'current'
|
||||||
|
downloadType: 'single'
|
||||||
|
downloadPath: '$(System.ArtifactsDirectory)'
|
||||||
|
- task: Kubernetes@1
|
||||||
|
inputs:
|
||||||
|
connectionType: 'Kubernetes Service Connection'
|
||||||
|
kubernetesServiceEndpoint: 'Kubernetes'
|
||||||
|
namespace: 'home-monitor'
|
||||||
|
command: 'apply'
|
||||||
|
useConfigurationFile: true
|
||||||
|
configuration: '$(System.ArtifactsDirectory)/Manifest/manifest-internal.yaml'
|
||||||
|
secretType: 'dockerRegistry'
|
||||||
|
containerRegistryType: 'Container Registry'
|
||||||
|
|||||||
100
WebDisplay/deploy/manifest-internal.yaml
Normal file
100
WebDisplay/deploy/manifest-internal.yaml
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
---
|
||||||
|
kind: Deployment
|
||||||
|
apiVersion: apps/v1
|
||||||
|
metadata:
|
||||||
|
name: display-internal
|
||||||
|
namespace: home-monitor
|
||||||
|
labels:
|
||||||
|
app: display-internal
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: display-internal
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: display-internal
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: display-internal
|
||||||
|
image: ckaczor/home-monitor-web-display:15
|
||||||
|
terminationMessagePath: "/dev/termination-log"
|
||||||
|
terminationMessagePolicy: File
|
||||||
|
imagePullPolicy: Always
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
env:
|
||||||
|
- name: API_PREFIX
|
||||||
|
value: http://172.23.10.3
|
||||||
|
- name: HOME_ASSISTANT_URL
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: display-internal-config
|
||||||
|
key: HOME_ASSISTANT_URL
|
||||||
|
- name: HOME_ASSISTANT_TOKEN
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: display-internal-config
|
||||||
|
key: HOME_ASSISTANT_TOKEN
|
||||||
|
- name: GARAGE_DEVICE
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: display-internal-config
|
||||||
|
key: GARAGE_DEVICE
|
||||||
|
- name: ALARM_DEVICE
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: display-internal-config
|
||||||
|
key: ALARM_DEVICE
|
||||||
|
restartPolicy: Always
|
||||||
|
terminationGracePeriodSeconds: 30
|
||||||
|
dnsPolicy: ClusterFirst
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: kubernetes
|
||||||
|
schedulerName: default-scheduler
|
||||||
|
---
|
||||||
|
kind: Service
|
||||||
|
apiVersion: v1
|
||||||
|
metadata:
|
||||||
|
name: display-internal
|
||||||
|
spec:
|
||||||
|
ports:
|
||||||
|
- name: client
|
||||||
|
port: 9001
|
||||||
|
targetPort: 80
|
||||||
|
selector:
|
||||||
|
app: display-internal
|
||||||
|
type: ClusterIP
|
||||||
|
---
|
||||||
|
apiVersion: traefik.containo.us/v1alpha1
|
||||||
|
kind: IngressRoute
|
||||||
|
metadata:
|
||||||
|
annotations:
|
||||||
|
kubernetes.io/ingress.class: traefik
|
||||||
|
creationTimestamp: null
|
||||||
|
name: display-internal
|
||||||
|
namespace: home-monitor
|
||||||
|
spec:
|
||||||
|
entryPoints:
|
||||||
|
- display
|
||||||
|
routes:
|
||||||
|
- kind: Rule
|
||||||
|
match: PathPrefix(`/`)
|
||||||
|
priority: 101
|
||||||
|
services:
|
||||||
|
- kind: Service
|
||||||
|
name: display-internal
|
||||||
|
namespace: home-monitor
|
||||||
|
port: 9001
|
||||||
|
---
|
||||||
|
apiVersion: traefik.containo.us/v1alpha1
|
||||||
|
kind: Middleware
|
||||||
|
metadata:
|
||||||
|
creationTimestamp: null
|
||||||
|
name: display-internal
|
||||||
|
namespace: home-monitor
|
||||||
|
spec:
|
||||||
|
stripPrefix:
|
||||||
|
prefixes:
|
||||||
|
- /
|
||||||
@@ -24,6 +24,17 @@ spec:
|
|||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
securityContext:
|
securityContext:
|
||||||
privileged: true
|
privileged: true
|
||||||
|
env:
|
||||||
|
- name: API_PREFIX
|
||||||
|
value:
|
||||||
|
- name: HOME_ASSISTANT_URL
|
||||||
|
value:
|
||||||
|
- name: HOME_ASSISTANT_TOKEN
|
||||||
|
value:
|
||||||
|
- name: GARAGE_DEVICE
|
||||||
|
value:
|
||||||
|
- name: ALARM_DEVICE
|
||||||
|
value:
|
||||||
restartPolicy: Always
|
restartPolicy: Always
|
||||||
terminationGracePeriodSeconds: 30
|
terminationGracePeriodSeconds: 30
|
||||||
dnsPolicy: ClusterFirst
|
dnsPolicy: ClusterFirst
|
||||||
|
|||||||
7
WebDisplay/nginx/entrypoint.sh
Normal file
7
WebDisplay/nginx/entrypoint.sh
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
sed -i -e "s~%API_PREFIX%~$API_PREFIX~g" /usr/share/nginx/html/assets/*
|
||||||
|
sed -i -e "s~%HOME_ASSISTANT_URL%~$HOME_ASSISTANT_URL~g" sed -i -e "s~%API_PREFIX%~$API_PREFIX~g" /usr/share/nginx/html/assets/*
|
||||||
|
sed -i -e "s~%HOME_ASSISTANT_TOKEN%~$HOME_ASSISTANT_TOKEN~g" sed -i -e "s~%API_PREFIX%~$API_PREFIX~g" /usr/share/nginx/html/assets/*
|
||||||
|
sed -i -e "s~%GARAGE_DEVICE%~$GARAGE_DEVICE~g" sed -i -e "s~%API_PREFIX%~$API_PREFIX~g" /usr/share/nginx/html/assets/*
|
||||||
|
sed -i -e "s~%ALARM_DEVICE%~$ALARM_DEVICE~g" sed -i -e "s~%API_PREFIX%~$API_PREFIX~g" /usr/share/nginx/html/assets/*
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"API_PREFIX": "",
|
|
||||||
"HOME_ASSISTANT_TOKEN": "",
|
|
||||||
"HOME_ASSISTANT_URL": "",
|
|
||||||
"GARAGE_DEVICE": "",
|
|
||||||
"ALARM_DEVICE": ""
|
|
||||||
}
|
|
||||||
@@ -1,23 +1,21 @@
|
|||||||
import config from './config.json';
|
|
||||||
|
|
||||||
export default class Environment {
|
export default class Environment {
|
||||||
public static getUrlPrefix(): string {
|
public static getUrlPrefix(): string {
|
||||||
return config.API_PREFIX;
|
return '%API_PREFIX%';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getHomeAssistantUrl(): string {
|
public static getHomeAssistantUrl(): string {
|
||||||
return config.HOME_ASSISTANT_URL;
|
return '%HOME_ASSISTANT_URL%';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getHomeAssistantToken(): string {
|
public static getHomeAssistantToken(): string {
|
||||||
return config.HOME_ASSISTANT_TOKEN;
|
return '%HOME_ASSISTANT_TOKEN%';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getGarageDevice(): string {
|
public static getGarageDevice(): string {
|
||||||
return config.GARAGE_DEVICE;
|
return '%GARAGE_DEVICE%';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getAlarmDevice(): string {
|
public static getAlarmDevice(): string {
|
||||||
return config.ALARM_DEVICE;
|
return '%ALARM_DEVICE%';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user