Build Ember CLI application for Docker

Hey,

I would like to run my Ember app in different environments/stages but with the same docker image. Until now I just compiled the app with the -prod flag and copied dist into my nginx image, but now I would like to use this image for production and staging and I need different configurations.

I am playing around with installing Ember CLI into my docker container so right now I am able to build the app with the --environment flag depending on an ENV variable upon container start-up and afterwards the dist directory is copied to the nginx root. This makes things more flexible but the container size exploded and the build itself is more complicated and thus possibly more error-prone.

I am wondering what is the preferred way to do that? In theory, the only thing that changes is the configuration in the index.html, so maybe I should pre-build all possible environments and copy the index.html(s) to the container?

1 Like

Perhaps use ember-cli-deploy. I use it to deploy to Cloudant but with plugins like ember-cli-deploy-cp you can copy to docker. You can use ember-cli-deploy-build-plus to create a robots.txt for staging.

How does that solve my problem? I still have to build the app inside the docker container right?

I mean, I was more looking for a best practice instead of yet another plugin :slight_smile:

No I think you should develop outside docker and deploy your application to docker.

I wrote an article How to dockerize an Ember app. The solution uses a single dockerfile and docker-compose to bring up the application stack in development and production; however, the production side of the tutorial isn’t detailed because production environments vary depending on who you talk to. Perhaps this is a good place for you to start?

No but thanks anyway :slight_smile:

Could You clarify? You want:

a)development env inside docker container b)test/QA/prod in docker containers.
c)both of the above?
d)multiple containers sourced from single image and ember app source code

Tips for a) will be different then for b)

We use Docker + Ember + Loopback JSON API here: GitHub - tsteuwer/emberloop: EmberJS and Loopback together in a single repository. It includes Docker support, as well as simple scripts that allow you to use all the functionality of Ember CLI and Loopback.

I guess the best way to configure compiled Ember app I found here: ember.js - Managing Configurations After Building Ember Application - Stack Overflow