I wanted to share a quick tutorial I wrote on how to deploy simple PHP scripts to Hyper.sh. The whole article is available on my blog, but I'm also including the highlights here.
1. Build a PHP website that runs in Docker
In order to demonstrate Hyper.sh’s hosting, we’ll need to build a simple PHP application. Here’s a super simple PHP webpage:
<title>My PHP Website</title>
<h1>My PHP Website</h1>
<p>Here is some static content.</p>
<p><?php echo "Here is some dynamic content"; ?></p>
To run this sample PHP web app locally, run:
docker run --rm -p 8000:80 -v $(pwd):/var/www/html php:apache, and view your website locally at
2. Push to Docker Hub
Before we push the image to Docker Hub, we need to build the PHP project locally by creating a new Docker image. Add a Dockerfile to the root of the project:
COPY index.php /var/www/html/index.php
Once you’ve got the Dockerfile in the root directory with your
index.php file, build an image from the command line using your Docker Hub username:
docker build . -t <YOUR_USERNAME>/tiny-php-app.
Now push that image to Docker Hub:
docker push <YOUR_USERNAME>/tiny-php-app.
3. Run the container on Hyper.sh
Once you’ve logged in via the Hyper.sh CLI, you can go ahead and run your site:
hyper run -d -p 80:80 <YOUR_USERNAME>/tiny-php-app.
Hyper.sh will pull the latest version of the image and start up a new container, leaving you with the ID in your command line. To ensure the container is running, run
hyper ps to see a list of your running containers.
Next, you can allocate and assign an IP address:
hyper fip allocate 1
hyper fip attach <YOUR_IP> <YOUR_CONTAINER_ID>
Your tiny PHP application should now be hosted live on the web at
4. Updating the container
Finally, this is the script I use for updating the container:
# Build the updated image
docker build . -t <YOUR_USERNAME>/tiny-php-app
# Push to Docker hub
docker push <YOUR_USERNAME>/tiny-php-app
# Pull the latest on Hyper
hyper pull <YOUR_USERNAME>/tiny-php-app
# Kill the old container
hyper rm -f <OLD_CONTAINER_ID>
# Run the new one
hyper run -d -p 80:80 <YOUR_USERNAME>/tiny-php-app
# Attach the FIP
hyper fip hyper fip attach <YOUR_IP> <NEW_CONTAINER_ID>
If you've got anything to add or ideas for expanding on this tutorial (I know it's a very simple example so far), I'd love to hear it. This is really just a starting point, and I know there's a ton I didn't cover (databases, caching, hyper-compose, etc).