Add pipeline
continuous-integration/drone/push Build is failing Details

This commit is contained in:
DutchEllie 2022-07-01 15:00:51 +02:00
parent 892d100e68
commit 2091723b40
Signed by: DutchEllie
SSH Key Fingerprint: SHA256:UU8yhd1Bh8exU88ev0ej/Dm+CeyfR/ZIDRrpRfYdfbg
14 changed files with 261 additions and 1 deletions

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
node_modules
npm-debug.log

52
.drone.yml Normal file
View File

@ -0,0 +1,52 @@
kind: pipeline
type: kubernetes
name: deploy
trigger:
event:
- push
steps:
- name: build-publish-image
image: plugins/docker
privileged: true
volumes:
- name: build
path: /drone/src/build
settings:
username:
from_secret: org_docker_username
password:
from_secret: org_docker_password
dockerfile: Dockerfile
repo: dutchellie/${DRONE_REPO_NAME}
tags:
- ${DRONE_BRANCH}-${DRONE_COMMIT_SHA:0:8}
- name: deploy
image: pelotech/drone-helm3
settings:
mode: upgrade
chart: .drone/helm/chart
namespace: drone-staging
release: ${DRONE_REPO_NAME}-${DRONE_BRANCH}
skip_tls_verify: true
values_files:
- .drone/helm/staging-val.yaml
values:
- "image=dutchellie/${DRONE_REPO_NAME}:${DRONE_BRANCH}-${DRONE_COMMIT_SHA:0:8}"
- "baseURL=${DRONE_BRANCH}.${DRONE_REPO_NAME}.ci.dutchellie.nl"
- "name={DRONE_REPO_NAME}-${DRONE_BRANCH}"
kube_api_server:
from_secret: org_api_server
kube_token:
from_secret: org_kube_token
kube_certificate:
from_secret: org_kube_certificate
kube_service_account: drone-deploy
dry_run: false
depends_on:
- build-publish-image
volumes:
- name: build
temp: {}

View File

@ -0,0 +1,3 @@
apiVersion: v2
name: newsite
version: v0.0.3

View File

@ -0,0 +1,39 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.name }}
namespace: {{ .Release.Namespace }}
{{- if .Values.annotations }}
annotations: {{ toYaml .Values.annotations | nindent 4}}
{{- end}}
spec:
selector:
matchLabels:
app: {{ .Values.name }}
release: {{ .Values.release }}
replicas: {{ .Values.replicas }}
template:
metadata:
{{- if .Values.podAnnotations }}
annotations:
{{- range $key, $value := .Values.controller.podAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
labels:
app: {{ .Values.name }}
release: {{ .Values.release }}
spec:
containers:
- name: {{ .Values.containerName }}
image: {{ .Values.image }}
imagePullPolicy: {{ .Values.imagePullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
{{- if .Values.containerEnv }}
env: {{ toYaml .Values.containerEnv | nindent 12 }}
{{- end }}

View File

@ -0,0 +1,36 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ tpl .Values.ingress.name . }}
namespace: {{ .Release.Namespace }}
{{- with .Values.ingress.annotations }}
annotations:
{{- tpl (. | toYaml) $ | nindent 4 }}
{{- end }}
spec:
ingressClassName: {{ .Values.ingress.className }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ tpl . $ | quote }}
{{- end }}
secretName: {{ tpl (.secretName | toYaml) $ }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ tpl .host $ | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
pathType: {{ .pathType }}
backend:
service:
name: {{ tpl $.Values.service.name $ }}
port:
number: {{ .Values.service.port }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
name: {{ tpl .Values.service.name . }}
namespace: {{ .Release.Namespace }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
selector:
app: {{ .Values.name }}
release: {{ .Values.release }}
ports:
- protocol: TCP
name: http
port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}

View File

@ -0,0 +1,29 @@
name: nginx-changeme-deployment
annotations: {}
release: latest
replicas: 1
podAnnotations: {}
containerName: nginx
image: nginx:latest
imagePullPolicy: Always
containerEnv: []
service:
name: changeme-service
annotations: {}
port: 3000
ingress:
name: changeme-ingress
annotations: {}
className: nginx
tls: []
# tls:
# - hosts:
# - example.com
# secretName: example-tls
hosts:
- host: example.com
paths:
- path: /
pathType: Prefix

21
.drone/helm/prod-val.yaml Normal file
View File

@ -0,0 +1,21 @@
baseURL: changeme.dutchellie.nl
name: changeme-prod
containerEnv:
# - name: APIURL
# value: https://api.quenten.nl/api
service:
name: "{{ .Values.name }}"
ingress:
name: "{{ .Values.name }}"
annotations:
cert-manager.io/cluster-issuer: "letsencrypt-prod"
external-dns.alpha.kubernetes.io/hostname: "{{ .Values.baseURL }}"
tls:
- hosts:
- "{{ .Values.baseURL }}"
secretName: "{{ .Values.name }}-tls"
hosts:
- host: "{{ .Values.baseURL }}"
paths:
- path: /
pathType: Prefix

View File

@ -0,0 +1,22 @@
baseURL: changemestaging.dutchellie.nl
name: changeme-staging
containerEnv:
# - name: APIURL
# value: https://api.quenten.nl/api/testing
service:
name: "{{ .Values.name }}"
port: 3000
ingress:
name: "{{ .Values.name }}"
annotations:
cert-manager.io/cluster-issuer: "letsencrypt-staging"
external-dns.alpha.kubernetes.io/hostname: "{{ .Values.baseURL }}"
tls:
- hosts:
- "{{ .Values.baseURL }}"
secretName: "{{ .Values.name }}-tls"
hosts:
- host: "{{ .Values.baseURL }}"
paths:
- path: /
pathType: Prefix

0
.drone/helm/values.yaml Normal file
View File

18
Dockerfile Normal file
View File

@ -0,0 +1,18 @@
FROM node:18.2.0-alpine
WORKDIR /app
COPY . .
RUN npm ci
RUN npm audit fix
RUN npm run build
FROM node:18.2.0-alpine
WORKDIR /app
COPY --from=0 /app/package*.json ./
RUN npm ci --production --ignore-scripts
RUN npm audit fix
COPY --from=0 /app/build ./
EXPOSE 3000
CMD ["node", "./index.js"]

19
package-lock.json generated
View File

@ -9,6 +9,7 @@
"version": "0.0.1",
"devDependencies": {
"@sveltejs/adapter-auto": "next",
"@sveltejs/adapter-node": "^1.0.0-next.78",
"@sveltejs/kit": "next",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
@ -196,6 +197,15 @@
"tiny-glob": "^0.2.9"
}
},
"node_modules/@sveltejs/adapter-node": {
"version": "1.0.0-next.78",
"resolved": "https://registry.npmjs.org/@sveltejs/adapter-node/-/adapter-node-1.0.0-next.78.tgz",
"integrity": "sha512-TXB5Ii0z/7o1B05p/YLsS4t+JUHFHWBzFv1U16TKvM3HMbMUJIx+AhpM2WJfDX8HtAyfd1m9OawGoUB+1ed24A==",
"dev": true,
"dependencies": {
"tiny-glob": "^0.2.9"
}
},
"node_modules/@sveltejs/adapter-vercel": {
"version": "1.0.0-next.59",
"resolved": "https://registry.npmjs.org/@sveltejs/adapter-vercel/-/adapter-vercel-1.0.0-next.59.tgz",
@ -3276,6 +3286,15 @@
"tiny-glob": "^0.2.9"
}
},
"@sveltejs/adapter-node": {
"version": "1.0.0-next.78",
"resolved": "https://registry.npmjs.org/@sveltejs/adapter-node/-/adapter-node-1.0.0-next.78.tgz",
"integrity": "sha512-TXB5Ii0z/7o1B05p/YLsS4t+JUHFHWBzFv1U16TKvM3HMbMUJIx+AhpM2WJfDX8HtAyfd1m9OawGoUB+1ed24A==",
"dev": true,
"requires": {
"tiny-glob": "^0.2.9"
}
},
"@sveltejs/adapter-vercel": {
"version": "1.0.0-next.59",
"resolved": "https://registry.npmjs.org/@sveltejs/adapter-vercel/-/adapter-vercel-1.0.0-next.59.tgz",

View File

@ -14,6 +14,7 @@
},
"devDependencies": {
"@sveltejs/adapter-auto": "next",
"@sveltejs/adapter-node": "^1.0.0-next.78",
"@sveltejs/kit": "next",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",

View File

@ -1,4 +1,4 @@
import adapter from '@sveltejs/adapter-auto';
import adapter from '@sveltejs/adapter-node';
import preprocess from 'svelte-preprocess';
/** @type {import('@sveltejs/kit').Config} */