diff --git a/.dockerignore b/.dockerignore index 4da1cec..e2ff740 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,4 @@ Dockerfile* docker-compose.yml vendor -tests +tests \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index a0ec54e..4ed981f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,8 +15,8 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # RUN apt-get update && apt-get install -y \ - gnupg git libnss3-tools \ - vim # for testing for now + gnupg git libnss3-tools gosu \ + vim net-tools procps # for testing for now @@ -49,9 +49,16 @@ RUN mkdir /.composer && \ chmod -R ugo+rw /.composer && \ chown -R "$USER" /.composer +COPY docker/Caddyfile /etc/caddy/Caddyfile +COPY --chown=$USER:$WWWGROUP docker/start-review-container /usr/local/bin/start-review-container + + RUN chown -R "$USER":${WWWGROUP} /data/caddy && \ chown -R "$USER":${WWWGROUP} /config/caddy && \ + chmod 770 /usr/local/bin/start-review-container && \ + chmod 444 /etc/caddy/Caddyfile && \ mkdir -p /var/www/.npm && chown -R $USER:$WWWGROUP /var/www/.npm && \ + mkdir -p /app/logs/laravel && \ chown -R $USER:$WWWGROUP /app @@ -69,3 +76,6 @@ RUN mkdir -p /app/storage/logs && \ npm run build RUN composer install --no-interaction --no-dev --prefer-dist --optimize-autoloader + + +CMD ["/usr/local/bin/start-review-container"] diff --git a/README.md b/README.md index d58e345..a324408 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,3 @@ -

Statamic Logo

+# Statamic in docker on heroku -## About Statamic - -Statamic is the flat-first, Laravel + Git powered CMS designed for building beautiful, easy to manage websites. - -> **Note:** This repository contains the code for the Statamic application. To contribute to the core package, visit the [Statamic core package repository][cms-repo]. - - -## Learning Statamic - -Statamic has extensive [documentation][docs]. We dedicate a significant amount of time and energy every day to improving them, so if something is unclear, feel free to open issues for anything you find confusing or incomplete. We are happy to consider anything you feel will make the docs and CMS better. - -## Support - -We provide official developer support on [Statamic Pro](https://statamic.com/pricing) projects. Community-driven support is available on the [forum](https://statamic.com/forum) and in [Discord][discord]. - - -## Contributing - -Thank you for considering contributing to Statamic! We simply ask that you review the [contribution guide][contribution] before you open issues or send pull requests. - - -## Code of Conduct - -In order to ensure that the Statamic community is welcoming to all and generally a rad place to belong, please review and abide by the [Code of Conduct](https://github.com/statamic/cms/wiki/Code-of-Conduct). - - -## Important Links - -- [Statamic Main Site](https://statamic.com) -- [Statamic Documentation][docs] -- [Statamic Core Package Repo][cms-repo] -- [Statamic Migrator](https://github.com/statamic/migrator) -- [Statamic Discord][discord] - -[docs]: https://statamic.dev/ -[discord]: https://statamic.com/discord -[contribution]: https://github.com/statamic/cms/blob/master/CONTRIBUTING.md -[cms-repo]: https://github.com/statamic/cms +Tests how to deploy a php statamic (frankenphp) container on heroku. \ No newline at end of file diff --git a/app.json b/app.json new file mode 100644 index 0000000..ce0a2b9 --- /dev/null +++ b/app.json @@ -0,0 +1,9 @@ +{ + "name": "Heroku statamic review apps test", + "repository": "https://github.com/rburgstaller/frankenphp-statamic", + "env": {}, + "addons": [], + "buildpacks": [], + "stack": "container" + } + \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 25103d1..ee4421d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,10 +8,11 @@ services: dockerfile: ./Dockerfile ports: # laravel - - '8002:443' + - '9999:9999' + - '2019:2019' environment: - PORT: 81 - #user: '33:33' + PORT: 9999 + # user: '33:33' networks: - fp-network networks: diff --git a/docker/Caddyfile b/docker/Caddyfile new file mode 100644 index 0000000..91c4fad --- /dev/null +++ b/docker/Caddyfile @@ -0,0 +1,59 @@ +{ + {$CADDY_GLOBAL_OPTIONS} + {$CADDY_GLOBAL_OPTIONS2} + + debug + + frankenphp { + #worker /path/to/your/worker.php + {$FRANKENPHP_CONFIG} + } + + # https://caddyserver.com/docs/caddyfile/directives#sorting-algorithm + order mercure after encode + order vulcain after reverse_proxy + order php_server before file_server + order php before file_server +} + +{$CADDY_EXTRA_CONFIG} + +:{$PORT:8080} { + bind 0.0.0.0 + + #log { + # # Redact the authorization query parameter that can be set by Mercure + # format filter { + # wrap console + # fields { + # uri query { + # replace authorization REDACTED + # } + # } + # } + #} + + root * public/ + encode zstd br gzip + + # Uncomment the following lines to enable Mercure and Vulcain modules + #mercure { + # # Transport to use (default to Bolt) + # transport_url {$MERCURE_TRANSPORT_URL:bolt:///data/mercure.db} + # # Publisher JWT key + # publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG} + # # Subscriber JWT key + # subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG} + # # Allow anonymous subscribers (double-check that it's what you want) + # anonymous + # # Enable the subscription API (double-check that it's what you want) + # subscriptions + # # Extra directives + # {$MERCURE_EXTRA_DIRECTIVES} + #} + #vulcain + + {$CADDY_SERVER_EXTRA_DIRECTIVES} + + php_server +} diff --git a/docker/start-review-container b/docker/start-review-container new file mode 100644 index 0000000..8fb4745 --- /dev/null +++ b/docker/start-review-container @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# here we can add the code to perform the db migration, db setup etc +php artisan migrate +php artisan db:seed +php artisan cache:clear + +echo "got port $PORT" + +export CADDY_GLOBAL_OPTIONS="http_port $PORT" +export SERVER_NAME="http://0.0.0.0:$PORT" + +# check what user and gid we have +echo "id follows $(id)" +echo "whoami follows $(whoami)" + +# exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf + +if [[ -n "${UID}" && "${UID}" -ne 33 ]]; then + echo "UID is set and is different from 33" + # usermod -u $UID www-data +else + echo "UID is not set or is equal to 33" +fi + + +if [ $# -gt 0 ]; then + echo "starting custom command $@" + exec gosu $WWWUSER "$@" +else + echo "starting entrypoint" +# exec gosu www-data /usr/local/bin/docker-php-entrypoint --config /etc/caddy/Caddyfile --adapter caddyfile + exec /usr/local/bin/docker-php-entrypoint --config /etc/caddy/Caddyfile --adapter caddyfile +fi