From a770df5254f2750716cba7976915925a3b29d8ad Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Sun, 12 May 2019 23:39:52 +0200 Subject: [PATCH] Add websites cronjob and build script Signed-off-by: Patrick Uiterwijk --- playbooks/openshift-apps/websites.yml | 10 ++++++ .../websites/templates/build.sh | 4 +++ .../websites/templates/buildconfig.yml | 1 + .../websites/templates/configmap.yml | 11 ++++++ .../websites/templates/cron.yml | 35 +++++++++++++++++++ 5 files changed, 61 insertions(+) create mode 100644 roles/openshift-apps/websites/templates/build.sh create mode 100644 roles/openshift-apps/websites/templates/configmap.yml create mode 100644 roles/openshift-apps/websites/templates/cron.yml diff --git a/playbooks/openshift-apps/websites.yml b/playbooks/openshift-apps/websites.yml index 5ed4fe43eb..be0806fad9 100644 --- a/playbooks/openshift-apps/websites.yml +++ b/playbooks/openshift-apps/websites.yml @@ -29,3 +29,13 @@ app: websites buildname: websites-build objectname: websites-build + + - role: openshift/object + app: websites + template: configmap.yml + objectname: configmap.yml + + - role: openshift/object + app: websites + template: cron.yml + objectname: cron.yml diff --git a/roles/openshift-apps/websites/templates/build.sh b/roles/openshift-apps/websites/templates/build.sh new file mode 100644 index 0000000000..fe9f5502ae --- /dev/null +++ b/roles/openshift-apps/websites/templates/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash -xe +git clone --branch {% if env == "staging" %}staging{% else %}master{% endif %} https://pagure.io/fedora-web/websites.git +cd websites +exec ./build.sh /output diff --git a/roles/openshift-apps/websites/templates/buildconfig.yml b/roles/openshift-apps/websites/templates/buildconfig.yml index b80836df47..c311f5b45c 100644 --- a/roles/openshift-apps/websites/templates/buildconfig.yml +++ b/roles/openshift-apps/websites/templates/buildconfig.yml @@ -9,6 +9,7 @@ spec: dockerfile: |- FROM fedora:latest RUN dnf -y install \ + git \ python-flask \ python-frozen-flask \ python-flask-assets \ diff --git a/roles/openshift-apps/websites/templates/configmap.yml b/roles/openshift-apps/websites/templates/configmap.yml new file mode 100644 index 0000000000..abd5ee6ecd --- /dev/null +++ b/roles/openshift-apps/websites/templates/configmap.yml @@ -0,0 +1,11 @@ +{% macro load_file(filename) %}{% include filename %}{%- endmacro -%} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: websites-configmap + labels: + app: websites +data: + build.sh: |- + {{ load_file('build.sh') | indent() }} diff --git a/roles/openshift-apps/websites/templates/cron.yml b/roles/openshift-apps/websites/templates/cron.yml new file mode 100644 index 0000000000..37873dfae3 --- /dev/null +++ b/roles/openshift-apps/websites/templates/cron.yml @@ -0,0 +1,35 @@ +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: build +spec: + concurrencyPolicy: Forbid + schedule: "0 * * * *" + jobTemplate: + spec: + template: + metadata: + labels: + parent: "cronjobbuild" + spec: + containers: + - name: build + image: docker-registry.default.svc:5000/websites/builder:latest + env: + - name: BUILD_ENV + value: "{{ env_short }}" + volumeMounts: + - name: config + mountPath: /etc/websites + readOnly: true + - name: build-output + mountPath: /output + readOnly: false + restartPolicy: Never + volumes: + - name: config-volume + configMap: + name: websites-configmap + - name: build-output + persistentVolumeClaim: + claimName: websites-storage