Skip to content

Commit

Permalink
k8s und docker und actions
Browse files Browse the repository at this point in the history
  • Loading branch information
VanDerLars committed Jan 7, 2025
1 parent c2fbba1 commit 7274edd
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: 'Deploy sln-bookings'

on:
push:
branches:
- main

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
install-build-publish-deploy:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
lfs: true

- name: Restore cached dependencies
uses: actions/cache@v3
with:
path: |
**/node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build project
run: yarn build

- name: Login
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
ghcr.io/stadtlandnetz/sln-notion-room-booking:${{ github.sha }}
ghcr.io/stadtlandnetz/sln-notion-room-booking:main
- name: Deploy
run: |
kubectl config set-cluster k8s --server=${{ secrets.OTC_KUBERNETES_SERVER }}
kubectl config set clusters.k8s.certificate-authority-data ${{ secrets.OTC_KUBERNETES_CERT }}
kubectl config set-credentials gitlab --token=${{ secrets.OTC_KUBERNETES_TOKEN }}
kubectl config set-context default --cluster=k8s --user=gitlab
kubectl config use-context default
kubectl set image deployment/sln-bookings sln-bookings=ghcr.io/stadtlandnetz/sln-notion-room-booking:${{ github.sha }}
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:18-buster-slim

ENV NODE_ENV production
WORKDIR /sln-booking
COPY ./package.json ./
COPY ./node_modules ./node_modules
COPY ./build ./build

EXPOSE 3000

CMD node build
36 changes: 36 additions & 0 deletions k8s/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: sln-bookings
spec:
replicas: 1
selector:
matchLabels:
app: sln-bookings
template:
metadata:
labels:
app: sln-bookings
spec:
containers:
- name: sln-bookings
image: ghcr.io/stadtlandnetz/sln-notion-room-booking:main
env:
- name: NOTION_TOKEN
valueFrom:
secretKeyRef:
name: sln-bookings-notion-token
key: NOTION_TOKEN
- name: NOTION_DBID
valueFrom:
secretKeyRef:
name: sln-bookings-notion-database
key: NOTION_DATABASE_ID
resources:
limits:
memory: "500Mi"
cpu: "500m"
ports:
- containerPort: 3000
imagePullSecrets:
- name: github-registry
25 changes: 25 additions & 0 deletions k8s/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: sln-bookings
labels:
name: sln-bookings
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
ingressClassName: nginx
tls:
- hosts:
- sln-bookings.nova-hub.app
secretName: sln-bookings-tls
rules:
- host: changelog.nova-hub.app
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: sln-bookings
port:
number: 80
9 changes: 9 additions & 0 deletions k8s/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: sln-bookings-notion-token
namespace: default
data:
NOTION_DBID: MTNl=
NOTION_TOKEN: c2VjcmV0=
type: Opaque
10 changes: 10 additions & 0 deletions k8s/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: sln-bookings
spec:
selector:
app: sln-bookings
ports:
- port: 80
targetPort: 3000
8 changes: 8 additions & 0 deletions svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ const config = {
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
adapter: adapter()
},
vite: {
ssr: {
noExternal: ['@notionhq/client']
},
optimizeDeps: {
include: ['@notionhq/client']
}
}
};

Expand Down

0 comments on commit 7274edd

Please sign in to comment.