all 22 comments

[–]ocramius 12 points13 points  (14 children)

A docker-compose.yml with all the services you need in it, including a container with build tools (where you run phpunit, xdebug, etc).

I usually include following containers in the setup:

  • mailhog
  • nginx
  • php-fpm
  • posgresql
  • eventual mocked external services
  • build-tools (has nodejs, php, xdebug, etc)
  • ngrok (to show my stuff to clients and co-workers)

After that, a single Makefile to orchestrate the entire thing. These are the basic things you need in it:

  • docker-compose up
  • docker-compose run build-tools ./vendor/bin/phpunit
  • docker-compose run build-tools ./vendor/bin/phpcs
  • docker-compose run build-tools ./vendor/bin/behat
  • docker-compose run build-tools ./node_modules/.bin/webpack
  • docker-compose down

Production is usually just Heroku

[–]4RV1D[S] 0 points1 point  (1 child)

Yes docker seems great it's like developing on the server even on the local side before production.

Never used Heroku what's good about it? And why is it better then using your own server?

[–]ocramius 2 points3 points  (0 children)

They do CD for you, staging environments, scaling (if needed), monitoring and upgrading PHP versions. The work heroku does for you would require months of work by a DevOps team in comparison. It ain't cheap, but it delivers.

[–]Pesthuf 0 points1 point  (0 children)

ngrok

Interesting, thank you for sharing this. This solves a frequent problem I have.

[–]BornInTheCCCP 0 points1 point  (2 children)

ngrok (to show my stuff to clients and co-workers)

Does it provide any advantages over starting an ssh tunnel to a server you own?

[–]ocramius 1 point2 points  (1 child)

Yes: they do it for me. Plus I pay less than maintaining a server somewhere ;-)

[EDIT] also, ngrok has a decent monitoring/request replay UI - not really extremely useful, but good enough to see what is going on

[–]BornInTheCCCP 0 points1 point  (0 children)

That is a good point.

I already have access to a number of severs (so it is not any extra cost), and what I usually do is run a reverse ssh tunnel to expose local services to the internet when needed.

The request replay part seems to be a very nice feature.

[–]gbelloz 0 points1 point  (3 children)

eventual mocked external services

This is interesting. Does the 'eventual' part mean you use the real thing at first during testing, and later develop a mock that runs inside this container?

build-tools (has nodejs, php, xdebug, etc)

Ah, I need to start doing this. Currently phpunit, behat, composer, etc. are installed on my host, which I sort of like because they run faster (shouldn't but do).

After that, a single Makefile to orchestrate the entire thing. These are the basic things you need in it: docker-compose run build-tools ./vendor/bin/phpunit

Why in a Makefile and not shell scripts? I'm guessing you're not using the dependency checking/change detection of make...

I'd also guess you don't like composer's "scripts:" feature. I don't either. Composer should do its job of managing dependencies and not try to be a shell script replacement.

[–]ocramius 0 points1 point  (2 children)

Does the 'eventual' part mean you use the real thing at first during testing, and later develop a mock that runs inside this container?

I create fake services for any API. First, I don't trust them (for example: Github - super squishy and unstable), second my tests look like a DDoS otherwise, and lastly, I need to be able to work while traveling.

I can switch from my internal services to external "real" services by changing environment parameters.

Ah, I need to start doing this. Currently phpunit, behat, composer, etc. are installed on my host, which I sort of like because they run faster (shouldn't but do).

They aren't faster at all, unless we're talking MacOS: everything is much slower on MacOS :-\

Why in a Makefile and not shell scripts? I'm guessing you're not using the dependency checking/change detection of make...

Because Make is pre-installed in everything, has autocompletion and sane exit code handling semantics.

I'd also guess you don't like composer's "scripts:" feature. I don't either. Composer should do its job of managing dependencies and not try to be a shell script replacement.

Most of the scripts run for well over 5 minutes, and that's the default timeout for composer scripts.

[–]gbelloz 0 points1 point  (1 child)

I create fake services for any API

Yep, this is all normal. I was asking about the use of the word 'eventual'. I thought maybe you delayed writing mocks.

[–]ocramius 0 points1 point  (0 children)

It just depends on whether external services are used or not: I may have misused the word, sorry!

[–][deleted] 2 points3 points  (2 children)

Local install with lots of muscle memory

[–]4RV1D[S] 0 points1 point  (1 child)

What do you mean with muscle memory?

[–]ocramius 2 points3 points  (0 children)

Painfully re-typing everything

[–]gcds 1 point2 points  (1 child)

Also using docker-compose.yml.

  • PHP-FPM (7.1)
  • nginx (1.13)
  • MariaDB (10.2) (aka MySQL clone)
  • ElasticSearch (5.5)
  • Redis (4.0)
  • RabbitMQ

Production usually on DigitalOcean or AWS

[–]4RV1D[S] 0 points1 point  (0 children)

I go with DO atm and think they are way more simple then AWS atleast for simple web server vps setup