-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcontainer
More file actions
executable file
·86 lines (68 loc) · 1.89 KB
/
container
File metadata and controls
executable file
·86 lines (68 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
# Name of image & container.
image_name='forthecity-client-ruby'
container_name='forthecity-client-ruby'
# Make environment variables available
source env.sh
# Build docker image based on Dockerfile, if creating or starting container.
if [ "$1" = "-c" ]; then
echo "Building $image_name image..."
docker build -t "$image_name" .
fi
# -h
# Print help.
if [ "$1" = "-h" ]; then
help_output= cat <<HelpText
APP DOCKER MANAGER
This script manages Docker for this application. It may need to be run as
the root user on your system. The create, test, start & restart flags attempt
to build or rebuild the image based on the Dockerfile before executing.
ARGUMENTS
-h
Prints help text.
-c
Creates an image based the Dockerfile.
-t
Runs the test suite for the application & Rubocop.
-lt
Runs Rubocop.
--interactive
Runs an interactive container.
--status
Shows status of the container.
HelpText
echo $help_output
fi
# -c
# Creates & runs the container.
if [ "$1" = "-c" ]; then
echo "Creating $containter_name image"
fi
# -t
# Run tests.
if [ "$1" = "-t" ]; then
docker run --rm -t -v $PWD:/opt/app -e HOST=$HOST -e PORT=$PORT \
-e TOKEN=$TOKEN -e SECRET=$SECRET --link forthecity-api:api \
$image_name /bin/bash -c \
"bundle exec rspec; bundle exec rubocop --require rubocop-rspec"
fi
# -lt
# Run tests.
if [ "$1" = "-lt" ]; then
docker run --rm -t -v $PWD:/opt/app -e HOST=$HOST -e PORT=$PORT \
-e TOKEN=$TOKEN -e SECRET=$SECRET --link forthecity-api:api \
$image_name /bin/bash -c \
"bundle exec rubocop --require rubocop-rspec"
fi
# --interactive
# Run interactive container
if [ "$1" = "--interactive" ]; then
docker run --rm -i -t -v $PWD:/opt/app -e HOST=$HOST -e PORT=$PORT \
-e TOKEN=$TOKEN -e SECRET=$SECRET \
--link forthecity-api:api $image_name /bin/bash
fi
# --status
# Shows status.
if [ "$1" = "--status" ]; then
docker ps -a --filter "name=$container_name"
fi