Created
February 16, 2016 20:21
-
-
Save igorescobar/310633f985b407c13b1d to your computer and use it in GitHub Desktop.
The correct way to run rails db migration on AWS Beanstalk (Docker Container Environment)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# .ebextensions/scripts/db_migrate.sh | |
. /opt/elasticbeanstalk/hooks/common.sh | |
EB_SUPPORT_FILES=$(/opt/elasticbeanstalk/bin/get-config container -k support_files_dir) | |
EB_CONFIG_DOCKER_ENV_ARGS=() | |
while read -r ENV_VAR; do | |
EB_CONFIG_DOCKER_ENV_ARGS+=(--env "$ENV_VAR") | |
done < <($EB_SUPPORT_FILES/generate_env) | |
echo "Running migrations for aws_beanstalk/staging-app" | |
docker run --rm "${EB_CONFIG_DOCKER_ENV_ARGS[@]}" -t aws_beanstalk/staging-app bundle exec rake db:migrate || echo "The Migrations failed to run." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment