News for hackers. Stuff that matters.
Re:CapRover: Build your own PaaS by xu6ahb8E on Tuesday June 09, 2020 @07:22AM (#23465591)
Here is an example of post-receive script I use for that:

    #!/usr/bin/env bash

    export APP=appname
    export DOCKER_OPTS=""
    unset GIT_DIR

    rm -rf /home/username/apps/$APP
    cd /home/username/apps && \
    git clone /home/username/git/$APP && \
    cd $APP && \
    echo building image && \
    docker build -t $APP .
    if [[ "$?" != "0" ]]; then
      echo "error while building image."
      exit 1
    fi

    echo "Stopping previous container..."
    docker stop $APP

    echo "Starting new container..."
    sleep 1
    docker run -d --name $APP --rm $APP
Re:CapRover: Build your own PaaS by phaemon on Tuesday June 09, 2020 @09:22AM (#23466425)
You should at least use `set -u` in this script, otherwise, at some point, you'll fail to set $APP and end up running:

  rm -rf /home/username/apps/
Guess how I learned this lesson? :)
Re:CapRover: Build your own PaaS by Operyl on Tuesday June 09, 2020 @09:30AM (#23466483)
Ooooh, I need to start documenting my war stories. They'll make for a fun read at some point years down the line.
Re:CapRover: Build your own PaaS by dugmartin on Tuesday June 09, 2020 @07:31AM (#23465633)
FYI, you can avoid the $APP directory removal and clone by doing:

    GIT_WORK_TREE=/home/username/apps/$APP git checkout master
Re:CapRover: Build your own PaaS by xu6ahb8E on Tuesday June 09, 2020 @07:36AM (#23465669)
Yes, that's true, thanks for mentioning it. It comes from a time when I did not use docker so I wanted to get rid of build artifacts, but building within docker, this is not a problem anymore.
Re:CapRover: Build your own PaaS by c17r on Tuesday June 09, 2020 @10:08AM (#23466776)
If you need to use your "old way" for something else, you can use 'git clean -fdx' which will remove all files and directories that git does not track.