diff options
Diffstat (limited to 'ci')
| -rw-r--r-- | ci/.gitignore | 2 | ||||
| -rw-r--r-- | ci/Dockerfile | 13 | ||||
| -rw-r--r-- | ci/data/etc/sbclrc | 6 | ||||
| -rw-r--r-- | ci/data/etc/snow/figwheel-main.edn | 34 | ||||
| -rw-r--r-- | ci/data/etc/snow/options.lisp | 20 | ||||
| -rwxr-xr-x | ci/data/install-root.sh | 40 | ||||
| -rwxr-xr-x | ci/data/install-user-sbcl.sh | 10 | ||||
| -rw-r--r-- | ci/data/snow-starter.lisp | 7 | ||||
| -rwxr-xr-x | ci/data/start_app.sh | 45 | ||||
| -rwxr-xr-x | ci/docker-build.sh | 26 | ||||
| -rw-r--r-- | ci/docker-compose.yaml | 81 | ||||
| -rwxr-xr-x | ci/docker-run.sh | 7 | ||||
| -rw-r--r-- | ci/env.sh | 4 |
13 files changed, 295 insertions, 0 deletions
diff --git a/ci/.gitignore b/ci/.gitignore new file mode 100644 index 0000000..7ca3a5c --- /dev/null +++ b/ci/.gitignore @@ -0,0 +1,2 @@ +tmp +docker-start.tar.xz diff --git a/ci/Dockerfile b/ci/Dockerfile new file mode 100644 index 0000000..9058561 --- /dev/null +++ b/ci/Dockerfile @@ -0,0 +1,13 @@ +FROM arm64v8/ubuntu:noble +MAINTAINER Olo Platform Evolution #eng-platform-evolution-help +ADD tmp/docker-start.tar.xz / +ARG OLO_USERNAME=root +ARG OLO_GROUPNAME=root +ARG OLO_UID=0 +ARG OLO_GID=0 +RUN data/install-root.sh +USER ${OLO_UID}:${OLO_GID} +RUN data/install-user-sbcl.sh +ENTRYPOINT [ "data/start_app.sh" ] +#ENTRYPOINT [ "/bin/bash", "-l", "-c" ] +CMD [] diff --git a/ci/data/etc/sbclrc b/ci/data/etc/sbclrc new file mode 100644 index 0000000..3a931d0 --- /dev/null +++ b/ci/data/etc/sbclrc @@ -0,0 +1,6 @@ +;;; The following lines added by ql:add-to-init-file: +#-quicklisp +(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp" + (user-homedir-pathname)))) + (when (probe-file quicklisp-init) + (load quicklisp-init))) diff --git a/ci/data/etc/snow/figwheel-main.edn b/ci/data/etc/snow/figwheel-main.edn new file mode 100644 index 0000000..864266c --- /dev/null +++ b/ci/data/etc/snow/figwheel-main.edn @@ -0,0 +1,34 @@ +;; Figwheel-main configuration options see: https://figwheel.org/config-options +;; these will be overriden by the metadata config options in dev.cljs.edn build file +{ + ;; Set the server port https://figwheel.org/config-options#ring-server-options + ;; :ring-server-options {:port 9500} + + ;; Change the target directory from the "target" to "resources" + ;; https://figwheel.org/config-options#target-dir + ;; :target-dir "resources" + + ;; Server Ring Handler (optional) https://figwheel.org/docs/ring-handler.html + ;; If you want to embed a ring handler into the figwheel server, this + ;; is for simple ring servers + ;; :ring-handler hello_world.server/handler + + ;; To be able to open files in your editor from the heads up display + ;; you will need to put a script on your path. This script will have + ;; to take a file path and a line number ie. + ;; in ~/bin/myfile-opener: + ;; + ;; #! /bin/sh + ;; emacsclient -n +$2:$3 $1 + ;; + ;; :open-file-command "myfile-opener" + + ;; if you are using emacsclient you can just use + ;; :open-file-command "emacsclient" + + ;; Logging output gets printed to the REPL, if you want to redirect it to a file: + ;; :log-file "figwheel-main.log" + + :target-dir "resources" + :open-url false +} diff --git a/ci/data/etc/snow/options.lisp b/ci/data/etc/snow/options.lisp new file mode 100644 index 0000000..290ba00 --- /dev/null +++ b/ci/data/etc/snow/options.lisp @@ -0,0 +1,20 @@ +((:name "snow" + :url "http://localhost:3013" + :document-root "snow" + :title "Super Nifty Olo Webapp" + :meta-description "Super Nifty Olo Webapp" + :region "us-east-1" + :queue (:sleep-interval 15 + :git (:num-process-threads 10 + :wait-interval 0 + :exclude-dirs (".vscode" "frodomat" "frodomat-ci" "frodomat-teamcity" "ssh-tunnel" "ssl-cert" "datamat" "datamat-ci")) + :aws (:num-process-threads 30 + :wait-interval 90) + :octopus-slow (:num-process-threads 1 + :wait-interval 0) + :octopus-fast (:num-process-threads 10 + :wait-interval 0) + :tfcloud (:num-process-threads 1 + :wait-interval 0) + :awx (:num-process-threads 10 + :wait-interval 0)))) diff --git a/ci/data/install-root.sh b/ci/data/install-root.sh new file mode 100755 index 0000000..ca4f1c4 --- /dev/null +++ b/ci/data/install-root.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +echo 'APT::Acquire::Retries "3";' > /etc/apt/apt.conf.d/80-retries +export DEBIAN_FRONTEND=noninteractive +apt-get update +apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade +apt-get -y install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" aptitude +aptitude -y install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" apt-transport-https ca-certificates software-properties-common language-pack-de +update-ca-certificates +aptitude update +aptitude -y install -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" sbcl sbcl-source leiningen dnsutils bind9-host vim curl wget rlwrap pass rsync sudo gh jq lsof zip unzip + +mkdir -p /opt/aws-cli +pushd /tmp +rm -rf aws +curl -o awscliv2.zip https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip +unzip awscliv2.zip +pushd aws +./install -i /opt/aws-cli -b /usr/local/bin --update +popd +popd + +rsync -av /data/ / + +if (( OLO_UID != 0 )); then + userdel ubuntu || true + groupdel ubuntu || true + rm -rf /home/ubuntu || true + export HOMEDIR="/home/${OLO_USERNAME}" + groupadd -g "${OLO_GID}" "${OLO_GROUPNAME}" || OLO_GROUPNAME=$(grep -F "x:${OLO_GID}:" /etc/group | awk -F: '{print $1}') + useradd -s /bin/bash -m -u "${OLO_UID}" -g "${OLO_GROUPNAME}" "${OLO_USERNAME}" || OLO_USERNAME=$(grep -F "x:${OLO_UID}:" /etc/passwd | awk -F: '{print $1}') + SUDOERS_FILENAME="${OLO_USERNAME//\./_}" + echo "${OLO_USERNAME} ALL=(ALL) NOPASSWD: ALL" > "/etc/sudoers.d/${SUDOERS_FILENAME}" + chmod 0440 "/etc/sudoers.d/${SUDOERS_FILENAME}" + mkdir -p "${HOMEDIR}/.gnupg" + chown "${OLO_USERNAME}":"${OLO_GROUPNAME}" "${HOMEDIR}/.gnupg" + chmod 0700 "${HOMEDIR}/.gnupg" +fi + +exit 0 diff --git a/ci/data/install-user-sbcl.sh b/ci/data/install-user-sbcl.sh new file mode 100755 index 0000000..e9d03ff --- /dev/null +++ b/ci/data/install-user-sbcl.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +curl -o ~/quicklisp.lisp https://beta.quicklisp.org/quicklisp.lisp +sbcl --load ~/quicklisp.lisp --eval "(quicklisp-quickstart:install)" --eval "(sb-ext:exit)" +sbcl --eval "(loop for pkg in '(cl-ppcre cl-smtp hunchentoot cl-log ironclad cl-markdown tmpdir swank net-telent-date uffi drakma cl-json postmodern fiveam local-time trivial-octet-streams cl-ppcre) do (ql:quickload (symbol-name pkg)))" --eval "(sb-ext:exit)" + +mkdir -p ~/.config/common-lisp +echo "(:source-registry (:tree (:home \"common-lisp/systems\")) :inherit-configuration)" | tee ~/.config/common-lisp/source-registry.conf + +exit 0 diff --git a/ci/data/snow-starter.lisp b/ci/data/snow-starter.lisp new file mode 100644 index 0000000..e808f7a --- /dev/null +++ b/ci/data/snow-starter.lisp @@ -0,0 +1,7 @@ +(load "/etc/sbclrc") +(asdf:operate 'asdf:load-op 'swank) +(setf swank::*loopback-interface* "0.0.0.0") +(swank:create-server :port 4109 :dont-close t) +(asdf:operate 'asdf:load-op 'snow) +(in-package :snow) +(snow) diff --git a/ci/data/start_app.sh b/ci/data/start_app.sh new file mode 100755 index 0000000..029afe1 --- /dev/null +++ b/ci/data/start_app.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +mkdir -p ~/common-lisp/systems ~/opt +cd ~/opt +git clone -b main git@ns:repos/snow.git +git clone -b master git@github.com:ckonstanski/org-ckons-cljs.form.git +git clone -b master git@github.com:ckonstanski/org-ckons-cljs.notifications +git clone -b master git@github.com:ckonstanski/org-ckons-condition +git clone -b master git@github.com:ckonstanski/org-ckons-core +git clone -b master git@github.com:ckonstanski/org-ckons-file +git clone -b master git@github.com:ckonstanski/org-ckons-http +git clone -b master git@github.com:ckonstanski/org-ckons-json +git clone -b master git@github.com:ckonstanski/org-ckons-serializable +git clone -b master git@github.com:ckonstanski/org-ckons-session +git clone -b master git@github.com:ckonstanski/org-ckons-sql + +logdir="/var/log/lisp" +mv ${logdir}/snow.log.1 ${logdir}/snow.log.2 +mv ${logdir}/${APPNAME}snow.log ${logdir}/snow.log.1 + +pushd ~/common-lisp/systems +ln -s ~/opt/snow/lisp/snow.asd snow.asd +ln -s ~/opt/org-ckons-condition/org-ckons-condition.asd org-ckons-condition.asd +ln -s ~/opt/org-ckons-core/org-ckons-core.asd org-ckons-core.asd +ln -s ~/opt/org-ckons-file/org-ckons-file.asd org-ckons-file.asd +ln -s ~/opt/org-ckons-http/org-ckons-http.asd org-ckons-http.asd +ln -s ~/opt/org-ckons-json/org-ckons-json.asd org-ckons-json.asd +ln -s ~/opt/org-ckons-serializable/org-ckons-serializable.asd org-ckons-serializable.asd +ln -s ~/opt/org-ckons-session/org-ckons-session.asd org-ckons-session.asd +ln -s ~/opt/org-ckons-sql/org-ckons-sql.asd org-ckons-sql.asd +popd + +pushd ~/opt/snow/lisp/webapps/snow/clojurescript/snow +ln -s /etc/snow/figwheel-main.edn figwheel-main.edn +mkdir checkouts +pushd checkouts +ln -s ~/opt/org-ckons-cljs.form org-ckons-cljs.form +ln -s ~/opt/org-ckons-cljs.notifications org-ckons-cljs.notifications +popd + +lein clean +lein fig:build | tee /tmp/snow/lein.log & +popd + +SBCL_HOME=/usr/lib/sbcl SBCL_SOURCE_ROOT=/usr/lib/sbcl/src exec sbcl --dynamic-space-size 2048 --userinit /data/snow-starter.lisp | tee /tmp/snow/sbcl.log diff --git a/ci/docker-build.sh b/ci/docker-build.sh new file mode 100755 index 0000000..05f180e --- /dev/null +++ b/ci/docker-build.sh @@ -0,0 +1,26 @@ +#!/bin/bash -e + +. env.sh + +builddir='tmp' +container='snow' + +rm -rf ${builddir} +mkdir ${builddir} +rsync -aq data ${builddir} +pushd ${builddir} 2>/dev/null + +tar Jcvf docker-start.tar.xz data/ +docker stop ${container} || true +docker container prune -f +docker rmi --force ${container} + +DOCKER_BUILDKIT=0 docker compose --ansi "never" build \ + --no-cache \ + --pull \ + --progress "plain" + +popd 2>/dev/null +rm -rf tmp + +exit 0 diff --git a/ci/docker-compose.yaml b/ci/docker-compose.yaml new file mode 100644 index 0000000..930ed8b --- /dev/null +++ b/ci/docker-compose.yaml @@ -0,0 +1,81 @@ +services: + snow: + image: snow:v0.1 + tty: true + build: + context: . + args: + OLO_USERNAME: ${OLO_USERNAME} + OLO_GROUPNAME: ${OLO_GROUPNAME} + OLO_UID: ${OLO_UID} + OLO_GID: ${OLO_GID} + network_mode: "host" + container_name: snow + volumes: + - type: bind + source: /tmp/snow + target: /tmp/snow + - type: bind + source: ~/.aws + target: /home/${OLO_USERNAME}/.aws + - type: bind + source: ~/.terraform.d + target: /home/${OLO_USERNAME}/.terraform.d + - type: bind + source: ~/.m2 + target: /home/${OLO_USERNAME}/.m2 + - type: bind + source: ~/.bashrc + target: /home/${OLO_USERNAME}/.bashrc + - type: bind + source: ~/.bash_history + target: /home/${OLO_USERNAME}/.bash_history + - type: bind + source: ~/.vimrc + target: /home/${OLO_USERNAME}/.vimrc + - type: bind + source: ~/.gitconfig + target: /home/${OLO_USERNAME}/.gitconfig + - type: bind + source: ~/.ssh + target: /home/${OLO_USERNAME}/.ssh + - type: bind + source: ~/.tsh + target: /home/${OLO_USERNAME}/.tsh + - type: bind + source: ~/.local + target: /home/${OLO_USERNAME}/.local + - type: bind + source: ~/.emacs.d + target: /home/${OLO_USERNAME}/.emacs.d + - type: bind + source: ~/.password-store + target: /home/${OLO_USERNAME}/.password-store + - type: bind + source: ~/.gnupg + target: /home/${OLO_USERNAME}/.gnupg + - type: bind + source: /run/user/${OLO_UID} + target: /run/user/${OLO_UID} + - type: bind + source: /run/user/${OLO_UID}/gnupg/S.gpg-agent + target: /home/${OLO_USERNAME}/.gnupg/S.gpg-agent + - type: bind + source: /etc/hosts + target: /etc/hosts + - type: bind + source: /etc/ssh + target: /etc/ssh + - type: bind + source: /var/log/lisp + target: /var/log/lisp + environment: + - TERM=xterm-256color + - AWS_SDK_LOAD_CONFIG=1 + - https_proxy=${https_proxy} + - http_proxy=${http_proxy} + - no_proxy=${no_proxy} + - OLO_PROJECT_HOME=${OLO_PROJECT_HOME} + - GITHUB_TOKEN=${GITHUB_TOKEN} + - GPG_AGENT_INFO=/home/${OLO_USERNAME}/.gnupg/S.gpg-agent:0:1 + command: [ "/bin/bash -l -c" ] diff --git a/ci/docker-run.sh b/ci/docker-run.sh new file mode 100755 index 0000000..c368224 --- /dev/null +++ b/ci/docker-run.sh @@ -0,0 +1,7 @@ +#!/bin/bash -e + +. env.sh + +docker compose --ansi "never" up -d + +exit 0 diff --git a/ci/env.sh b/ci/env.sh new file mode 100644 index 0000000..a49fb54 --- /dev/null +++ b/ci/env.sh @@ -0,0 +1,4 @@ +export OLO_USERNAME=$(id -un) +export OLO_GROUPNAME=$(id -gn) +export OLO_UID=$(id -u) +export OLO_GID=$(id -g) |
