2017 © Pedro Peláez
 

project service

12 factor service skeleton

image

fridaylabs/service

12 factor service skeleton

  • Wednesday, July 26, 2017
  • by neronmoon
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

12 factor php service skeleton

TL;DR

install

macOs: brew install docker, (*1)

Linux/Unix:, (*2)

apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-xenial main'
apt-get update
apt-get install docker-engine

use

make to build, (*3)

make dev to build and run local version, (*4)

Dev version will appear here: http://localhost:8081, (*5)

What's inside

  1. nginx
  2. php7.1 + php-fpm
  3. slim ^3.0
  4. supervisord to rule them all

12 factor Manifest

Codebase

Create project, (*6)

composer create-project fridaylabs/service -s dev --no-install --ignore-platform-reqs <SERVICE_NAME>

and push it to your repo, (*7)

Dependencies

Solved by composer, (*8)

Config

  1. All configs should be pulled from environment.
  2. Don't use variables like APPLICATION_ENVIRONMENT!
  3. Use .env file for local setup

Backing services

Use config for connecting with DB, Queue or other services, (*9)

Build, release, run

  1. Type make to build
  2. Type make dev to build and run local version
  3. TODO: Push your branch to run tests, merge branch to release

Processes

  1. Make sure, that your app is stateless.
  2. Store all your data into remote services

Port binding

  1. App exposing 80 and 443 port.
  2. Default dev port is 8081

Concurrency

Solved by php-fpm, (*10)

Disposability

Solved by supervisord, (*11)

Dev/prod parity

Solved by docker and composer, (*12)

Logs

  1. Nginx, php-fpm and app writes logs to stdout
  2. Don't write logs to FS

Admin processes

TODO, (*13)

The Versions

26/07 2017

dev-master

9999999-dev

12 factor service skeleton

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar neronmoon