Skip to content

Commit 2f54f0c

Browse files
refactor: streamline scripts
1 parent a38882b commit 2f54f0c

File tree

8 files changed

+84
-127
lines changed

8 files changed

+84
-127
lines changed

script/-check-docker-compose

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
# script/bootstrap: Resolve all dependencies that the application requires to
4+
# run.
5+
6+
set -e
7+
cd "$(dirname "$0")/.."
8+
9+
10+
if ! docker-compose ps -q app > /dev/null; then
11+
echo "No server running yet, run ./script/server to launch"
12+
exit 1
13+
fi

script/bootstrap

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1-
# See https://github.com/github/scripts-to-rule-them-all
2-
#
3-
# script/bootstrap is used solely for fulfilling dependencies of the project.
4-
#
5-
# The goal is to make sure all required dependencies are installed.
1+
#!/bin/sh
62

7-
set -eu -o pipefail
8-
shopt -s failglob
3+
# script/bootstrap: Resolve all dependencies that the application requires to run.
94

10-
docker-compose pull
5+
set -e
6+
cd "$(dirname "$0")/.."
7+
8+
9+
echo
10+
echo "==> Verifying docker and docker-compose…"
11+
12+
if ! [ -x "$(command -v docker)" ]; then
13+
echo "Please install docker"
14+
exit 1
15+
fi
16+
17+
if ! [ -x "$(command -v docker-compose)" ]; then
18+
echo "Please install docker-compose"
19+
exit 1
20+
fi
21+
22+
if ! docker info > /dev/null 2>&1; then
23+
echo "Docker engine is not running, or your user does not have access to connect."
24+
echo "Try starting Docker, adding your user to the docker group, or running this command with sudo"
25+
exit 1
26+
fi

script/cibuild

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
1-
# See https://github.com/github/scripts-to-rule-them-all
2-
#
3-
# script/cibuild is used for your continuous integration server.
4-
# This script is typically only called from your CI server.
5-
#
6-
# You should set up any specific things for your environment here
7-
# before your tests are run. Your test are run simply by calling script/test.
1+
#!/bin/sh
82

9-
set -eu -o pipefail
10-
shopt -s failglob
3+
# script/cibuild: Build production deployment artifact
114

12-
scripts/test
5+
set -e
6+
cd "$(dirname "$0")/.."
137

14-
docker build -t upenn/chime .
158

16-
# FUTURE - should the container be pushed anywhere?
9+
script/bootstrap
10+
11+
echo
12+
echo "==> Building and tagging container…"
13+
docker build -t codeforphilly/chime .

script/console

Lines changed: 0 additions & 39 deletions
This file was deleted.

script/server

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
1-
# See https://github.com/github/scripts-to-rule-them-all
2-
#
3-
# script/server is used to start the application.
4-
#
5-
# For a web application, this might start up any extra processes
6-
# that the application requires to run in addition to itself.
7-
#
8-
# script/update should be called ahead of any application booting
9-
# to ensure that the application is up to date and can run appropriately.
1+
#!/bin/sh
102

3+
# script/server: Launch the application and any extra required processes
4+
# locally.
115

12-
set -eu -o pipefail
13-
shopt -s failglob
6+
set -e
7+
cd "$(dirname "$0")/.."
148

15-
docker-compose up -d
9+
10+
script/bootstrap
11+
12+
if [ ! -f ".env" ]; then
13+
echo
14+
echo "==> Initializing .env…"
15+
cp .env.example .env
16+
fi
17+
18+
echo
19+
echo "==> Loading .env…"
20+
set -o allexport; source .env; set +o allexport
21+
22+
echo
23+
echo "==> Starting containers with docker-compose…"
24+
docker-compose up -d --build
25+
26+
echo
27+
echo "==> App is now ready to go!"
28+
echo " *Open http://localhost:${PORT}"
29+
echo

script/setup

Lines changed: 0 additions & 15 deletions
This file was deleted.

script/test

Lines changed: 0 additions & 25 deletions
This file was deleted.

script/update

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
# See https://github.com/github/scripts-to-rule-them-all
2-
#
3-
# script/update is used to update the project after a fresh pull.
4-
#
5-
# If you have not worked on the project for a while,
6-
# running script/update after a pull will ensure that everything
7-
# inside the project is up to date and ready to work.
8-
#
9-
# Typically, script/bootstrap is run inside this script.
10-
# This is also a good opportunity to run database migrations
11-
# or any other things required to get the state of the app into
12-
# shape for the current version that is checked out.
1+
#!/bin/sh
132

14-
set -eu -o pipefail
15-
shopt -s failglob
3+
# script/update: Update application to run for its current checkout.
164

17-
docker-compose down
18-
scripts/bootstrap
5+
set -e
6+
cd "$(dirname "$0")/.."
7+
8+
9+
script/bootstrap
10+
script/-check-docker-compose
11+
12+
echo
13+
echo "==> Rebuilding containers…"
14+
docker-compose up -d --build

0 commit comments

Comments
 (0)