github.com/rkt/rkt@v1.30.1-0.20200224141603-171c416fac02/Documentation/examples/build-container/play-example/build-play-example.sh (about)

     1  #!/usr/bin/env bash
     2  set -e
     3  
     4  if [ "$EUID" -ne 0 ]; then
     5      echo "This script uses functionality which requires root privileges"
     6      exit 1
     7  fi
     8  
     9  # Start the build with an empty ACI
    10  acbuild --debug begin docker://ubuntu:17.10
    11  
    12  # In the event of the script exiting, end the build
    13  trap "{ export EXT=$?; acbuild --debug end && exit $EXT; }" EXIT
    14  
    15  # Name the ACI
    16  acbuild --debug set-name example.com/play-example
    17  
    18  # Install java, psql, and git
    19  acbuild --debug run -- apt-get update
    20  acbuild --debug run -- apt-get -y install openjdk-8-jre openjdk-8-jdk git postgresql
    21  
    22  # Clone play example repo
    23  acbuild --debug run -- git clone https://github.com/ics-software-engineering/play-example-postgresql.git /play-example
    24  
    25  acbuild --debug run -- apt-get -y autoremove --purge git
    26  
    27  acbuild --debug run -- chown -R postgres:postgres /play-example
    28  
    29  STAGE_DIR=/play-example/target/universal/stage/
    30  TARGET_BIN="${STAGE_DIR}"/bin/play-example-postgresql
    31  
    32  # Build example
    33  acbuild --debug run -- /bin/bash -c 'cd /play-example && su postgres -c "./activator stage"'
    34  
    35  # Set user and group
    36  acbuild --debug set-user postgres
    37  acbuild --debug set-group postgres
    38  
    39  # Copy "wait for postgres" script
    40  acbuild --debug copy wait-for-postgres.sh /wait-for-postgres.sh
    41  
    42  # Run postgres server
    43  acbuild --debug set-exec /wait-for-postgres.sh 127.0.0.1 "${TARGET_BIN}"
    44  
    45  # Write the result
    46  acbuild --debug write --overwrite play-latest-linux-amd64.aci