Skip to content

Instantly share code, notes, and snippets.

@jordanbrauer
Created August 6, 2021 18:11
Show Gist options
  • Save jordanbrauer/1b9a228605514b7f96d8f5a10af8b7ad to your computer and use it in GitHub Desktop.
Save jordanbrauer/1b9a228605514b7f96d8f5a10af8b7ad to your computer and use it in GitHub Desktop.
Earthly PHP Example
FROM php:8.0-fpm-alpine
WORKDIR /var/www
build:
COPY index.php .
SAVE ARTIFACT index.php /index.php
docker:
COPY +build/index.php .
ENTRYPOINT php /var/www/index.php
SAVE IMAGE php-example:latest
<?php
declare(strict_types = 1);
echo 'hello world';
@jordanbrauer
Copy link
Author

  1. Install Earthly;
  2. Save the Earthfile and index.php in some directory on your host;
    • Alternatively, run this to simply fetch the files with curl;
    mkdir php-earthly && cd $_ \
      && curl https://gist.githubusercontent.com/jordanbrauer/1b9a228605514b7f96d8f5a10af8b7ad/raw/59dfe698da90e522098c5efe3a9423839fcc1ccc/Earthfile > Earthfile \
      && curl https://gist.githubusercontent.com/jordanbrauer/1b9a228605514b7f96d8f5a10af8b7ad/raw/59dfe698da90e522098c5efe3a9423839fcc1ccc/index.php > index.php;
  3. Execute the following and be greeted from an Earthly PHP build;
    earthly +docker
    docker run --rm php-example:latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment