.ebextensions/02_container_commands.config
files:
"/home/ec2-user/migrations.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
docker run -e RDS_DB_NAME=$RDS_DB_NAME -e RDS_USERNAME=$RDS_USERNAME -e RDS_PASSWORD=$RDS_PASSWORD \
-e RDS_HOSTNAME=$RDS_HOSTNAME -e RDS_PORT=5432 -e RAILS_ENV=production -e DEVISE_SECRET_KEY=$DEVISE_SECRET_KEY \
-e REDIS_PORT_6379_TCP_ADDR=$REDIS_PORT_6379_TCP_ADDR \
-e REDIS_PORT_6379_TCP_PORT=$REDIS_PORT_6379_TCP_PORT \
-e CACHE_HOST=$CACHE_HOST \
-e CACHE_PORT=$CACHE_PORT \
-e AWS_REGION=$AWS_REGION \
-e AWS_SECRETS_MANAGER_PREFIX=$AWS_SECRETS_MANAGER_PREFIX \
aws_beanstalk/staging-app:latest bundle exec rake db:migrate champaign:seed_liquid
"/home/ec2-user/docker-housekeeping.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
# remove all stopped containers
docker rm $(docker ps -a -q)
# remove all unused images
docker rmi $(docker images | grep "^<none>" | tr -s ' ' | cut -d ' ' -f 3)
exit 0
container_commands:
01_add_pending_migrations:
command: /home/ec2-user/migrations.sh
leader_only: true
02_docker_housekeeping:
command: /home/ec2-user/docker-housekeeping.sh