Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN apt-get install -y pkg-config libcap-dev libsystemd-dev git make gcc

# Checkout and get isolate
RUN git clone https://github.com/ioi/isolate /isolate/
RUN git checkout b5e87ec10c5c83830b0ab4b9d908437e4c14e426

# Build isolate
RUN make isolate
Expand Down
9 changes: 1 addition & 8 deletions scripts/hrd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,6 @@ function hrd_deploy() {
# This does a full deploy to the staging or production server
# This assumes that the .env file is already set up on the respective server
# and no new dependencies are needed to be installed (i.e. no need to rebuild the docker image)
# If you need to do any of those, you'll want to do it manually by doing the following:
#
# git push origin main
# hrd connect production
# git pull --ff-only origin main
# ./tools/docker_build.sh
# vim .env
# hrd restart
#
# Pre-requisites for this command:
# You need to add something like the following to your ~/.ssh/config file:
Expand Down Expand Up @@ -144,6 +136,7 @@ function hrd_deploy_server() {
# Server-side script for deploying the latest changes to the production server
set -e
cd ~/hurado/
./scripts/docker_build.sh
./scripts/next_build.sh
$HRD_CMD compose restart
$HRD_CMD shell npm run db:migrate
Expand Down
1 change: 1 addition & 0 deletions scripts/local/npm_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ docker run \
-v "$PROJECT_ROOT:/app" \
-w /app \
--user $(id -u):$(id -g) \
-e NPM_CONFIG_CACHE=/app/.npm \
noiph/hurado:latest npm ci
56 changes: 56 additions & 0 deletions scripts/setup_hooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash
if [ -z "$1" ]; then
echo "Error: Missing bare repository directory parameter."
echo "Usage: $0 <path_to_bare_repo>"
exit 1
fi

BARE_REPO_DIR="$1"
WORK_TREE=$(pwd)

if [ -d "$BARE_REPO_DIR" ]; then
read -p "Directory '$BARE_REPO_DIR' already exists. Delete it? (y/N): " confirm

if [[ "$confirm" =~ ^[Yy]$ ]]; then
rm -rf "$BARE_REPO_DIR"
echo "Deleted '$BARE_REPO_DIR'."
else
echo "Setup aborted. Existing directory was kept."
exit 1
fi
fi

git init --bare "$BARE_REPO_DIR"

HOOK_FILE="$BARE_REPO_DIR/hooks/post-receive"
cat > "$HOOK_FILE" <<EOL
#!/bin/bash
set -e

#https://stackoverflow.com/questions/32910661/pretend-to-be-a-tty-in-bash-for-any-command
faketty () {
script -qefc "\$(printf "%q " "\$@")" /dev/null
}

while read oldrev newrev refname; do
if [[ "\$refname" == refs/heads/* ]]; then
BRANCH="\${refname#refs/heads/}"
PWD=\$(pwd)
unset GIT_DIR

# this assumes the work tree already exists
set +e
cd $WORK_TREE
faketty ./scripts/hrd.sh compose stop
set -e

cd \$PWD
GIT_WORK_TREE="$WORK_TREE" git checkout -f "\$BRANCH"

cd $WORK_TREE
faketty ./scripts/hrd.sh deploy_server | cat
fi
done
EOL

chmod +x $HOOK_FILE
Loading