/
buildspec.yml
69 lines (61 loc) · 1.91 KB
/
buildspec.yml
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
version: 0.2
env:
variables:
RACK_ENV: test
RAILS_ENV: test
RAILS_SERVE_STATIC_FILES: enabled
PGHOST: 127.0.0.1
PGUSER: postgres
PGPASSWORD: postgres
phases:
install:
runtime-versions:
ruby: 2.7
nodejs: 12
commands:
# Upgrade AWS CLI to the latest version
- pip3 install --upgrade awscli
# Install Ruby dependencies from the Gemfile.
- gem install bundler
- bundle install
# Install Yarn dependencies from package.json.
- bundle exec yarn
# Run Postgres
- >-
docker run
-d
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
-p 5432:5432
-e POSTGRES_PASSWORD=postgres
postgres
# Run Redis
- >-
docker run
-d
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
-p 6379:6379
redis
# Set up database
- bundle exec rails db:setup
pre_build:
commands:
# Set the SECRET_KEY_BASE environment variable for running tests
- export SECRET_KEY_BASE=$(rake secret)
# Run the tests using Rake.
- bundle exec rake
post_build:
commands:
- aws cloudformation package --template template.yml --s3-bucket $S3_BUCKET --output-template-file template-export.yml
# Do not remove this statement. This command is required for AWS CodeStar projects.
# Update the AWS Partition, AWS Region, account ID and project ID in the project ARN on template-configuration.json file so AWS CloudFormation can tag project resources.
- sed -i.bak 's/\$PARTITION\$/'${PARTITION}'/g;s/\$AWS_REGION\$/'${AWS_REGION}'/g;s/\$ACCOUNT_ID\$/'${ACCOUNT_ID}'/g;s/\$PROJECT_ID\$/'${PROJECT_ID}'/g' template-configuration.json
artifacts:
files:
- template-export.yml
- template-configuration.json