Skip to content

ttskch/docker-nginx-php-fpm-heroku

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  • Fixing bug or enhancement
  • Adding some examples

Releases

No releases published

Packages

No packages published

Languages