Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@igorescobar
Created February 16, 2016 20:21
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save igorescobar/310633f985b407c13b1d to your computer and use it in GitHub Desktop.
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)
#!/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