Build Ember CLI application for Docker


#1

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?


#2

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.


#3

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:


#4

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


#5

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?


#6

No but thanks anyway :slight_smile:


#7

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)


#8

We use Docker + Ember + Loopback JSON API here: https://github.com/tsteuwer/emberloop


#9

I guess the best way to configure compiled Ember app I found here: https://stackoverflow.com/a/38214438/255633