Sign inSign up

ttskch/nginx-php-fpm-heroku

By ttskch

•Updated over 8 years ago

Heroku Container Registry ready minimal image of Nginx + PHP-FPM on Alpine.

Image
0

2.7K

ttskch/nginx-php-fpm-heroku repository overview

⁠nginx-php-fpm-heroku

Minimal image of Nginx + PHP-FPM running on Alpine.

With this image šŸ‘ you can deploy your PHP project to Heroku via Container Registry⁠ šŸ‘ because layer count and image size are decreased as much as possible to meet Heroku's restriction⁠.

⁠Usage

⁠1. Add Dockerfile into your PHP project

This is just an example. It's of course ready for Composer.

$ cd /path/to/your-php-project
$ tree .
.
ā”œā”€ā”€ index.php
└── Dockerfile

0 directories, 3 files
<?php
// index.php
echo 'Hello, Heroku Container Registry!';
# Dockerfile
FROM ttskch/nginx-php-fpm-heroku

# as will be described later, just for local development
USER nonroot
⁠2. Deploy to Heroku
$ heroku login
$ heroku container:login
$ heroku create {appname}
$ heroku container:push web
$ heroku open

Then you can see 'Hello, Heroku Container Registry!' on https://{appname}.herokuapp.com

⁠Local development

Of course you can run your app locally on this image too.

$ docker build . -t {sometag}
$ docker run -p {port}:8888 -v $(pwd):/docroot {sometag}

Or

$ heroku container:push web
$ docker run -p {port}:8888 -v $(pwd):/docroot registry.heroku.com/{appname}/web

Then browse http://localhost:{port}⁠

⁠More examples

See examples⁠.

⁠What's special?

  • Less number of layers
  • Small image size
  • Nginx correctly listens to $PORT which set by Herkou web dyno on runtime
  • As Heroku recommends⁠, can run as non-root user locally (Many permission problems are solved)

⁠Getting involved

Feel free to send Pull Request for

Tag summary

Content type

Image

Digest

Size

35.5 MB

Last updated

over 8 years ago

docker pull ttskch/nginx-php-fpm-heroku