[skip-ci] WIP Add docker image
Add website-build-deployment and cron skeleton. Add shadow-cljs.edn - needs config for cljs.merge-requests/1/merge
parent
a21c2a4957
commit
76f5b87ec9
@ -0,0 +1,51 @@
|
||||
from os import environ
|
||||
from pybuilder.core import task, init
|
||||
from ddadevops import *
|
||||
import logging
|
||||
|
||||
name = 'c4k-website-build'
|
||||
MODULE = 'docker'
|
||||
PROJECT_ROOT_PATH = '../..'
|
||||
|
||||
class MyBuild(DevopsDockerBuild):
|
||||
pass
|
||||
|
||||
@init
|
||||
def initialize(project):
|
||||
project.build_depends_on('ddadevops>=0.12.4')
|
||||
stage = 'prod'
|
||||
dockerhub_user = environ.get('DOCKERHUB_USER')
|
||||
if not dockerhub_user:
|
||||
dockerhub_user = gopass_field_from_path('meissa/web/docker.com', 'login')
|
||||
dockerhub_password = environ.get('DOCKERHUB_PASSWORD')
|
||||
if not dockerhub_password:
|
||||
dockerhub_password = gopass_password_from_path('meissa/web/docker.com')
|
||||
tag = environ.get('CI_COMMIT_TAG')
|
||||
if not tag:
|
||||
tag = get_tag_from_latest_commit()
|
||||
config = create_devops_docker_build_config(
|
||||
stage, PROJECT_ROOT_PATH, MODULE, dockerhub_user, dockerhub_password, docker_publish_tag=tag)
|
||||
build = MyBuild(project, config)
|
||||
build.initialize_build_dir()
|
||||
|
||||
|
||||
@task
|
||||
def image(project):
|
||||
build = get_devops_build(project)
|
||||
build.image()
|
||||
|
||||
@task
|
||||
def drun(project):
|
||||
build = get_devops_build(project)
|
||||
build.drun()
|
||||
|
||||
@task
|
||||
def publish(project):
|
||||
build = get_devops_build(project)
|
||||
build.dockerhub_login()
|
||||
build.dockerhub_publish()
|
||||
|
||||
@task
|
||||
def test(project):
|
||||
build = get_devops_build(project)
|
||||
build.test()
|
@ -0,0 +1,9 @@
|
||||
FROM clojure:temurin-18-jammy
|
||||
|
||||
# Prepare Entrypoint Script
|
||||
ADD resources /tmp
|
||||
|
||||
ENV BUILDDIR="website"
|
||||
|
||||
RUN /tmp/install.sh
|
||||
RUN /tmp/entrypoint.sh
|
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
source /usr/local/bin/functions.sh
|
||||
|
||||
function main() {
|
||||
get-and-unzip-website-data
|
||||
build-and-extract-website
|
||||
move-website-files-to-target
|
||||
}
|
||||
|
||||
main
|
||||
|
||||
while true; do
|
||||
sleep 1m
|
||||
done
|
@ -0,0 +1,2 @@
|
||||
.git
|
||||
.gitignore
|
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# "Authorization: token YOURAUTHTOKEN"
|
||||
function get-and-unzip-website-data() {
|
||||
curl -H "$AUTHTOKEN" -O $REPOZIPURL # REPOZIPURL = https://your.gitea.host/api/v1/repos/<owner>/<repo>/archive/main.zip
|
||||
mkdir $BUILDDIR
|
||||
unzip main.zip -D $BUILDDIR
|
||||
}
|
||||
|
||||
function build-and-extract-website() {
|
||||
(cd $BUILDDIR; lein ring war; websiteartifactname=$(ls | grep -o *.war); unzip target/$websiteartifactname "WEB-INF/classes/public/*")
|
||||
}
|
||||
|
||||
# set variables from environment
|
||||
# read write zugriff sicherstellen
|
||||
function move-website-files-to-target() {
|
||||
rsync -ru --exclude-from "/home/$USER/exclude.pattern" --delete WEB-INF/classes/public/* $TARGETDIR # TARGETDIR = mount/path/to/website-content-vol with write permission
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
apt update > /dev/null;
|
||||
|
||||
install -m 0700 /tmp/entrypoint.sh /
|
||||
|
||||
install -m 0700 /tmp/functions.sh /usr/local/bin/
|
||||
install -m 0700 /tmp/exclude.pattern /home/$USER
|
||||
install -m 0700 /tmp/project.clj /home/$USER/.lein/
|
||||
(cd /home/$USER/.lein; lein deps)
|
@ -0,0 +1,2 @@
|
||||
{:user
|
||||
{:plugins [[lein-ring "0.12.5"]]}}
|
@ -0,0 +1,11 @@
|
||||
FROM c4k-jira-backup
|
||||
|
||||
RUN apt update
|
||||
RUN apt -yqq --no-install-recommends --yes install curl default-jre-headless
|
||||
|
||||
RUN curl -L -o /tmp/serverspec.jar \
|
||||
https://github.com/DomainDrivenArchitecture/dda-serverspec-crate/releases/download/2.0.0/dda-serverspec-standalone.jar
|
||||
|
||||
COPY serverspec.edn /tmp/serverspec.edn
|
||||
|
||||
RUN java -jar /tmp/serverspec.jar /tmp/serverspec.edn -v
|
@ -0,0 +1,5 @@
|
||||
{:file [{:path "/usr/local/bin/install.sh" :mod "700"}
|
||||
{:path "/usr/local/bin/functions.sh" :mod "700"}
|
||||
{:path "/usr/local/bin/exclude.pattern" :mod "700"}
|
||||
{:path "/usr/local/bin/project.clj" :mod "700"}
|
||||
{:path "/entrypoint.sh" :mod "700"}]}
|
@ -0,0 +1,16 @@
|
||||
{:source-paths ["src/main/cljc"
|
||||
"src/main/cljs"
|
||||
"src/main/resources"
|
||||
"src/test/cljc"
|
||||
"src/test/cljs"
|
||||
"src/test/resources"]
|
||||
:dependencies [[org.domaindrivenarchitecture/c4k-common-cljs "3.0.1"]
|
||||
[hickory "0.7.1"]
|
||||
[org.clojure/math.numeric-tower "0.0.5"]]
|
||||
:builds {:frontend {:target :browser
|
||||
:modules {:main {:init-fn dda.c4k-website.browser/init}}
|
||||
:release {}
|
||||
:compiler-options {:optimizations :advanced}}
|
||||
:test {:target :node-test
|
||||
:output-to "target/node-tests.js"
|
||||
:repl-pprint true}}}
|
@ -0,0 +1,47 @@
|
||||
apiVersion: batch/v1beta1
|
||||
kind: CronJob
|
||||
metadata:
|
||||
name: website-builder
|
||||
labels:
|
||||
app.kubernetes.part-of: website # correct name?
|
||||
spec:
|
||||
schedule: "10 23 * * *"
|
||||
successfulJobsHistoryLimit: 1
|
||||
failedJobsHistoryLimit: 1
|
||||
jobTemplate:
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: backup-app
|
||||
image: domaindrivenarchitecture/c4k-gitea-backup
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: ["/entrypoint.sh"]
|
||||
env:
|
||||
- name: AWS_DEFAULT_REGION
|
||||
value: eu-central-1
|
||||
- name: AWS_ACCESS_KEY_ID_FILE
|
||||
value: /var/run/secrets/backup-secrets/aws-access-key-id
|
||||
- name: AWS_SECRET_ACCESS_KEY_FILE
|
||||
value: /var/run/secrets/backup-secrets/aws-secret-access-key
|
||||
- name: RESTIC_REPOSITORY
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: backup-config
|
||||
key: restic-repository
|
||||
- name: RESTIC_PASSWORD_FILE
|
||||
value: /var/run/secrets/backup-secrets/restic-password
|
||||
volumeMounts:
|
||||
- name: gitea-data-volume
|
||||
mountPath: /var/backups
|
||||
- name: backup-secret-volume
|
||||
mountPath: /var/run/secrets/backup-secrets
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: gitea-data-volume
|
||||
persistentVolumeClaim:
|
||||
claimName: gitea-data-pvc
|
||||
- name: backup-secret-volume
|
||||
secret:
|
||||
secretName: backup-secret
|
||||
restartPolicy: OnFailure
|
@ -0,0 +1,73 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: backup-restore
|
||||
spec:
|
||||
replicas: 0
|
||||
selector:
|
||||
matchLabels:
|
||||
app: backup-restore
|
||||
strategy:
|
||||
type: Recreate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: backup-restore
|
||||
app.kubernetes.io/name: backup-restore
|
||||
app.kubernetes.io/part-of: gitea
|
||||
spec:
|
||||
containers:
|
||||
- image: domaindrivenarchitecture/c4k-gitea-backup
|
||||
name: backup-app
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: ["/entrypoint-start-and-wait.sh"]
|
||||
env:
|
||||
- name: POSTGRES_USER
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: postgres-secret
|
||||
key: postgres-user
|
||||
- name: POSTGRES_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: postgres-secret
|
||||
key: postgres-password
|
||||
- name: POSTGRES_DB
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: postgres-config
|
||||
key: postgres-db
|
||||
- name: POSTGRES_HOST
|
||||
value: "postgresql-service:5432"
|
||||
- name: POSTGRES_SERVICE
|
||||
value: "postgresql-service"
|
||||
- name: POSTGRES_PORT
|
||||
value: "5432"
|
||||
- name: AWS_DEFAULT_REGION
|
||||
value: eu-central-1
|
||||
- name: AWS_ACCESS_KEY_ID_FILE
|
||||
value: /var/run/secrets/backup-secrets/aws-access-key-id
|
||||
- name: AWS_SECRET_ACCESS_KEY_FILE
|
||||
value: /var/run/secrets/backup-secrets/aws-secret-access-key
|
||||
- name: RESTIC_REPOSITORY
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: backup-config
|
||||
key: restic-repository
|
||||
- name: RESTIC_PASSWORD_FILE
|
||||
value: /var/run/secrets/backup-secrets/restic-password
|
||||
- name: CERTIFICATE_FILE
|
||||
value: ""
|
||||
volumeMounts:
|
||||
- name: gitea-data-volume
|
||||
mountPath: /var/backups
|
||||
- name: backup-secret-volume
|
||||
mountPath: /var/run/secrets/backup-secrets
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: gitea-data-volume
|
||||
persistentVolumeClaim:
|
||||
claimName: gitea-data-pvc
|
||||
- name: backup-secret-volume
|
||||
secret:
|
||||
secretName: backup-secret
|
Loading…
Reference in New Issue