Skip to content

Commit

Permalink
Merge pull request #139 from molgenis/build/move_circleci
Browse files Browse the repository at this point in the history
Build/move circleci
  • Loading branch information
mswertz authored Jul 26, 2024
2 parents 1d6322a + 5464c91 commit fc8e929
Show file tree
Hide file tree
Showing 12 changed files with 317 additions and 102 deletions.
37 changes: 37 additions & 0 deletions .circleci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# docker file for the ci
# to build and publish:
# docker buildx build -t molgenis/molgenis-org-ci:v1.0.1 --platform linux/amd64 .
# docker push molgenis/molgenis-org-ci:v1.0.1

FROM ubuntu:jammy

# general deps
RUN apt-get update
RUN apt-get install ruby-full build-essential zlib1g-dev lsb-release curl -y

# kubectl repo
RUN curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add
RUN echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | tee /etc/apt/sources.list.d/kubernetes.list
RUN apt-get update
RUN apt-get install kubectl -y

#
##helm repo
RUN curl https://baltocdn.com/helm/signing.asc | gpg --dearmor | tee /usr/share/keyrings/helm.gpg > /dev/null
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/helm.gpg] https://baltocdn.com/helm/stable/debian/ all main" | tee /etc/apt/sources.list.d/helm-stable-debian.list
RUN apt-get update
RUN apt-get install helm -y
#

# Azure CLI Tools
RUN mkdir -p /etc/apt/keyrings
RUN curl -sLS https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | tee /etc/apt/keyrings/microsoft.gpg > /dev/null
RUN chmod go+r /etc/apt/keyrings/microsoft.gpg
RUN AZ_DIST=$(lsb_release -cs) && echo "deb [arch=`dpkg --print-architecture` signed-by=/etc/apt/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/azure-cli/ $AZ_DIST main" | tee /etc/apt/sources.list.d/azure-cli.list
RUN apt-get update
RUN apt-get install azure-cli

# jekyll
COPY Gemfile .
RUN gem install bundler jekyll
RUN bundle update
8 changes: 8 additions & 0 deletions .circleci/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source 'https://rubygems.org'

ruby '3.0.2'

gem "jekyll"
gem "jekyll-feed"
gem "jekyll-target-blank"
gem "html-proofer"
68 changes: 68 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version: 2.1

parameters:
GHA_Actor:
type: string
default: ""
GHA_Event:
type: string
default: ""
GHA_Action:
type: string
default: ""
GHA_Meta:
type: string
default: ""

orbs:
slack: circleci/[email protected]

jobs:
build:
docker:
- image: molgenis/molgenis-org-ci:v1.0.1
steps:
- checkout
- run:
name: Jekyll build
command: |
bundle exec jekyll doctor
bundle exec jekyll build
- run:
name: prepare azure
command: |
az login --service-principal --tenant ${AZURE_SP_TENANT} -u ${AZURE_CLIENT_ID} -p ${AZURE_SECRET}
az aks get-credentials -g ${RESOURCE_GROUP} -n ${RESOURCE_GROUP}
kubectl config set-cluster ${RESOURCE_GROUP}
kubectl config use-context ${RESOURCE_GROUP}
- run:
name: update preview
command: |
NAME="preview-molgenis-org-pr-${CIRCLE_PULL_REQUEST##*/}"
echo "${NAME}"
kubectl delete namespace $NAME || true
echo ${CERTDEVMOLGENIS_KEY} | base64 --decode >> /tmp/cert_key
echo ${CERTDEVMOLGENIS_PEM} | base64 --decode >> /tmp/cert_pem
kubectl create namespace ${NAME}
kubectl create secret tls "dev.molgenis.org" --key /tmp/cert_key --cert /tmp/cert_pem -n ${NAME}
kubectl create configmap html-files --from-file=_site -n ${NAME}
helm upgrade --install ${NAME} ./helm-chart --namespace ${NAME} \
--set ingress.hosts[0].host=${NAME}.dev.molgenis.org \
--set spec.tls[0].hosts[0].host=${NAME}.dev.molgenis.org \
--set image.tag=latest \
--set image.repository=nginx \
--set image.pullPolicy=Always \
--debug
- run:
name: message slack about preview
command: |
curl -d "token=${SLACK_TOKEN}" \
-d "text=*<${CIRCLE_PULL_REQUEST}|Circle-CI » Molgenis » Molgenis-org » PR-${CIRCLE_PULL_REQUEST##*/} #${CIRCLE_BUILD_NUM}>*
PR Preview available on https://preview-molgenis-org-${CIRCLE_PULL_REQUEST##*/}.dev.molgenis.org" \
-d "channel=C02AZDG6QQ7" \
-X POST https://slack.com/api/chat.postMessage
workflows:
version: 2
build:
jobs:
- build
101 changes: 0 additions & 101 deletions Jenkinsfile

This file was deleted.

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

We produce the website using Jekyl. The master branch is automatically build and can be viewed at http://site.dev.molgenis.org . The admin of the website can then push it into production.


# How to develop

Fork this repository and then checkout. On your own machine you should install jekyll.
Expand Down
7 changes: 7 additions & 0 deletions helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: website
version: 0.0.0
appVersion: "8.x"
icon: https://raw.githubusercontent.com/molgenis/molgenis-ops-helm/master/charts/molgenis/catalogIcon-molgenis.png
description: MOLGENIS website
type: application
63 changes: 63 additions & 0 deletions helm-chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "website.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "website.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "website.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "website.labels" -}}
helm.sh/chart: {{ include "website.chart" . }}
{{ include "website.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Selector labels
*/}}
{{- define "website.selectorLabels" -}}
app.kubernetes.io/name: {{ include "website.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "website.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "website.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
41 changes: 41 additions & 0 deletions helm-chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "website.fullname" . }}
labels:
app: {{ template "website.name" . }}
chart: {{ template "website.chart" . }}
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
spec:
replicas: 1
selector:
matchLabels:
{{- include "website.selectorLabels" . | nindent 6 }}
strategy:
type: Recreate
template:
metadata:
labels:
{{- include "website.selectorLabels" . | nindent 8 }}
spec:
initContainers:
- name: data-loader
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["sh", "-c", "cp -r /mnt/html-files/. /usr/share/nginx/html"]
volumeMounts:
- name: html-volume
mountPath: /mnt/html-files
containers:
- name: nginx-container
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
ports:
- containerPort: 80
volumeMounts:
- name: html-volume
mountPath: /usr/share/nginx/html
volumes:
- name: html-volume
persistentVolumeClaim:
claimName: {{ include "website.fullname" . }}-pv
36 changes: 36 additions & 0 deletions helm-chart/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{{- if .Values.ingress.enabled }}
{{- $fullName := include "website.fullname" . -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "website.fullname" . }}
labels:
app: {{ template "website.name" . }}
chart: {{ template "website.chart" . }}
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/proxy-body-size: "0"
nginx.ingress.kubernetes.io/use-regex: "true"
spec:
tls:
{{- range .Values.ingress.hosts }}
- hosts:
- {{ .host | quote }}
secretName: dev.molgenis.org

rules:
- host: {{ .host | quote }}
http:
paths:
- path: {{default "/" .path}}
pathType: Prefix
backend:
service:
name: {{$fullName}}
port:
number: 80

{{- end }}
{{- end }}
16 changes: 16 additions & 0 deletions helm-chart/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ include "website.fullname" . }}-pv
labels:
app: {{ template "website.name" . }}
chart: {{ template "website.chart" . }}
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1G
status: {}
Loading

0 comments on commit fc8e929

Please sign in to comment.