Deploying Gastropoda to Amazon Web Services - Never Forget

After my last blog post I decided that it was time to deploy Gastropoda to Amazon Web Services - namely Elastic Beanstalk, which utilizes an EC2 instance (reserved) and an RDS DB instance.

I started last Saturday. I’ve just now gotten something running that seems on par with what I have on my vagrant box. I have decided to put together a post of random tips for myself so that I never have to go through this nightmare again the next time I have to set up a new Elastic Beanstalk app or environment.

I started off mostly following these very helpful Laravel deployment instructions. These set me off on the right track, but there were so many obstacles that I ran into that just following this wasn’t really enough.


Differences from instructions above

$env = $app->detectEnvironment(array(

	'local' => array('homestead'),
	'development' => array('hostnamehere'),



      command: "php artisan migrate --env=development --force"
      command: "php artisan db:seed --force"

Migrating and Seeding Database

class RaceTerrainTableSeeder extends Seeder {

    public function run()

        $statement = "
                        ALTER TABLE race_terrains AUTO_INCREMENT = 1;

        			'name' => 'Plastic Tabletop',
        			'description' => 'A smooth, plastic tabletop - lightly misted with water'  			


The $statement above is very important. Before I added this, the auto-incremeneted primary key would keep counting up from the previous batch each time I deployed a new version of the app. This broke everything, since I had code and other tables referring specifically to various IDs. This makes sure the IDs increment back from 1 each time the table is seeded.

Cron job

      command: "/usr/bin/composer.phar dump-autoload --optimize"
      command: "cat .ebextensions/dispatcherJob.txt > /etc/cron.d/dispatcherJob && chmod 644 /etc/cron.d/dispatcherJob"
      leader_only: true
* * * * * root /usr/bin/php /var/www/html/artisan scheduled:run > /dev/null

Logs and Storage

      command: sudo chmod -R 777 /var/www/html/app/storage

More most likely to come…

© - 2021 · Liza Shulyayeva ·