1
0
Fork 0

Initial commit

This commit is contained in:
Vojtěch Mareš 2023-09-26 21:43:36 +00:00
commit 7724a7614e
24 changed files with 1653 additions and 0 deletions

3
app/.dockerignore Normal file
View file

@ -0,0 +1,3 @@
node_modules
.gitignore
.gitlab-ci.yml

1
app/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
node_modules

34
app/.gitlab-ci.yml Normal file
View file

@ -0,0 +1,34 @@
default:
image: sikalabs/ci
variables:
IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
before_script:
- cd app
stages:
- build
- deploy
docker:build:
stage: build
script:
- echo $CI_REGISTRY_PASSWORD | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin
- docker build -t $IMAGE .
- docker push $IMAGE
deploy:
stage: deploy
environment:
name: live
url: https://sentry-demo.trz.sikademo.com
script:
- helm upgrade --install sentry-demo
./helm
--wait
--set image=$IMAGE
--set host=sentry-demo.trz.sikademo.com
--set dockerRegistry=$CI_REGISTRY
--set dockerRegistryAuth=$DOCKER_REGISTRY_AUTH

17
app/Dockerfile Normal file
View file

@ -0,0 +1,17 @@
FROM node:lts as build
WORKDIR /app
COPY package.json .
COPY package-lock.json .
RUN npm install
COPY . .
FROM node:lts
COPY --from=build /app /app
EXPOSE 3000
CMD ["node", "/app/server.js"]

0
app/README.md Normal file
View file

4
app/helm/Chart.yaml Normal file
View file

@ -0,0 +1,4 @@
apiVersion: v2
name: ad-auth
type: application
version: 0.1.0

View file

@ -0,0 +1 @@
[Public endpoint] NGINX Ingress auth URL: https://{{ .Values.host }}

View file

@ -0,0 +1,44 @@
kind: Deployment
apiVersion: apps/v1
metadata:
name: sentry-demo-app
labels:
app: sentry-demo-app
spec:
replicas: 1
selector:
matchLabels:
app: sentry-demo-app
template:
metadata:
labels:
app: sentry-demo-app
spec:
{{- if and (.Values.dockerRegistry) (.Values.dockerRegistryAuth) }}
imagePullSecrets:
- name: sentry-demo-app-docker
{{ end }}
containers:
- name: sentry-demo-app
image: {{ required "Missing required value: image" .Values.image }}
imagePullPolicy: Always
ports:
- containerPort: 3000
protocol: TCP
livenessProbe:
initialDelaySeconds: 5
timeoutSeconds: 30
tcpSocket:
port: 3000
env:
- name: PORT
value: "3000"
- name: SENTRY_DSN
value: {{ .Vaslues.sentry.dsn }}
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 400m
memory: 1024Mi

View file

@ -0,0 +1,16 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: sentry-demo-app
spec:
rules:
- host: {{ .Values.host }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: sentry-demo-app
port:
number: 3000

View file

@ -0,0 +1,11 @@
{{- if and (.Values.dockerRegistry) (.Values.dockerRegistryAuth) }}
apiVersion: v1
kind: Secret
type: kubernetes.io/dockerconfigjson
metadata:
name: sentry-demo-app-docker
labels:
release: {{ .Release.Name }}
stringData:
.dockerconfigjson: '{"auths": {"{{ .Values.dockerRegistry }}": {"auth": "{{ .Values.dockerRegistryAuth }}"}}}'
{{ end }}

View file

@ -0,0 +1,13 @@
kind: Service
apiVersion: v1
metadata:
name: sentry-demo-app
labels:
app: sentry-demo-app
spec:
ports:
- name: http
port: 3000
targetPort: 3000
selector:
app: sentry-demo-app

6
app/helm/values.yaml Normal file
View file

@ -0,0 +1,6 @@
image:
host:
sentry:
dsn:
dockerRegistry:
dockerRegistryAuth:

1177
app/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

17
app/package.json Normal file
View file

@ -0,0 +1,17 @@
{
"name": "sentry-demo",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"author": "Vojtech Mares <iam@vojtechmares.com>",
"license": "MIT",
"dependencies": {
"@sentry/node": "^6.2.5",
"@sentry/tracing": "^6.2.5",
"express": "^4.17.1"
}
}

38
app/server.js Normal file
View file

@ -0,0 +1,38 @@
const express = require('express')
const sentry = require('@sentry/node')
const tracing = require('@sentry/tracing')
const app = express()
const PORT = process.env.PORT || 3000
const SENTRY_DSN = process.env.SENTRY_DSN
sentry.init({
dsn: SENTRY_DSN,
tracesSampleRate: 1.0,
})
app.get('/hello', (req, res) => {
res.send('World')
})
app.get('/exception', (req, res) => {
try {
throw new Error('Something flew out of a window')
} catch(e) {
sentry.captureException(e)
res.status(500).end()
}
})
app.get('/uncaught-exception', (req, res) => {
throw new Error('Something flew out of a window')
})
app.get('/error-message', (req, res) => {
sentry.captureMessage('Something went wrong')
req.status(500).end()
})
app.listen(PORT, '0.0.0.0', () => {
console.log(`Server listening on http://0.0.0.0:${PORT}`)
})