wip deploy

This commit is contained in:
tali 2024-02-02 11:15:40 -05:00
parent 50d27b7cd9
commit 7d8669867c
4 changed files with 82 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
_build/
_opam/
_dist/
*.install

13
deploy/_build.sh Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env bash
export OPAMROOTISOK=1
opam init --disable-sandboxing --no-setup
eval $(opam env)
opam pin add ./talircd --kind=path --no-action --yes
opam install talircd --destdir=dist
#opam install talircd --destdir=dist --yes

16
deploy/build.sh Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
MACHINE=${MACHINE:-talircd-build}
PROJECT_ROOT=${PROJECT_ROOT:-$(git rev-parse --show-toplevel)}
DIST_DIR=${DIST_DIR:-${PROJECT_ROOT}/_dist}
set -x
mkdir -p "${DIST_DIR}"
sudo systemd-nspawn -q \
--machine ${MACHINE} \
--bind-ro ${PROJECT_ROOT}:/root/talircd \
--bind ${DIST_DIR}:/root/dist \
--chdir /root \
/root/talircd/deploy/_run.sh

52
deploy/deploy.sh Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env bash
MACHINE=${MACHINE:-talircd-build}
MACHINE_PATH=/var/lib/machines/${MACHINE}
PROJECT_ROOT=${PROJECT_ROOT:-$(git rev-parse --show-toplevel)}
DIST_DIR=${DIST_DIR:-${PROJECT_ROOT}/_dist}
CODENAME=bullseye
MIRROR=${MIRROR:-http://debian.csail.mit.edu/debian/}
COMMAND=${1:-build}
set -x
function init() {
# TODO: fakeroot ?
sudo debootstrap \
--include=ocaml-base,ocaml,opam,ca-certificates,git,rsync \
--components=main,contrib \
${CODENAME} ${MACHINE_PATH} ${MIRROR}
}
function cleanall() {
sudo rm -rf ${MACHINE_PATH}
}
function clean() {
sudo systemd-nspawn -q \
--machine ${MACHINE} \
rm -rf /root/.opam
}
function build() {
sudo systemd-nspawn -q \
--machine ${MACHINE} \
--bind-ro ${PROJECT_ROOT}:/root/talircd \
--bind ${DIST_DIR}:/root/dist \
--chdir /root \
/root/talircd/deploy/_build.sh
}
case $1 in
init) init ;;
build) build ;;
clean) clean ;;
cleanall) cleanall ;;
*)
echo "$1"
esac
# mkdir -p "${DIST_DIR}"