I wanted to do the same as you - we run discourse on Amazon ECS, so we needed to be able to build just the web image and push it to a registry. I didn’t fancy hacking the discourse build process because we want to stay as close as possible to the supported install.
Instead, we use the normal launcher
script to build a two-container setup on a local machine, but ignore the data container and push the web container to the registry. At runtime we override the Postgres and Redis connection details via environment variables.
Deploying the new image is a 3-step process:
-
Run the safe pre-migrations. Get ECS to run this command (with the new image):
SKIP_POST_DEPLOYMENT_MIGRATIONS=1 rake db:migrate
-
Deploy the new image. Update the ECS service.
-
Run the post-migrations. Get ECS to run this command:
SKIP_POST_DEPLOYMENT_MIGRATIONS=0 rake db:migrate
Having a local data container run while we build the image is probably wasteful, but it means we can use the standard web.template.yml
without having to worry about which parts try to talk to the database or redis.