Skip to content

Instantly share code, notes, and snippets.

@marsyang1
Last active August 29, 2015 14:25
Show Gist options
  • Select an option

  • Save marsyang1/efdc30dcf6d73f750c2a to your computer and use it in GitHub Desktop.

Select an option

Save marsyang1/efdc30dcf6d73f750c2a to your computer and use it in GitHub Desktop.
12FactorAppInJava
I. Codebase
One codebase tracked in revision control, many deploys
1.Use VCS( Git, Mercurial, or Subversion. )
2.1 app 1 code repository
3.1 app 1 or many deploy(production , testing , develop1 , develop2 ...)
4.deploy can be different version , but from same code repo.
II. Dependencies
Explicitly declare and isolate dependencies
1. use maven,ivy or gradle to manage dependencies.
2. use sonar nexus will be plus
III. Config
Store config in the environment
1. less CONFIG IN AP Server setting
2. use properties
3. config store
1. Resource handles to the database, Memcached, and other backing services
2. Credentials to external services such as Amazon S3 or Twitter
3. Per-deploy values such as the canonical hostname for the deploy
4. -> Config varies substantially ACROSS deploys, code does not.
5. “config” does not include internal application config
1. Spring java config(@Configuration,application-context.xml)
6. Database can like ruby config/database.yml(http://stackoverflow.com/questions/5872264/correct-mysql-configuration-for-ruby-on-rails-database-yml-file)
7. STORE config file path in environment variables.
8. discuess
1. (http://redd.it/2n122s , http://redd.it/2r38xr)
2. http://movingfast.io/articles/environment-variables-considered-harmful/
3. https://gist.github.com/telent/9742059
4. https://spring.io/blog/2015/01/13/configuring-it-all-out-or-12-factor-app-style-configuration-with-spring
8. example
1. http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Java.managing.html#create_deploy_Java.managing.accessing
2. http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-options
3. http://blog.doismellburning.co.uk/2014/10/06/twelve-factor-config-misunderstandings-and-advice/
IV. Backing Services
Treat backing services as attached resources
V. Build, release, run
Strictly separate build and run stages
VI. Processes
Execute the app as one or more stateless processes
VII. Port binding
Export services via port binding
VIII. Concurrency
Scale out via the process model
IX. Disposability
Maximize robustness with fast startup and graceful shutdown
X. Dev/prod parity
Keep development, staging, and production as similar as possible
XI. Logs
Treat logs as event streams
XII. Admin processes
Run admin/management tasks as one-off processes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment