-
Notifications
You must be signed in to change notification settings - Fork 1
/
test-build.sh
executable file
·63 lines (48 loc) · 2.19 KB
/
test-build.sh
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
#!/usr/bin/env bash
#### halt script on error
set -xe
echo '##### Print docker version'
docker --version
echo '##### Print environment'
env | sort
assert_site() {
wget -O - $1 | if grep -q $2; then echo "found $2"; else echo "$2 not found"; exit 1; fi
}
#### Build the Docker Images
if [ -n "${MY_RUBY_VERSION}" ]; then
cp env.example .env
sed -i -- "s/MY_RUBY_VERSION=.*/MY_RUBY_VERSION=${MY_RUBY_VERSION}/g" .env
sed -i -- "s/RUBY_RAILS_VERSION=.*/RUBY_RAILS_VERSION=${RUBY_RAILS_VERSION}/g" .env
sed -i -- 's/=false/=true/g' .env
cat .env
cp docker-compose.cached.yml docker-compose.override.yml
docker-compose build ruby
docker images
docker-compose run ruby gem install rails -v $RUBY_RAILS_VERSION
sed -i -- "s/APP=.*/APP=myapp/g" .env
sed -i -- "s/RUBY_DB_ADAPTER=.*/RUBY_DB_ADAPTER=postgresql/g" .env
sed -i -- "s/RUBY_DB_HOST=.*/RUBY_DB_HOST=postgres/g" .env
sed -i -- "s/RUBY_DB_PORT=.*/RUBY_DB_PORT=5432/g" .env
docker-compose run ruby rails-new myapp postgresql
docker-compose up -d ruby postgres redis elasticsearch
docker-compose run ruby env
docker-compose run ruby bash -c 'cd myapp && dockerize --wait tcp://postgres:5432 echo "postgresql is ready"'
docker-compose run ruby bash -c 'cd myapp && bin/rails db:create'
docker-compose run ruby bash -c 'cd myapp && bin/rails db:migrate'
docker-compose run ruby bash -c 'cd myapp && bin/rails db:setup'
assert_site http://localhost:3000 '5.1.4'
docker-compose down -v
sed -i -- "s/APP=.*/APP=myapp2/g" .env
sed -i -- "s/RUBY_DB_ADAPTER=.*/RUBY_DB_ADAPTER=mysql2/g" .env
sed -i -- "s/RUBY_DB_HOST=.*/RUBY_DB_HOST=mysql/g" .env
sed -i -- "s/RUBY_DB_PORT=.*/RUBY_DB_PORT=3306/g" .env
docker-compose run ruby rails-new myapp2 mysql
docker-compose up -d ruby mysql redis elasticsearch
docker-compose run ruby env
docker-compose run ruby bash -c 'cd myapp2 && dockerize --wait tcp://mysql:3306 -timeout 1m echo "mysql is ready"'
docker-compose run ruby bash -c 'cd myapp2 && bin/rails db:create'
docker-compose run ruby bash -c 'cd myapp2 && bin/rails db:migrate'
docker-compose run ruby bash -c 'cd myapp2 && bin/rails db:setup'
assert_site http://localhost:3000 '5.1.4'
docker-compose down -v
fi