7

I am working on an Angular2 project with Yii2 (PHP/MySQL) as its API point. We will need to deploy the Angular app in different languages for different customers (using AOT compilation from angular-cli).

What is the best way to achieve this? I am looking at Docker or Ansible(-container) to make this work. But the examples are mainly for a 1:1 setup. But I would need a 1:n, something like:

deploy app-de new_costomer prod_server

Additional to that, when a new version of the app is available i want to update the entire network with the new app (that requires uploading of the src/ folder AOT compiled, and db migration scripts on the Yii2 side).

Ideally it would do something like:

deploy update network-all prod_server

Any ideas?

To clarify: I have a number of customers, each customer should get its own container (docker, through ansible-container). There is the AOT compiled Angular stuff (just JS) and the PHP backend with MySQL.

Each customer gets this setup on a server (so 3 customers = 3 docker containers with the Angular + PHP + MySQL).

We push updates to both Angular and PHP quite frequently (i.e. the entire DIST folder needs to be uploaded or at least a diff, migrations scripts for the PHP/MySQL backend needs to run, etc.).

And this from one command (because I obviously do not want to have SSH into each container to do all that semi-manually).

Since I have never done this kind of setup before, I would like to get some ideas on how this can achieved with things like Ansible (or the like).

6
  • It's not very clear what you're asking for. It sounds like your general issue is internationalization. That is typically an application design issue, not a deployment issue. You could deploy different languages as separate containers, but I'm not sure that would be the simplest or most efficient solution. Mar 2, 2017 at 15:24
  • 2
    Looks like a copy-pasted question from another site, including the SE links and icons around the question. Fix the formatting and please make this question clear to understand and to answer. Mar 2, 2017 at 15:51
  • 1
    Hey @Evgeny, yes it was copied from my post on Stackexchange, where someone commented on this and told me to take it over here. Hence the dupliciation. I updated the issue above.
    – axtho
    Mar 3, 2017 at 18:20
  • @axtho Cross-posting is generally discouraged—you should either have the post on this site or on Stack Overflow, not both. That's probably why your question hasn't been received very well.
    – Aurora0001
    Mar 3, 2017 at 18:24
  • Better with the edit , don't specify "edit " looking at revision we can know what have been added and in the review queu the changes are highlighted. voting to reopen
    – Tensibai
    Mar 3, 2017 at 22:43

1 Answer 1

7

Let's assume you have the following scenario: You have many customers, but most use the exact same app, except for some configuration changes. You would like each of your customer to get the latest of the app ASAP.

If this is your scenario then try make everything that needs to be differentiated between the apps a configuration change. You build one (or one set of) docker containers that can handle any of your customer based on the configuration it was given. Then on deployment time you simply supply the proper configurations for this container for each of your customer.

The benefit of this approach is that you don't really incur massive overheads when a new customer comes. You generate their configuration, create the new servers, add some entries into an inventory file, and the next time you deploy, it gets there as well. The more well your CD pipeline is set up the more you can automate any of this process.

So how would the flow generally look like:

  1. You have your application codebase, that can cater for all of your customers
  2. You build the docker container for your application (one for the frontend, one for the backend, possibly a few more supporting ones)
  3. You have a deployment script that uses a configuration file to determine where to deploy and what.
  4. You run this deployment script. It will go over all of your customers, and simply deploy the latest version of your app with the appropriate config.

If you have a new customer, the only place you have to change is the deployment configuration file. If you are using ansible most likely you have to change your inventory and your vars file. Let's say you have get a new customer, who would like the app to run under Spanish locale, and has access to the beta features. This customer's configuration would maybe look like this:

config.js:

SETTINGS = { locale: 'es', beta: true };

config.php:

define('CUSTOMER_LOCALE','es');
define('CUSTOMER_BETA','true');

You then make sure that during deployment your container gets these files mounted on startup.

2
  • Thanks. That is, mainly, what I need and a good starting point. Out of curiosity: why would you suggest many docker images for one customer?
    – axtho
    Mar 7, 2017 at 9:52
  • @axtho not mandatory, although it's usually a good practice to separate each concern (frontend, backend, database, etc.) into a separate container, so they can be deployed and scaled independently
    – SztupY
    Mar 7, 2017 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.