├── .editorconfig ├── .github └── workflows │ ├── 00-s6-overlay.yml │ ├── 01-php.yml │ ├── 02-servers.yml │ ├── 03-apps.yml │ ├── build-all.yml │ ├── template-common.yml │ └── template-php.yml ├── .gitignore ├── .gitmodules ├── .vscode └── settings.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── SECURITY.md ├── _config.yml ├── build ├── .secrets.example ├── config.sh └── helpers.sh ├── src ├── dummy.dockerfile ├── dummy.md ├── php │ ├── .dockerignore │ ├── base-os.dockerfile │ ├── base-os.md │ ├── base-php.dockerfile │ ├── base-s6.dockerfile │ ├── base-s6.md │ ├── common │ │ ├── docker-php-entrypoint │ │ ├── os-base.dockerfile │ │ ├── os-crontab.dockerfile │ │ ├── os-s6-overlay.dockerfile │ │ ├── php-composer.dockerfile │ │ ├── php-extensions.dockerfile │ │ ├── php-ini-directives.dockerfile │ │ ├── rootfs │ │ │ ├── etc │ │ │ │ ├── cont-init.d │ │ │ │ │ └── 00-bootstrap │ │ │ │ ├── hooks │ │ │ │ │ ├── bootstrap │ │ │ │ │ │ ├── 00-bootstrap │ │ │ │ │ │ ├── 10-create-conf │ │ │ │ │ │ ├── 10-create-project │ │ │ │ │ │ ├── 10-missing-index │ │ │ │ │ │ ├── 50-autorun │ │ │ │ │ │ ├── 50-crontabs │ │ │ │ │ │ ├── 50-sendmail │ │ │ │ │ │ └── 99-other-fixes │ │ │ │ │ ├── cleanup │ │ │ │ │ │ ├── 00-php-source │ │ │ │ │ │ ├── 00-pkgs │ │ │ │ │ │ ├── 00-upgrade │ │ │ │ │ │ └── zz-clean-tmp │ │ │ │ │ └── onbuild │ │ │ │ │ │ └── 00-greeting │ │ │ │ └── welcome.txt │ │ │ ├── license │ │ │ ├── startup │ │ │ │ └── 99-greeting │ │ │ └── usr │ │ │ │ └── local │ │ │ │ ├── bin │ │ │ │ ├── app-path │ │ │ │ ├── app-root │ │ │ │ ├── debug-echo │ │ │ │ ├── env-default │ │ │ │ ├── greeting │ │ │ │ ├── has-cmd │ │ │ │ ├── has-s6 │ │ │ │ ├── is-debug │ │ │ │ ├── is-true │ │ │ │ ├── log-path │ │ │ │ ├── os-name │ │ │ │ └── vergte │ │ │ │ └── sbin │ │ │ │ ├── autorun │ │ │ │ ├── cleanup │ │ │ │ ├── hook │ │ │ │ ├── mkcert │ │ │ │ ├── pkg-add │ │ │ │ ├── pkg-del │ │ │ │ ├── s6-service │ │ │ │ ├── web-chown │ │ │ │ ├── web-cmd │ │ │ │ ├── web-do │ │ │ │ ├── web-mkdir │ │ │ │ └── with-env │ │ └── shell-php │ │ │ ├── php-envvars │ │ │ ├── phpaddmod │ │ │ └── phpdelmod │ ├── meta.dockerfile │ ├── with-apache.dockerfile │ ├── with-apache.md │ ├── with-apache │ │ ├── apache-config.dockerfile │ │ ├── apache-install.dockerfile │ │ └── rootfs │ │ │ ├── etc │ │ │ ├── apache2 │ │ │ │ ├── apache2.conf │ │ │ │ └── sites-enabled │ │ │ │ │ └── 00-default.conf │ │ │ └── cont-init.d │ │ │ │ └── zz-start-apache │ │ │ └── usr │ │ │ └── local │ │ │ └── sbin │ │ │ ├── a2dismod │ │ │ ├── a2enmod │ │ │ ├── apache-conf │ │ │ ├── apache-mpm │ │ │ └── apache-test │ ├── with-f8p.dockerfile │ ├── with-f8p.md │ ├── with-f8p │ │ ├── f8p-config.dockerfile │ │ ├── f8p-install.dockerfile │ │ └── rootfs │ │ │ ├── etc │ │ │ ├── caddy │ │ │ │ └── Caddyfile │ │ │ └── cont-init.d │ │ │ │ └── zz-start-f8p │ │ │ └── usr │ │ │ └── local │ │ │ └── bin │ │ │ └── f8p-conf │ ├── with-nginx.dockerfile │ ├── with-nginx.md │ ├── with-nginx │ │ ├── nginx-config.dockerfile │ │ ├── nginx-install.dockerfile │ │ └── rootfs │ │ │ ├── etc │ │ │ ├── cont-init.d │ │ │ │ └── zz-start-nginx │ │ │ └── nginx │ │ │ │ ├── custom.d │ │ │ │ ├── 00-ext-brotli.conf │ │ │ │ ├── 00-ext-gzip.conf │ │ │ │ ├── 00-ext-http3.conf │ │ │ │ └── 01-common.conf │ │ │ │ ├── nginx.conf │ │ │ │ └── sites-enabled │ │ │ │ └── 00-default.conf │ │ │ └── usr │ │ │ └── local │ │ │ └── bin │ │ │ ├── nginx-conf │ │ │ └── nginx-test │ ├── with-roadrunner.dockerfile │ ├── with-roadrunner.md │ ├── with-roadrunner │ │ ├── roadrunner-config.dockerfile │ │ ├── roadrunner-install.dockerfile │ │ └── rootfs │ │ │ ├── etc │ │ │ └── cont-init.d │ │ │ │ └── zz-start-roadrunner │ │ │ ├── source │ │ │ ├── .rr.yaml │ │ │ ├── composer.json │ │ │ └── index.php │ │ │ └── usr │ │ │ └── local │ │ │ └── bin │ │ │ └── roadrunner-conf │ ├── with-unit.dockerfile │ ├── with-unit.md │ └── with-unit │ │ ├── rootfs │ │ ├── etc │ │ │ ├── cont-init.d │ │ │ │ └── zz-start-unit │ │ │ └── unit │ │ │ │ └── sites-enabled │ │ │ │ └── 00-default.json │ │ └── usr │ │ │ └── local │ │ │ └── bin │ │ │ └── unit-conf │ │ ├── unit-config.dockerfile │ │ └── unit-install.dockerfile └── webapps │ ├── bedrock │ ├── README.md │ ├── bedrock.dockerfile │ └── rootfs │ │ └── startup │ │ └── boot-bedrock │ ├── cakephp4 │ ├── README.md │ ├── cakephp4.dockerfile │ └── rootfs │ │ └── startup │ │ └── boot-cakephp4 │ ├── cakephp5 │ ├── README.md │ ├── cakephp5.dockerfile │ └── rootfs │ │ └── startup │ │ └── boot-cakephp5 │ ├── codeigniter4 │ ├── README.md │ ├── codeigniter4.dockerfile │ └── rootfs │ │ └── startup │ │ └── boot-codeigniter4 │ ├── coolify │ ├── README.md │ ├── coolify.dockerfile │ └── rootfs │ │ ├── etc │ │ └── hooks │ │ │ └── post-package-update │ │ │ └── 00-coolify-env │ │ └── startup │ │ └── boot-coolify │ ├── drupal │ ├── README.md │ ├── drupal.dockerfile │ └── rootfs │ │ └── startup │ │ └── boot-drupal │ ├── espocrm │ ├── README.md │ ├── espocrm.dockerfile │ └── rootfs │ │ ├── etc │ │ └── apache2 │ │ │ └── custom.d │ │ │ ├── espocrm-websocket.conf │ │ │ └── espocrm.conf │ │ └── startup │ │ └── boot-espocrm │ ├── flarum │ ├── README.md │ ├── flarum.dockerfile │ └── rootfs │ │ └── startup │ │ └── boot-flarum │ ├── grav │ ├── README.md │ ├── grav.dockerfile │ └── rootfs │ │ └── startup │ │ └── boot-grav │ ├── hyperf │ ├── README.md │ ├── hyperf.dockerfile │ └── rootfs │ │ ├── etc │ │ └── nginx │ │ │ └── sites-enabled │ │ │ └── 00-default.conf │ │ └── startup │ │ └── boot-hyperf │ ├── invoiceshelf │ ├── README.md │ ├── invoiceshelf.dockerfile │ └── rootfs │ │ └── startup │ │ └── boot-invoiceshelf │ ├── kirby │ ├── README.md │ ├── kirby.dockerfile │ └── rootfs │ │ └── startup │ │ └── boot-kirby │ ├── laminas │ ├── README.md │ ├── laminas.dockerfile │ └── rootfs │ │ └── startup │ │ └── boot-laminas │ ├── laravel │ ├── README.md │ ├── laravel.dockerfile │ └── rootfs │ │ └── startup │ │ └── boot-laravel │ ├── magento │ ├── README.md │ ├── magento.dockerfile │ └── rootfs │ │ └── startup │ │ └── boot-magento │ ├── mautic │ ├── README.md │ ├── mautic.dockerfile │ └── rootfs │ │ └── startup │ │ └── boot-mautic │ ├── phpmyadmin │ ├── README.md │ ├── phpmyadmin.dockerfile │ └── rootfs │ │ ├── etc │ │ └── phpmyadmin-config.php │ │ └── startup │ │ └── boot-phpmyadmin │ ├── slim │ ├── README.md │ ├── rootfs │ │ └── startup │ │ │ └── boot-slim │ └── slim.dockerfile │ ├── spiral │ ├── README.md │ ├── rootfs │ │ └── startup │ │ │ └── boot-spiral │ └── spiral.dockerfile │ ├── statamic │ ├── README.md │ ├── rootfs │ │ └── startup │ │ │ └── boot-statamic │ └── statamic.dockerfile │ ├── sulu │ ├── README.md │ ├── rootfs │ │ └── startup │ │ │ └── boot-sulu │ └── sulu.dockerfile │ ├── symfony │ ├── README.md │ ├── rootfs │ │ └── startup │ │ │ └── boot-symfony │ └── symfony.dockerfile │ ├── wordpress │ ├── README.md │ ├── rootfs │ │ ├── etc │ │ │ └── hooks │ │ │ │ └── bootstrap │ │ │ │ └── 10-create-project │ │ └── startup │ │ │ └── boot-wordpress │ └── wordpress.dockerfile │ ├── yii │ ├── README.md │ ├── rootfs │ │ └── startup │ │ │ └── boot-yii │ └── yii.dockerfile │ ├── zz-crater │ ├── README.md │ ├── crater.dockerfile │ └── rootfs │ │ └── startup │ │ └── boot-crater │ ├── zz-fuelphp │ ├── README.md │ ├── fuelphp.dockerfile │ └── rootfs │ │ └── startup │ │ └── boot-fuelphp │ └── zz-phpixie │ ├── README.md │ ├── phpixie.dockerfile │ └── rootfs │ └── startup │ └── boot-phpixie └── tests ├── action-test.sh ├── logs └── .gitignore ├── sbom-test.sh └── squash-test.sh /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = true 10 | 11 | [*.yml] 12 | indent_size = 2 13 | 14 | [Caddyfile] 15 | indent_style = tab 16 | indent_size = 2 17 | insert_final_newline = false 18 | -------------------------------------------------------------------------------- /.github/workflows/00-s6-overlay.yml: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | name: Publish S6 10 | 11 | ################################################################################ 12 | ################################################################################ 13 | 14 | on: 15 | workflow_call: 16 | inputs: 17 | tag_prefix: 18 | required: false 19 | type: string 20 | default: "" 21 | workflow_dispatch: 22 | 23 | ################################################################################ 24 | ################################################################################ 25 | 26 | jobs: 27 | 28 | s6-overlay: 29 | uses: ./.github/workflows/template-common.yml 30 | secrets: inherit 31 | with: 32 | app_name: "base-s6" 33 | os: "alpine" 34 | 35 | linux-s6: 36 | name: ${{ matrix.os == '' && 'debian' || matrix.os }}-s6 37 | uses: ./.github/workflows/template-common.yml 38 | secrets: inherit 39 | strategy: 40 | matrix: 41 | os: 42 | - "" 43 | - "ubuntu" 44 | - "alpine" 45 | with: 46 | app_name: "base-os" 47 | os: ${{ matrix.os }} 48 | tag_prefix: ${{ inputs.tag_prefix }} 49 | 50 | ################################################################################ 51 | ################################################################################ 52 | -------------------------------------------------------------------------------- /.github/workflows/01-php.yml: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | name: Publish PHP 10 | 11 | ################################################################################ 12 | ################################################################################ 13 | 14 | on: 15 | workflow_call: 16 | inputs: 17 | tag_prefix: 18 | required: false 19 | type: string 20 | default: "" 21 | build_all: 22 | required: false 23 | type: boolean 24 | default: false 25 | workflow_dispatch: 26 | 27 | ################################################################################ 28 | ################################################################################ 29 | 30 | jobs: 31 | 32 | php: 33 | # See: https://docs.github.com/en/webhooks/webhook-events-and-payloads#workflow_run 34 | if: ${{ github.event.workflow_run.conclusion == '' || github.event.workflow_run.conclusion == 'success' }} 35 | uses: ./.github/workflows/template-php.yml 36 | secrets: inherit 37 | strategy: 38 | matrix: 39 | app: 40 | - cli 41 | - fpm 42 | - zts 43 | with: 44 | app_name: ${{ matrix.app }} 45 | tag_prefix: ${{ inputs.tag_prefix }} 46 | build_all: ${{ inputs.build_all }} 47 | 48 | ################################################################################ 49 | ################################################################################ 50 | -------------------------------------------------------------------------------- /.github/workflows/02-servers.yml: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | name: Publish PHP Servers 10 | 11 | ################################################################################ 12 | ################################################################################ 13 | 14 | on: 15 | workflow_call: 16 | inputs: 17 | tag_prefix: 18 | required: false 19 | type: string 20 | default: "" 21 | build_all: 22 | required: false 23 | type: boolean 24 | default: false 25 | workflow_dispatch: 26 | workflow_run: 27 | workflows: [Publish PHP] 28 | types: 29 | - completed 30 | 31 | ################################################################################ 32 | ################################################################################ 33 | 34 | jobs: 35 | 36 | php-servers: 37 | # See: https://docs.github.com/en/webhooks/webhook-events-and-payloads#workflow_run 38 | if: ${{ github.event.workflow_run.conclusion == '' || github.event.workflow_run.conclusion == 'success' }} 39 | uses: ./.github/workflows/template-php.yml 40 | secrets: inherit 41 | strategy: 42 | matrix: 43 | app: 44 | - with-apache 45 | - with-nginx 46 | - with-roadrunner 47 | - with-f8p 48 | - with-unit 49 | with: 50 | app_name: ${{ matrix.app }} 51 | tag_prefix: ${{ inputs.tag_prefix }} 52 | build_all: ${{ inputs.build_all }} 53 | 54 | ################################################################################ 55 | ################################################################################ 56 | -------------------------------------------------------------------------------- /.github/workflows/03-apps.yml: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | name: Publish PHP Apps 10 | 11 | ################################################################################ 12 | ################################################################################ 13 | 14 | on: 15 | workflow_call: 16 | inputs: 17 | tag_prefix: 18 | required: false 19 | type: string 20 | default: "" 21 | build_all: 22 | required: false 23 | type: boolean 24 | default: false 25 | workflow_dispatch: 26 | workflow_run: 27 | workflows: [Publish PHP Servers] 28 | types: 29 | - completed 30 | 31 | ################################################################################ 32 | ################################################################################ 33 | 34 | jobs: 35 | 36 | php-apps: 37 | # See: https://docs.github.com/en/webhooks/webhook-events-and-payloads#workflow_run 38 | if: ${{ github.event.workflow_run.conclusion == '' || github.event.workflow_run.conclusion == 'success' }} 39 | uses: ./.github/workflows/template-php.yml 40 | secrets: inherit 41 | strategy: 42 | max-parallel: 4 43 | matrix: 44 | app: 45 | - app-bedrock 46 | - app-cakephp4 47 | - app-cakephp5 48 | - app-codeigniter4 49 | - app-coolify 50 | - app-drupal 51 | - app-espocrm 52 | - app-flarum 53 | - app-grav 54 | - app-hyperf 55 | - app-invoiceshelf 56 | - app-kirby 57 | - app-laminas 58 | - app-laravel 59 | - app-magento 60 | - app-mautic 61 | - app-phpmyadmin 62 | - app-slim 63 | - app-spiral 64 | - app-statamic 65 | - app-sulu 66 | - app-symfony 67 | - app-wordpress 68 | - app-yii 69 | # include: 70 | # - app: app-laravel 71 | # server: [apache, nginx] 72 | with: 73 | app_name: ${{ matrix.app }} 74 | server: ${{ matrix.server }} 75 | tag_prefix: ${{ inputs.tag_prefix }} 76 | build_all: ${{ inputs.build_all }} 77 | 78 | ################################################################################ 79 | ################################################################################ 80 | -------------------------------------------------------------------------------- /.github/workflows/build-all.yml: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | name: Daily build 10 | 11 | ################################################################################ 12 | ################################################################################ 13 | 14 | on: 15 | workflow_dispatch: 16 | schedule: 17 | - cron: "0 0 * * *" 18 | release: 19 | types: [released] 20 | pull_request: 21 | types: [opened] 22 | paths: 23 | - 'src/**' 24 | - '!src/**.md' 25 | 26 | ################################################################################ 27 | ################################################################################ 28 | 29 | jobs: 30 | prepare: 31 | runs-on: ubuntu-22.04 32 | outputs: 33 | tag_prefix: ${{ steps.init.outputs.tag_prefix }} 34 | build_all: ${{ steps.init.outputs.build_all == '1' }} 35 | steps: 36 | - name: pre-build debug 37 | id: init 38 | run: | 39 | the_day=$(date -u +"%d") 40 | event_name=${{ github.event_name }} 41 | ref_type=${{ github.ref_type }} 42 | ref=${{ github.ref }} 43 | tag_prefix=$(if [[ $ref_type != 'tag' ]] && [[ $ref != 'refs/heads/main' ]]; then echo 'dev-'; fi) 44 | build_all=$(if [[ $event_name != 'schedule' ]] || [[ $the_day == '01' ]]; then echo '1'; fi) 45 | 46 | # For debugging purposes 47 | echo "the_day=$the_day" >> "$GITHUB_OUTPUT" 48 | echo "tag_prefix=$tag_prefix" >> "$GITHUB_OUTPUT" 49 | echo "build_all=$build_all" >> "$GITHUB_OUTPUT" 50 | echo "github.event_name = $event_name" 51 | echo "github.ref_type = $ref_type" 52 | echo "github.ref = $ref" 53 | echo "tag_prefix = $tag_prefix" 54 | echo "build_all = $(if [ ! -z "$build_all" ]; then echo 'yes, includes outdated versions'; else echo 'no, only maintained versions'; fi)" 55 | 56 | s6: 57 | uses: ./.github/workflows/00-s6-overlay.yml 58 | secrets: inherit 59 | needs: [prepare] 60 | with: 61 | tag_prefix: ${{ needs.prepare.outputs.tag_prefix }} 62 | 63 | php: 64 | uses: ./.github/workflows/01-php.yml 65 | secrets: inherit 66 | needs: [prepare] 67 | with: 68 | tag_prefix: ${{ needs.prepare.outputs.tag_prefix }} 69 | build_all: ${{ fromJSON(needs.prepare.outputs.build_all) || false }} 70 | 71 | php-servers: 72 | uses: ./.github/workflows/02-servers.yml 73 | secrets: inherit 74 | needs: [prepare, php] 75 | with: 76 | tag_prefix: ${{ needs.prepare.outputs.tag_prefix }} 77 | build_all: ${{ fromJSON(needs.prepare.outputs.build_all) || false }} 78 | 79 | php-apps: 80 | uses: ./.github/workflows/03-apps.yml 81 | secrets: inherit 82 | needs: [prepare, php-servers] 83 | with: 84 | tag_prefix: ${{ needs.prepare.outputs.tag_prefix }} 85 | build_all: ${{ fromJSON(needs.prepare.outputs.build_all) || false }} 86 | 87 | ################################################################################ 88 | ################################################################################ 89 | -------------------------------------------------------------------------------- /.github/workflows/template-php.yml: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | name: Build Template PHP 10 | 11 | ################################################################################ 12 | ################################################################################ 13 | 14 | on: 15 | workflow_call: 16 | inputs: 17 | app_name: 18 | required: true 19 | type: string 20 | server: 21 | required: false 22 | type: string 23 | default: "" 24 | tag_prefix: 25 | required: false 26 | type: string 27 | default: "" 28 | build_all: 29 | required: false 30 | type: boolean 31 | default: false 32 | 33 | ################################################################################ 34 | ################################################################################ 35 | 36 | jobs: 37 | maintained: 38 | uses: ./.github/workflows/template-common.yml 39 | secrets: inherit 40 | strategy: 41 | max-parallel: 8 42 | matrix: 43 | os: ["", "alpine"] 44 | php_version: ["8.1", "8.2", "8.3", "8.4"] 45 | with: 46 | os: ${{ matrix.os }} 47 | php_version: ${{ matrix.php_version }} 48 | app_name: ${{ inputs.app_name }} 49 | server: ${{ inputs.server }} 50 | tag_prefix: ${{ inputs.tag_prefix }} 51 | 52 | outdated: 53 | if: ${{ inputs.build_all }} 54 | uses: ./.github/workflows/template-common.yml 55 | secrets: inherit 56 | strategy: 57 | max-parallel: 7 58 | matrix: 59 | os: ["", "alpine"] 60 | php_version: ["5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0"] 61 | with: 62 | os: ${{ matrix.os }} 63 | php_version: ${{ matrix.php_version }} 64 | app_name: ${{ inputs.app_name }} 65 | server: ${{ inputs.server }} 66 | tag_prefix: ${{ inputs.tag_prefix }} 67 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | .env.* 3 | .secrets 4 | **/.DS_Store 5 | **/.git 6 | **/*.squashed 7 | **/*.working 8 | **/Dockerfile 9 | **/meta.dockerfile 10 | myproject 11 | 12 | !.env.example 13 | !src/php/meta.dockerfile 14 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "build/docker-squash"] 2 | path = build/docker-squash 3 | url = https://github.com/shinsenter/docker-squash.git 4 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.rulers": [ 3 | 60, 4 | 80, 5 | 100, 6 | 120, 7 | 160 8 | ], 9 | "editor.trimAutoWhitespace": true, 10 | "files.encoding": "utf8", 11 | "files.eol": "\n" 12 | } 13 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Responsible Disclosure Policy 2 | 3 | 4 | ## Reporting Security Vulnerabilities 5 | 6 | We take security seriously in our open-source project. If you discover a security vulnerability, please help us by responsibly disclosing it. We appreciate your efforts in keeping our project safe for everyone. 7 | 8 | 9 | ## How to Report a Vulnerability 10 | 11 | To report a security vulnerability: 12 | 13 | 1. **Contact us privately**: Please email us at [shin@shin.company](mailto:shin@shin.company) with details about the vulnerability. Please refrain from disclosing the issue publicly until we've had a chance to address it. 14 | 15 | 2. **Provide details**: Include as much information as possible about the vulnerability, including steps to reproduce it and its potential impact. 16 | 17 | 3. **Be responsible**: Please avoid exploiting the vulnerability beyond what is necessary to demonstrate the issue. 18 | 19 | 20 | ## What to Expect 21 | 22 | Once we receive your report, we'll acknowledge it promptly. We'll work to assess the reported vulnerability's validity and severity and develop a fix as quickly as possible. We'll keep you updated on our progress throughout the process. 23 | 24 | 25 | ## Legal Safe Harbor 26 | 27 | We won't take legal action against you for responsibly disclosing security vulnerabilities in our project. We appreciate your contributions to making our project more secure. 28 | 29 | Thank you for your help in keeping our project safe. 30 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-architect 2 | -------------------------------------------------------------------------------- /build/.secrets.example: -------------------------------------------------------------------------------- 1 | DOCKER_HUB_USERNAME= 2 | DOCKER_HUB_PASSWORD= 3 | DOCKER_HUB_ACCESS_TOKEN= 4 | GITHUB_TOKEN= 5 | -------------------------------------------------------------------------------- /src/dummy.dockerfile: -------------------------------------------------------------------------------- 1 | FROM busybox:latest 2 | ENV DUMMY=1 3 | 4 | ARG BUILDPLATFORM 5 | ARG BUILDOS 6 | ARG BUILDARCH 7 | ARG BUILDVARIANT 8 | ARG TARGETPLATFORM 9 | ARG TARGETOS 10 | ARG TARGETARCH 11 | ARG TARGETVARIAN 12 | 13 | ARG BUILD_CACHE_KEY 14 | ARG BUILD_CACHE_PATH 15 | ARG BUILD_CONTEXT 16 | ARG BUILD_DATE 17 | ARG BUILD_DESC 18 | ARG BUILD_DOCKERFILE 19 | ARG BUILD_DOCKERFILE_SQUASHED 20 | ARG BUILD_NAME 21 | ARG BUILD_TMP_NAME 22 | ARG BUILD_PLATFORM 23 | ARG BUILD_README 24 | ARG BUILD_REVISION 25 | ARG BUILD_SOURCE_IMAGE 26 | ARG BUILD_TAG 27 | ARG BUILD_TAGS 28 | ARG LATEST_PHP 29 | ARG LATEST_S6 30 | ARG OS_BASE 31 | ARG OS_VERSION 32 | ARG PHP_VERSION 33 | ARG PHP_VARIANT 34 | ARG S6_PATH 35 | ARG S6_VERSION 36 | ARG SQUASH_CMD 37 | 38 | ENV BUILDPLATFORM=$BUILDPLATFORM 39 | ENV BUILDOS=$BUILDOS 40 | ENV BUILDARCH=$BUILDARCH 41 | ENV BUILDVARIANT=$BUILDVARIANT 42 | ENV TARGETPLATFORM=$TARGETPLATFORM 43 | ENV TARGETOS=$TARGETOS 44 | ENV TARGETARCH=$TARGETARCH 45 | ENV TARGETVARIAN=$TARGETVARIAN 46 | 47 | ENV BUILD_CACHE_KEY=$BUILD_CACHE_KEY 48 | ENV BUILD_CACHE_PATH=$BUILD_CACHE_PATH 49 | ENV BUILD_CONTEXT=$BUILD_CONTEXT 50 | ENV BUILD_DATE=$BUILD_DATE 51 | ENV BUILD_DESC=$BUILD_DESC 52 | ENV BUILD_DOCKERFILE=$BUILD_DOCKERFILE 53 | ENV BUILD_DOCKERFILE_SQUASHED=$BUILD_DOCKERFILE_SQUASHED 54 | ENV BUILD_NAME=$BUILD_NAME 55 | ENV BUILD_TMP_NAME=$BUILD_TMP_NAME 56 | ENV BUILD_PLATFORM=$BUILD_PLATFORM 57 | ENV BUILD_README=$BUILD_README 58 | ENV BUILD_REVISION=$BUILD_REVISION 59 | ENV BUILD_SOURCE_IMAGE=$BUILD_SOURCE_IMAGE 60 | ENV BUILD_TAG=$BUILD_TAG 61 | ENV BUILD_TAGS=$BUILD_TAGS 62 | ENV LATEST_PHP=$LATEST_PHP 63 | ENV LATEST_S6=$LATEST_S6 64 | ENV OS_BASE=$OS_BASE 65 | ENV OS_VERSION=$OS_VERSION 66 | ENV PHP_VERSION=${PHP_VERSION//-rc/} 67 | ENV PHP_VARIANT=$PHP_VARIANT 68 | ENV S6_PATH=$S6_PATH 69 | ENV S6_VERSION=$S6_VERSION 70 | ENV SQUASH_CMD=$SQUASH_CMD 71 | 72 | RUN <<'EOF' 73 | echo BUILDPLATFORM=$BUILDPLATFORM 74 | echo BUILDOS=$BUILDOS 75 | echo BUILDARCH=$BUILDARCH 76 | echo BUILDVARIANT=$BUILDVARIANT 77 | echo TARGETPLATFORM=$TARGETPLATFORM 78 | echo TARGETOS=$TARGETOS 79 | echo TARGETARCH=$TARGETARCH 80 | echo TARGETVARIAN=$TARGETVARIAN 81 | 82 | echo BUILD_CACHE_KEY=$BUILD_CACHE_KEY 83 | echo BUILD_CACHE_PATH=$BUILD_CACHE_PATH 84 | echo BUILD_CONTEXT=$BUILD_CONTEXT 85 | echo BUILD_DATE=$BUILD_DATE 86 | echo BUILD_DESC=$BUILD_DESC 87 | echo BUILD_DOCKERFILE=$BUILD_DOCKERFILE 88 | echo BUILD_DOCKERFILE_SQUASHED=$BUILD_DOCKERFILE_SQUASHED 89 | echo BUILD_NAME=$BUILD_NAME 90 | echo BUILD_TMP_NAME=$BUILD_TMP_NAME 91 | echo BUILD_PLATFORM=$BUILD_PLATFORM 92 | echo BUILD_README=$BUILD_README 93 | echo BUILD_REVISION=$BUILD_REVISION 94 | echo BUILD_SOURCE_IMAGE=$BUILD_SOURCE_IMAGE 95 | echo BUILD_TAG=$BUILD_TAG 96 | echo BUILD_TAGS=$BUILD_TAGS 97 | echo LATEST_PHP=$LATEST_PHP 98 | echo LATEST_S6=$LATEST_S6 99 | echo OS_BASE=$OS_BASE 100 | echo OS_VERSION=$OS_VERSION 101 | echo PHP_VERSION=$PHP_VERSION 102 | echo PHP_VARIANT=$PHP_VARIANT 103 | echo S6_PATH=$S6_PATH 104 | echo S6_VERSION=$S6_VERSION 105 | echo SQUASH_CMD=$SQUASH_CMD 106 | EOF 107 | -------------------------------------------------------------------------------- /src/dummy.md: -------------------------------------------------------------------------------- 1 | # dummy.md 2 | 3 | Just a dummy build. 4 | -------------------------------------------------------------------------------- /src/php/.dockerignore: -------------------------------------------------------------------------------- 1 | .env 2 | .env.* 3 | *.dockerfile 4 | *.md 5 | *.squashed 6 | **/.DS_Store 7 | **/.git 8 | **/*.dockerfile 9 | **/*.md 10 | **/*.squashed 11 | **/*.working 12 | **/Dockerfile 13 | -------------------------------------------------------------------------------- /src/php/base-os.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG OS_BASE=${OS_BASE:-alpine} 18 | ARG OS_VERSION=${OS_VERSION:-latest} 19 | 20 | FROM ${OS_BASE}:${OS_VERSION} 21 | 22 | ################################################################################ 23 | 24 | INCLUDE ./common/os-base 25 | INCLUDE ./common/os-s6-overlay 26 | INCLUDE ./common/os-crontab 27 | 28 | RUN echo $(source /etc/os-release && echo $NAME $VERSION) >/etc/welcome.txt 29 | 30 | ################################################################################ 31 | 32 | ENTRYPOINT /usr/local/bin/docker-php-entrypoint 33 | 34 | ################################################################################ 35 | 36 | INCLUDE ./meta 37 | 38 | ################################################################################ 39 | -------------------------------------------------------------------------------- /src/php/base-php.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-php} 18 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 19 | ARG PHP_VARIANT=${PHP_VARIANT:-fpm-alpine} 20 | 21 | FROM ${BUILD_FROM_IMAGE}:${PHP_VERSION}-${PHP_VARIANT} 22 | 23 | # set PHP variables 24 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 25 | ENV PHP_VERSION=${PHP_VERSION//-rc/} 26 | 27 | ################################################################################ 28 | 29 | INCLUDE ./common/os-base 30 | INCLUDE ./common/os-crontab 31 | INCLUDE ./common/php-extensions 32 | INCLUDE ./common/php-composer 33 | INCLUDE ./common/php-ini-directives 34 | 35 | ################################################################################ 36 | 37 | INCLUDE ./meta 38 | 39 | ################################################################################ 40 | -------------------------------------------------------------------------------- /src/php/base-s6.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | FROM scratch AS s6-overlay 18 | 19 | ARG S6_PATH 20 | COPY --link --from=./base-os $S6_PATH/ / 21 | 22 | ################################################################################ 23 | 24 | INCLUDE ./meta 25 | 26 | ################################################################################ 27 | -------------------------------------------------------------------------------- /src/php/base-s6.md: -------------------------------------------------------------------------------- 1 | # shinsenter/s6-overlay 2 | 3 | 🗂 Unpacked s6-overlay version 3 as a multi-platform build stage. 4 | 5 | - Docker Hub: https://hub.docker.com/r/shinsenter/s6-overlay 6 | - GitHub Packages: https://code.shin.company/php/pkgs/container/s6-overlay 7 | 8 | 9 | ## Introduction 10 | 11 | Unpacked [s6-overlay](https://github.com/just-containers/s6-overlay) binaries which allow a single Dockerfile to support multiple platform build using techniques like BuildKit. 12 | 13 | > 💡 Hint: See [s6-overlay/README.md](https://github.com/just-containers/s6-overlay/blob/master/README.md) to learn more. 14 | 15 | 16 | ## Usage 17 | 18 | Build the following Dockerfile and try it out: 19 | 20 | ```Dockerfile 21 | # Use your favorite image 22 | FROM ubuntu 23 | ARG S6_OVERLAY_VERSION=v3.1.6.2 24 | 25 | # Just copy unpacked binaries 26 | ADD --from=shinsenter/s6-overlay:$S6_OVERLAY_VERSION / / 27 | 28 | ENTRYPOINT ["/init"] 29 | ``` 30 | 31 | 32 | ## Supported Platforms 33 | 34 | - linux/386 35 | - linux/amd64 36 | - linux/arm/v6 37 | - linux/arm/v7 38 | - linux/arm64 39 | - linux/ppc64le 40 | - linux/s390x 41 | 42 | 43 | ## Contributing 44 | 45 | If you find these images useful, consider donating via [PayPal](https://www.paypal.me/shinsenter) 46 | or opening an issue on [GitHub](https://code.shin.company/php/issues/new). 47 | 48 | Your support helps maintain and improve these images for the community. 49 | 50 | 51 | ## License 52 | 53 | This project is licensed under the terms of the [GNU General Public License v3.0](https://code.shin.company/php/blob/main/LICENSE). 54 | 55 | Please respect the intellectual efforts involved in creating these images. 56 | If you intend to copy or use ideas from this project, proper credit is appreciated. 57 | 58 | --- 59 | 60 | From Vietnam 🇻🇳 with love. 61 | -------------------------------------------------------------------------------- /src/php/common/docker-php-entrypoint: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | if [ "$(id -u)" != "0" ]; then debug-echo -e "!!! Please run this container as the root user !!!" >&2; exit 1; fi 10 | 11 | APP_PATH="$(app-path)" 12 | 13 | debug-echo "Initialize container" 14 | mkdir -p "$APP_PATH" 15 | 16 | # set timezone 17 | export TZ="${TZ:=UTC}" 18 | if [ ! -z "$TZ" ] && [ -e /usr/share/zoneinfo/$TZ ]; then 19 | ln -nsf /usr/share/zoneinfo/$TZ /etc/localtime 20 | echo $TZ >/etc/timezone 21 | fi 22 | 23 | # activity logging 24 | touch /var/log/startup.log 25 | echo "$(date) $(whoami)@$(hostname):$(pwd)\$ $0 $SUPERVISOR_PHP_COMMAND $@" >>/var/log/startup.log 26 | 27 | # load the $ENV in ~/.bashrc 28 | ENV_CHECK='if [ -x "$ENV" ]; then source "$ENV"; fi' 29 | touch ~/.bashrc 30 | if ! grep -qF "$ENV_CHECK" ~/.bashrc; then echo " 31 | # load environment variables for PHP 32 | $ENV_CHECK 33 | " >> ~/.bashrc; fi 34 | 35 | # export all env variables for PHP 36 | if is-true $ALLOW_RUNTIME_PHP_ENVVARS && has-cmd php && has-cmd php-envvars; then 37 | debug-echo "Export all env variables for PHP" 38 | php-envvars export_envvars 2>&1 39 | fi 40 | 41 | # change working directory 42 | if [ -d "$APP_PATH" ]; then cd "$APP_PATH"; fi 43 | 44 | if [ ! -z "$SUPERVISOR_PHP_COMMAND" ]; then 45 | # run bootstrap hook to initialize the container 46 | hook bootstrap 47 | 48 | # run custom command defined in $SUPERVISOR_PHP_COMMAND 49 | debug-echo "Start container with the command: $SUPERVISOR_PHP_COMMAND $@" 50 | exec with-env $SUPERVISOR_PHP_COMMAND "$@" 51 | else 52 | # run bootstrap hook to initialize the container 53 | if ! has-s6; then hook bootstrap; fi 54 | 55 | # fallback for docker-php-entrypoint 56 | if [ -x "/init" ]; then set -- /init "$@"; fi 57 | 58 | # fallback empty entrypoint 59 | if [ $# -eq 0 ]; then set -- /bin/sh; fi 60 | 61 | # start container with command 62 | debug-echo "Start container with the command: $@" 63 | exec with-env "$@" 64 | fi 65 | -------------------------------------------------------------------------------- /src/php/common/os-crontab.dockerfile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | # install crontab 10 | RUN <<'EOF' 11 | echo 'Configure base crontab' 12 | [ -z "$DEBUG" ] || set -ex && set -e 13 | 14 | env-default CRONTAB_SHELL '/bin/sh' 15 | env-default CRONTAB_MAILTO '$APP_ADMIN' 16 | 17 | if ! has-cmd crond; then 18 | pkg-add cron 19 | ln -nsf $(command -v cron) /usr/sbin/crond 20 | fi 21 | 22 | if has-cmd s6-service; then 23 | s6-service crontab longrun '#!/usr/bin/env sh 24 | if is-true $ENABLE_CRONTAB; then 25 | export APP_PATH="$(app-path)" 26 | export APP_ROOT="$(app-root)" 27 | cd $APP_PATH && exec crond -f $CRONTAB_OPTIONS 28 | else 29 | exec s6-svc -Od . 30 | fi 31 | ' 32 | fi 33 | EOF 34 | -------------------------------------------------------------------------------- /src/php/common/os-s6-overlay.dockerfile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | # S6 variables 10 | ARG S6_VERSION=${S6_VERSION:-} 11 | ARG S6_PATH=${S6_PATH:-} 12 | 13 | ################################################################################ 14 | 15 | RUN <<'EOF' 16 | if ! has-s6 && [ ! -z "$S6_VERSION" ]; then 17 | echo 'Configure s6-overlay' 18 | [ -z "$DEBUG" ] || set -ex && set -e 19 | 20 | SOURCE="https://github.com/just-containers/s6-overlay/releases/download/${S6_VERSION}" 21 | FALLBACK_ENTRYPOINT="/usr/local/bin/fallback-entrypoint" 22 | 23 | # install deps 24 | if [ ! -x "$(command -v xz)" ] || [ ! -x "$(command -v tar)" ]; then 25 | APK_PACKAGES="tar xz" \ 26 | APT_PACKAGES="xz-utils" \ 27 | pkg-add 28 | fi 29 | 30 | # backup existing entrypoint 31 | if [ -x /init ]; then mv -f /init $FALLBACK_ENTRYPOINT; fi 32 | 33 | # detect system's architecture 34 | case "$(uname -m)" in 35 | aarch64 ) S6_ARCH='aarch64' ;; 36 | arm64 ) S6_ARCH='aarch64' ;; 37 | armhf ) S6_ARCH='armhf' ;; 38 | arm* ) S6_ARCH='arm' ;; 39 | i4* ) S6_ARCH='i486' ;; 40 | i6* ) S6_ARCH='i686' ;; 41 | riscv64 ) S6_ARCH='riscv64' ;; 42 | s390* ) S6_ARCH='s390x' ;; 43 | * ) S6_ARCH='x86_64' ;; 44 | esac 45 | 46 | untar() { 47 | local url="$1" 48 | local path="${2:-$S6_PATH}/" 49 | if [ ! -e $path ]; then mkdir -p $path; fi 50 | curl --retry 3 --retry-delay 5 -ksLRJ "$url" | tar Jxp -C $path 51 | } 52 | 53 | # and install the right version of s6-overlay 54 | untar ${SOURCE}/s6-overlay-noarch.tar.xz 55 | untar ${SOURCE}/s6-overlay-${S6_ARCH}.tar.xz 56 | untar ${SOURCE}/syslogd-overlay-noarch.tar.xz 57 | 58 | # set s6-overlay default behavior 59 | if has-cmd env-default; then 60 | env-default '# Environment variables for s6-overlay' 61 | env-default S6_BEHAVIOUR_IF_STAGE2_FAILS 2 62 | env-default S6_CMD_WAIT_FOR_SERVICES_MAXTIME 0 63 | env-default S6_KEEP_ENV 1 64 | env-default S6_KILL_FINISH_MAXTIME 3000 65 | env-default S6_KILL_GRACETIME 3000 66 | env-default S6_LOGGING 0 67 | env-default S6_SERVICES_GRACETIME 3000 68 | env-default S6_VERBOSITY '$(is-debug && echo 2 || echo 0)' 69 | env-default S6_VERSION $S6_VERSION 70 | fi 71 | 72 | # inject legacy entrypoint 73 | if [ -x $FALLBACK_ENTRYPOINT ]; then 74 | sed -i "s|^exec |\nif [ \$# -gt 0 ]; then set -- $FALLBACK_ENTRYPOINT \"\$@\"; fi\n\nexec |" /init 75 | fi 76 | fi 77 | EOF 78 | 79 | ################################################################################ 80 | 81 | STOPSIGNAL SIGTERM 82 | -------------------------------------------------------------------------------- /src/php/common/php-composer.dockerfile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | ARG COMPOSER_ALLOW_SUPERUSER=1 10 | 11 | # Add Composer to the PATH 12 | ENV COMPOSER_HOME="/.composer" 13 | 14 | ################################################################################ 15 | 16 | RUN <<'EOF' 17 | echo 'Configure Composer' 18 | [ -z "$DEBUG" ] || set -ex && set -e 19 | 20 | # Set Composer default settings 21 | env-default '# Environment variables for Composer' 22 | env-default COMPOSER_ALLOW_SUPERUSER $COMPOSER_ALLOW_SUPERUSER 23 | env-default COMPOSER_ALLOW_XDEBUG '$(is-debug && echo 1 || echo 0)' 24 | env-default COMPOSER_FUND '0' 25 | env-default COMPOSER_HTACCESS_PROTECT '1' 26 | env-default COMPOSER_MEMORY_LIMIT '-1' 27 | env-default COMPOSER_NO_AUDIT '1' 28 | env-default COMPOSER_NO_INTERACTION '1' 29 | env-default COMPOSER_PROCESS_TIMEOUT '0' 30 | 31 | # Install Composer 32 | phpaddmod @composer 33 | composer -V 34 | 35 | # Make alias for Composer with env 36 | web-cmd root composer "$(command -v composer)" 37 | EOF 38 | -------------------------------------------------------------------------------- /src/php/common/rootfs/etc/cont-init.d/00-bootstrap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | exec hook bootstrap 3 | -------------------------------------------------------------------------------- /src/php/common/rootfs/etc/hooks/bootstrap/00-bootstrap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | DEFAULT_USER="www-data" 11 | DEFAULT_GROUP="www-data" 12 | DEFAULT_UID="$(id -u $DEFAULT_USER)" 13 | DEFAULT_GID="$(id -g $DEFAULT_USER)" 14 | 15 | APP_PATH="$(app-path)" 16 | LOG_PATH="$(dirname $(log-path))" 17 | APP_USER="${APP_USER:=$DEFAULT_USER}" 18 | APP_GROUP="${APP_GROUP:=$DEFAULT_GROUP}" 19 | APP_UID="${APP_UID:=$DEFAULT_UID}" 20 | APP_GID="${APP_GID:=$DEFAULT_GID}" 21 | USER_HOME="/home/${APP_USER}" 22 | 23 | rand_id() { echo "$((RANDOM % 500 + 499))"; } 24 | 25 | ################################################################################ 26 | 27 | # create user and group 28 | debug-echo "Verify group $APP_GROUP" 29 | if [ "$APP_GROUP" != "$DEFAULT_GROUP" ]; then 30 | APP_GID="${APP_GID:=$(rand_id)}" 31 | groupadd -o -r -g $APP_GID $APP_GROUP &>/dev/null 32 | else 33 | if [ "$APP_GID" != "$DEFAULT_GID" ]; then 34 | groupmod -o -g $APP_GID $APP_GROUP 2>&1 35 | web-chown "GID changed to $APP_GROUP ($APP_GID)." 36 | fi 37 | fi 38 | 39 | debug-echo "Verify user $APP_USER" 40 | if [ "$APP_USER" != "$DEFAULT_USER" ]; then 41 | APP_UID="${APP_UID:=$(rand_id)}" 42 | useradd -o -r -g $APP_GID \ 43 | -G $APP_GROUP,$DEFAULT_GROUP --no-log-init \ 44 | -d $USER_HOME -s /sbin/nologin -u $APP_UID $APP_USER &>/dev/null 45 | else 46 | usermod -g $APP_GID -G $APP_GROUP,$DEFAULT_GROUP \ 47 | -d $USER_HOME -s /sbin/nologin $APP_USER 2>&1 48 | 49 | if [ "$APP_UID" != "$DEFAULT_UID" ]; then 50 | usermod -o -u $APP_UID $APP_USER 2>&1 51 | web-chown "UID changed to $APP_USER ($APP_UID)." 52 | fi 53 | fi 54 | 55 | ################################################################################ 56 | 57 | # create application directories 58 | debug-echo "Create $APP_PATH if not exists" 59 | web-mkdir "$APP_PATH" "$LOG_PATH" &>/dev/null 60 | chmod 4755 "$APP_PATH" 61 | 62 | ################################################################################ 63 | 64 | # call the onboot hook 65 | # all the scripts in this hook will be executed 66 | # even when the autorun feature is disabled 67 | hook onboot 68 | -------------------------------------------------------------------------------- /src/php/common/rootfs/etc/hooks/bootstrap/10-create-conf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | if has-cmd php && has-cmd php-envvars; then 11 | debug-echo "Generate PHP config" 12 | if is-true $ALLOW_RUNTIME_PHP_ENVVARS; then 13 | php-envvars write_dynamic_config 2>&1 14 | else 15 | php-envvars write_static_config 2>&1 16 | fi 17 | fi 18 | 19 | if has-cmd php-fpm && is-true $ENABLE_TUNING_FPM; then 20 | debug-echo -w "Tune PHP-FPM performance" 21 | config_file="${PHP_INI_DIR}-fpm.d/zz-generated-settings.conf" 22 | 23 | # Gather system information 24 | cpu_cores=$(grep -c ^processor /proc/cpuinfo) 25 | ram_mb=$(free -m | awk '/^Mem:/{print $2}') 26 | 27 | # Set PHP-FPM directives based on system specs and best practices 28 | pm="dynamic" # Recommended for most cases 29 | pm_max_children=$((cpu_cores * 5)) 30 | pm_start_servers=$((cpu_cores * 2)) 31 | pm_min_spare_servers=$((cpu_cores * 1)) 32 | pm_max_spare_servers=$((cpu_cores * 3)) 33 | pm_max_requests=500 34 | 35 | # Modify configuration file 36 | mkdir -p "$(dirname $config_file)" 37 | touch $config_file 38 | sed -i '/^; Tuning PM/,$d' $config_file &>/dev/null 39 | cat <>$config_file 40 | ; Tuning PM 41 | [\${PHP_POOL_NAME}] 42 | pm = $pm 43 | pm.max_children = $pm_max_children 44 | pm.start_servers = $pm_start_servers 45 | pm.min_spare_servers = $pm_min_spare_servers 46 | pm.max_spare_servers = $pm_max_spare_servers 47 | pm.max_requests = $pm_max_requests 48 | 49 | EOF 50 | fi 51 | -------------------------------------------------------------------------------- /src/php/common/rootfs/etc/hooks/bootstrap/10-missing-index: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | if ! has-cmd php; then exit 0; fi 10 | 11 | APP_PATH="$(app-path)" 12 | APP_ROOT="$(app-root)" 13 | 14 | ################################################################################ 15 | 16 | create_index() { 17 | local index_path="${1:-$APP_ROOT}/index.php" 18 | cat <"$index_path" 19 | /dev/null 28 | } 29 | 30 | ################################################################################ 31 | 32 | web-mkdir "$APP_ROOT" && cd "$APP_ROOT" 33 | 34 | # create index.php when it doesn't exist 35 | if ! is-true $DISABLE_AUTORUN_GENERATING_INDEX; then 36 | if [ -z "$(ls -A "$APP_ROOT")" ]; then 37 | debug-echo "Create index.php" 38 | create_index "$APP_ROOT" 39 | else 40 | debug-echo "Skip creating index.php because $APP_ROOT is not empty." 41 | fi 42 | fi 43 | -------------------------------------------------------------------------------- /src/php/common/rootfs/etc/hooks/bootstrap/50-autorun: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | if ! has-cmd autorun; then exit 0; fi 10 | 11 | if is-true $DISABLE_AUTORUN_SCRIPTS; then exit 0; fi 12 | 13 | cd "$(app-path)" 14 | exec autorun /etc/autorun.d/ /startup/ 2>&1 15 | -------------------------------------------------------------------------------- /src/php/common/rootfs/etc/hooks/bootstrap/50-crontabs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | if ! has-cmd crond; then exit 0; fi 10 | 11 | APP_USER="${APP_USER:-root}" 12 | CRONTAB="/var/spool/cron/crontabs/$APP_USER" 13 | CRONTAB_DIR="${CRONTAB_DIR:-/etc/crontab.d}" 14 | 15 | if ! is-true $ENABLE_CRONTAB; then 16 | rm -f $CRONTAB 17 | exit 0 18 | fi 19 | 20 | set -e 21 | 22 | mkdir -p "$(dirname $CRONTAB)" $CRONTAB_DIR 23 | 24 | if is-debug; then 25 | echo '* * * * * echo "DEBUG: Crontab is running as $(whoami)." | tee /tmp/cron-debug.txt' >$CRONTAB_DIR/debug 26 | fi 27 | 28 | cat <$CRONTAB 29 | CRON_TZ=${CRONTAB_TZ:-${TZ:-UTC}} 30 | HOME=${CRONTAB_HOME:-$(app-path)} 31 | PATH=${CRONTAB_PATH:-$PATH} 32 | $(if [ ! -z "$CRONTAB_SHELL" ]; then echo "SHELL=${CRONTAB_SHELL}"; fi) 33 | $(if [ ! -z "$CRONTAB_MAILTO" ]; then echo "MAILTO=${CRONTAB_MAILTO}"; fi) 34 | 35 | # Job definition: 36 | # .---------------- minute (0 - 59) 37 | # | .------------- hour (0 - 23) 38 | # | | .---------- day of month (1 - 31) 39 | # | | | .------- month (1 - 12) OR jan,feb,mar,apr ... 40 | # | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat 41 | # | | | | | 42 | # * * * * * command to be executed 43 | ${CRONTAB_SETTINGS} 44 | 45 | $(if [ -d "$CRONTAB_DIR" ]; then 46 | for script in $(find "$CRONTAB_DIR" -type f | sort -dbfi); do 47 | echo -e "\n# $script"; cat "$script" 48 | done 49 | fi) 50 | 51 | CRONTAB 52 | 53 | chmod 0600 $CRONTAB 54 | debug-echo -i "\nCron is running as $APP_USER.\n\n### Config:\n$(crontab -u $APP_USER -l 2>/dev/null)\n" 55 | 56 | if ! has-s6 && has-cmd crond; then 57 | export APP_PATH="$(app-path)" 58 | export APP_ROOT="$(app-root)" 59 | CROND_PID=/var/run/crond.pid 60 | if [ -f $CROND_PID ]; then kill -TERM $(cat $CROND_PID) &>/dev/null || rm -f $CROND_PID; fi 61 | cd $APP_PATH && with-env crond $CRONTAB_OPTIONS; 62 | fi 63 | -------------------------------------------------------------------------------- /src/php/common/rootfs/etc/hooks/bootstrap/50-sendmail: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | if has-cmd msmtp; then 11 | debug-echo "Configure MSMTP" 12 | cat >/etc/msmtprc < /etc/ssmtp/ssmtp.conf << EOF 23 | root=postmaster 24 | mailhub=${SENDMAIL_SERVER_HOSTNAME:-"mailhog"}:${SENDMAIL_SERVER_PORT:-"1025"} 25 | hostname=`hostname` 26 | FromLineOverride=YES 27 | EOF 28 | fi 29 | -------------------------------------------------------------------------------- /src/php/common/rootfs/etc/hooks/bootstrap/99-other-fixes: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | APP_PATH="$(app-path)" 11 | APP_ROOT="$(app-root)" 12 | 13 | ################################################################################ 14 | 15 | # cache environment variables for other processes 16 | mkdir -p /etc/default && with-env >/etc/default/locale 17 | 18 | # log the timestamp of the first run, then call the hook 19 | # this is convenient for running migration scripts etc. 20 | if [ ! -e /etc/.first-run ]; then 21 | echo "$(date)" >/etc/.first-run 22 | hook onfirstrun 23 | fi 24 | 25 | ################################################################################ 26 | 27 | # fix .htaccess to allow uri path after index.php 28 | if [ -f "$APP_ROOT/.htaccess" ]; then 29 | debug-echo "Fix .htaccess to allow uri path after index.php" 30 | sed -i 's|index\.php/|index.php?/|g' "$APP_ROOT/.htaccess" &>/dev/null 31 | fi 32 | 33 | # fix ownership 34 | if ! is-true $DISABLE_AUTORUN_FIX_OWNER_GROUP; then 35 | debug-echo "Fix ownership for the application path" 36 | if is-true $FIX_APP_PATH_PERMISSION || is-true $FIX_WEBHOME_PERMISSION; then 37 | web-chown fix 38 | elif [ -f "$APP_ROOT/index.php" ] && [ "$(ls -ld "$APP_ROOT/index.php" | awk '{print $3 ":" $4}')" != "$APP_USER:$APP_GROUP" ]; then 39 | web-chown fix 40 | fi 41 | rm -rf "$(web-chown path)" 42 | fi 43 | -------------------------------------------------------------------------------- /src/php/common/rootfs/etc/hooks/cleanup/00-php-source: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | rm -rf /usr/src/php* || true 3 | 4 | if has-cmd composer; then 5 | composer clearcache -q || true 6 | fi 7 | 8 | if is-true $CLEANUP_PHPDBG && has-cmd phpdbg; then 9 | debug-echo -w 'Removing phpdbg binary' 10 | rm -rf "$(command -v phpdbg)" || true 11 | fi 12 | 13 | if [ -d "$PHP_EXTENSION_DIR" ]; then 14 | chmod -x "$PHP_EXTENSION_DIR"/*.so || true 15 | 16 | if has-cmd strip; then 17 | strip --strip-all --strip-debug "$PHP_EXTENSION_DIR"/*.so || true 18 | fi 19 | fi 20 | -------------------------------------------------------------------------------- /src/php/common/rootfs/etc/hooks/cleanup/00-pkgs: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | if is-true $CLEANUP_DEV_PACKAGES; then 3 | EXTRA_DEPS='*-dev' 4 | fi 5 | 6 | APK_PACKAGES='.persistent-deps tar xz' \ 7 | APT_PACKAGES='cpp-* xz-utils' \ 8 | exec pkg-del $PHPIZE_DEPS $EXTRA_DEPS 9 | -------------------------------------------------------------------------------- /src/php/common/rootfs/etc/hooks/cleanup/00-upgrade: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | is-true $UPGRADE_BEFORE_CLEANUP && pkg-add upgrade 3 | -------------------------------------------------------------------------------- /src/php/common/rootfs/etc/hooks/cleanup/zz-clean-tmp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | find /etc/ -name '*.dpkg-*' -or -name '*-' -exec rm -f {} \; || true 3 | find /var/log/ -type f -exec rm -f {} \; || true 4 | rm -rf $@ $(web-chown path || true) \ 5 | /tmp/* /usr/share/doc/* /var/cache/* /var/lib/apt/lists/* \ 6 | ~/.cache/ ~/.composer/ ~/.git/ ~/.log/ ~/.npm/ ~/.tmp/ || true 7 | -------------------------------------------------------------------------------- /src/php/common/rootfs/etc/hooks/onbuild/00-greeting: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | if [[ "$DOCKER_NAME" != 'shinsenter/'* ]]; then 3 | echo " 4 | 5 | ░█░█░█▀█░█▀▄░█▀█░▀█▀░█▀█░█▀▀░█░█░█ 6 | ░█▄█░█▀█░█▀▄░█░█░░█░░█░█░█░█░▀░▀░▀ 7 | ░▀░▀░▀░▀░▀░▀░▀░▀░▀▀▀░▀░▀░▀▀▀░▀░▀░▀ 8 | 9 | The Docker image you're using is a modified version 10 | of shinsenter/php images. Use it at your own risk. 11 | 12 | You can find the original Docker images from: 13 | Docker Hub: https://hub.docker.com/u/shinsenter 14 | GitHub Packages: https://github.com/shinsenter?tab=packages 15 | 16 | " 17 | elif has-cmd greeting; then greeting; fi 18 | -------------------------------------------------------------------------------- /src/php/common/rootfs/etc/welcome.txt: -------------------------------------------------------------------------------- 1 | ░█▀▀░█░█░▀█▀░█▀█░█▀▀░█▀▀░█▀█░▀█▀░█▀▀░█▀▄░░░█░█▀█░█░█░█▀█ 2 | ░▀▀█░█▀█░░█░░█░█░▀▀█░█▀▀░█░█░░█░░█▀▀░█▀▄░▄▀░░█▀▀░█▀█░█▀▀ 3 | ░▀▀▀░▀░▀░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀░▀░░▀░░▀▀▀░▀░▀░▀░░░▀░░░▀░▀░▀░░ 4 | 5 | If you find my Docker images useful, consider donating via PayPal: 6 | -> https://www.paypal.me/shinsenter 7 | 8 | (To edit this welcome message, add your text to %PATH%) 9 | -------------------------------------------------------------------------------- /src/php/common/rootfs/license: -------------------------------------------------------------------------------- 1 | Docker Images by SHIN Company 2 | Copyright (C) %YEAR% %EMAIL% 3 | 4 | This software is free under the GNU General Public License (GPL). 5 | You can redistribute and/or modify it under the terms of the GNU GPL. 6 | This program is provided with the hope that it will be useful, 7 | but it comes WITHOUT ANY WARRANTY. For more details, refer to the GNU GPL. 8 | 9 | To get support, please contact: %EMAIL% 10 | Docker Hub: https://hub.docker.com/u/shinsenter 11 | GitHub Packages: https://github.com/shinsenter?tab=packages 12 | -------------------------------------------------------------------------------- /src/php/common/rootfs/startup/99-greeting: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | if ! is-true $DISABLE_GREETING && has-cmd greeting; then greeting; fi 3 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/bin/app-path: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # falls back to old $WEBHOME if it is set 3 | if [ ! -z "$WEBHOME" ]; then 4 | echo "$WEBHOME" 5 | else 6 | echo "${APP_PATH:=/var/www/html}" 7 | fi 8 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/bin/app-root: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | document_root="$DOCUMENT_ROOT" 3 | 4 | # falls back to old $APACHE_DOCUMENT_ROOT or $NGINX_DOCUMENT_ROOT if it is set 5 | if [ ! -z "$APACHE_DOCUMENT_ROOT" ]; then 6 | document_root="$APACHE_DOCUMENT_ROOT" 7 | elif [ ! -z "$NGINX_DOCUMENT_ROOT" ]; then 8 | document_root="$NGINX_DOCUMENT_ROOT" 9 | fi 10 | 11 | echo "$(app-path)$document_root" 12 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/bin/debug-echo: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | NC='\033[0m' 4 | case "$1" in 5 | -c|--critical) CL='\033[0;31m'; shift ;; 6 | -e|--error) CL='\033[0;31m'; shift ;; 7 | -s|--success) CL='\033[0;32m'; shift ;; 8 | -w|--warn) CL='\033[0;33m'; shift ;; 9 | -i|--info) CL='\033[0;34m'; shift ;; 10 | -l|--log) CL='\033[0;90m'; shift ;; 11 | *) CL='\033[0;90m'; if ! is-debug; then exit 0; fi ;; 12 | esac 13 | 14 | if [ ! -t 1 ]; then NC=; CL=; fi 15 | 16 | colorize() { 17 | local msg="$@" 18 | if [ ! -z "$msg" ]; then 19 | echo -e "${CL}${msg}${NC}" 20 | fi 21 | } 22 | 23 | colorize "$@" 24 | 25 | if [ ! -t 0 ]; then 26 | while IFS= read -r line; do 27 | colorize "$line" 28 | done 29 | fi 30 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/bin/env-default: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | conf_path="${ENV:=/etc/.docker-env}" 11 | 12 | if [ ! -f $conf_path ]; then 13 | mkdir -p "$(dirname $conf_path)" 14 | echo '#!/bin/sh 15 | APP_PATH="$(app-path)" 16 | if [ -d "$APP_PATH" ]; then cd "$APP_PATH"; fi 17 | 18 | NEW_PATH="$(echo $PATH | sed "s/\/usr\/local\/aliases://")" 19 | if [ ! -z "$COMPOSER_HOME" ] && ! echo $NEW_PATH | grep -qF "$COMPOSER_HOME/vendor/bin"; then NEW_PATH="$COMPOSER_HOME/vendor/bin:$NEW_PATH"; fi 20 | if ! echo $NEW_PATH | grep -qF "$APP_PATH/vendor/bin"; then NEW_PATH="$APP_PATH/vendor/bin:$NEW_PATH"; fi 21 | export PATH="$NEW_PATH" 22 | 23 | ' >$conf_path 24 | chmod +x $conf_path 25 | fi 26 | 27 | if [ $# -eq 0 ]; then 28 | source $conf_path && env -0 | sort -dbfiz | tr '\0' '\n' 29 | exit 30 | fi 31 | 32 | line="$@" 33 | 34 | if [ "${line:0:1}" = "#" ]; then 35 | echo -e "\n${line}\n# ------------------------------------------------------------ #" >>$conf_path 36 | exit 37 | fi 38 | 39 | if [ "${line:0:6}" = "alias " ]; then 40 | echo "$line" >>$conf_path 41 | exit 42 | fi 43 | 44 | name="$1"; shift 45 | set -- "$(echo "$@" | sed -e 's/\([\\"]\)/\\\1/g')" 46 | sed -i "/$name=/d" $conf_path &>/dev/null 47 | echo "if [ -z \${${name}+x} ]; then export $name=\"$@\"; fi" >>$conf_path 48 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/bin/greeting: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | WELCOME_TXT=/etc/welcome.txt 3 | LICENSE_TXT=/license 4 | APP_USER="${APP_USER:=www-data}" 5 | APP_GROUP="${APP_GROUP:=www-data}" 6 | 7 | echo " 8 | $([ -f $WELCOME_TXT ] && cat $WELCOME_TXT | sed "s#%PATH%#$WELCOME_TXT#g") 9 | 10 | --------------- 11 | Container : ${DOCKER_NAME:-shinsenter/php} (built: ${DOCKER_DATE:-$(date +'%Y-%m-%dT%T%z')}) 12 | Distro : $(source /etc/os-release && echo ${PRETTY_NAME:-Unknown}) 13 | Timezone : $(date +'%Z') (GMT$(date +'%z')) 14 | UID / GID : $APP_USER:$APP_GROUP ($(id -u $APP_USER):$(id -g $APP_USER)) 15 | App Root : $(app-path) 16 | Document Root : $(app-root) 17 | --------------- 18 | 19 | $([ -f $LICENSE_TXT ] && cat $LICENSE_TXT | sed "s#%EMAIL%#${MAINTAINER:-shin@shin.company}#g" | sed "s#%YEAR%#$(date +'%Y')#g") 20 | 21 | $(if has-cmd php-fpm; then php-fpm -v; elif has-cmd php; then php -v; fi) 22 | $(if has-cmd composer; then composer -V 2>&1 | head -n1; fi) 23 | " 24 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/bin/has-cmd: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | if [ -x "$(command -v $1)" ]; then exit 0; else exit 1; fi 3 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/bin/has-s6: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | if has-cmd /command/s6-env; then exit 0; else exit 1; fi 3 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/bin/is-debug: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | if is-true $DEBUG_MODE || is-true $DEBUG; then exit 0; else exit 1; fi 3 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/bin/is-true: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | if [ $# -eq 0 ]; then exit 1; fi 11 | 12 | case "$(echo "$1" | tr '[:upper:]' '[:lower:]')" in 13 | ''|'false'|'none'|'null'|'off'|'undefined'|0|false|no) 14 | exit 1 ;; 15 | *) exit 0 ;; 16 | esac 17 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/bin/log-path: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | echo "${DEFAULT_LOG_PATH:-/proc/1/fd/2}" 3 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/bin/os-name: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | if [ -f /etc/os-release ]; then echo $(source /etc/os-release && echo "$ID"); else echo unknown; fi 3 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/bin/vergte: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | if [ "$(printf '%s\n' "$2" "$1" | sort -V | head -n1)" = "$2" ]; then exit 0; else exit 1; fi 3 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/sbin/autorun: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | run_cmd() { 11 | if [ -x "$script" ]; then 12 | debug-echo "\nAutorun script $1" 13 | with-env "$@" 14 | fi 15 | } 16 | 17 | for dir; do 18 | if [ ! -z "$dir" ] && [ -e "$dir" ]; then 19 | dir="$(realpath -s $dir)" 20 | if [ -d "$dir" ]; then 21 | find $dir -type f -name '*.sh' | xargs -r chmod +x &>/dev/null 22 | if has-cmd run-parts; then 23 | with-env run-parts --new-session "$dir" 24 | else 25 | for script in $(find $dir -type f -perm -111 | sort -dbfi); do 26 | run_cmd "$script" 27 | done 28 | fi 29 | else 30 | run_cmd "$dir" 31 | fi 32 | fi 33 | done 34 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/sbin/cleanup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | usage() { du -sh / 2>/dev/null; } 3 | before="$(usage)" 4 | hook cleanup 5 | echo 6 | debug-echo -w "Before cleanup: $before" 7 | debug-echo -s "After cleanup: $(usage)" 8 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/sbin/hook: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | for hook; do autorun "/etc/hooks/$hook" 2>&1; done 10 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/sbin/mkcert: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | INSTALL="0" 11 | CERT="domain.crt" 12 | KEY="domain.key" 13 | DAYS=365 14 | LENGTH=4096 15 | 16 | while [[ $# -gt 0 ]]; do 17 | case $1 in 18 | -l | -length) 19 | shift 20 | LENGTH="$1" 21 | ;; 22 | -c | -cert-file) 23 | shift 24 | CERT="$1" 25 | ;; 26 | -k | -key-file) 27 | shift 28 | KEY="$1" 29 | ;; 30 | -d | -days) 31 | shift 32 | DAYS="$1" 33 | ;; 34 | -i | -install) 35 | INSTALL="1" 36 | ;; 37 | *) 38 | DOMAINS="${DOMAINS}${DOMAINS:+,}$1" 39 | ;; 40 | esac 41 | shift 42 | done 43 | 44 | if [ -z "$DOMAINS" ]; then 45 | debug-echo -w "Usage: ${0##*/} example.com www.example.com [-c domain.crt] [-k domain.key] [-d 365] [-l 4096]" 46 | exit 1 47 | fi 48 | 49 | mkdir -p "$(dirname $CERT)" "$(dirname $KEY)" 50 | rm -rf $CERT $KEY 51 | 52 | debug-echo -w "Generate self-signed CA for $DOMAINS" 53 | openssl dhparam -dsaparam -out "$(dirname $CERT)"/dhparam.pem $LENGTH 54 | openssl req -nodes -x509 -days $DAYS \ 55 | -newkey rsa:$LENGTH -sha256 \ 56 | -keyout $KEY -out $CERT \ 57 | -subj "/CN=${DOMAINS}" 58 | 59 | if [ "$INSTALL" = "1" ]; then 60 | if [ -f /etc/ssl/certs/ca-certificates.crt ]; then 61 | ln -nsf $(realpath $CERT) /etc/ssl/certs/ 62 | elif [ -d /usr/local/share/ca-certificates ]; then 63 | ln -nsf $(realpath $CERT) /usr/local/share/ca-certificates/ 64 | fi 65 | if has-cmd update-ca-certificates; then 66 | update-ca-certificates 67 | fi 68 | fi 69 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/sbin/pkg-add: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | alpine() { 11 | if [ $# -gt 0 ]; then 12 | rm -rf /var/cache/apk && mkdir /var/cache/apk 13 | apk update | debug-echo -l 14 | for pkg; do 15 | if [ "$pkg" = "upgrade" ]; then 16 | apk upgrade --available | debug-echo -l 17 | else 18 | debug-echo -i "\nInstall $pkg" 19 | apk add $pkg | debug-echo -l 20 | fi 21 | done 22 | fi 23 | } 24 | 25 | debian() { 26 | local options="-yq --allow-unauthenticated" 27 | if [ $# -gt 0 ]; then 28 | apt-get update $options | debug-echo -l 29 | for pkg; do 30 | if [ "$pkg" = "upgrade" ] || [ "$pkg" = "update" ]; then 31 | apt-get upgrade $options | debug-echo -l 32 | else 33 | debug-echo -i "\nInstall $pkg" 34 | apt-get install $options --no-install-recommends --no-install-suggests $pkg | debug-echo -l 35 | fi 36 | done 37 | fi 38 | } 39 | 40 | if has-cmd apk; then alpine $APK_PACKAGES "$@"; fi 41 | if has-cmd apt; then debian $APT_PACKAGES "$@"; fi 42 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/sbin/pkg-del: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | alpine() { 11 | if [ $# -gt 0 ]; then 12 | debug-echo -e "\nRemove" $@ 13 | apk del --no-cache --purge "$@" 2>&1 | grep -vF 'No such package' | debug-echo -l 14 | fi 15 | } 16 | 17 | debian() { 18 | if [ $# -gt 0 ]; then 19 | debug-echo -e "\nRemove" $@ 20 | apt-get -yq remove --purge "$@" 2>&1 | grep -vF 'so not removed' | debug-echo -l 21 | fi 22 | 23 | apt-get -yq autoremove --purge | debug-echo -l 24 | apt-get -yq clean | debug-echo -l 25 | } 26 | 27 | if has-cmd apk; then alpine $APK_PACKAGES "$@"; fi 28 | if has-cmd apt; then debian $APT_PACKAGES "$@"; fi 29 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/sbin/s6-service: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Generate S6 service files 11 | # See: https://github.com/just-containers/s6-overlay#writing-a-service-script 12 | 13 | s6="/etc/s6-overlay/s6-rc.d" 14 | set -e 15 | 16 | name="$1" 17 | shift 18 | 19 | if [ -z "$name" ]; then 20 | debug-echo -w "Usage: ${0##*/} [longrun|oneshot|depends|finish|down] [exec script]" 21 | exit 1 22 | fi 23 | 24 | ################################################################################ 25 | 26 | create() { 27 | local path="$1" 28 | local dir="$(dirname $path)" 29 | 30 | mkdir -p $dir && chmod 0755 $dir 31 | touch $path && chmod ugo+x $path 32 | 33 | shift 34 | if [ -f $path ] && [ ! -z "$@" ]; then echo "$@" >| $path; fi 35 | } 36 | 37 | ################################################################################ 38 | 39 | # get service type 40 | type="${1:oneshot}" 41 | shift 42 | 43 | if [ "$type" = "depends" ]; then 44 | create "${s6}/${name}/dependencies.d/$1" 45 | exit $? 46 | fi 47 | 48 | # get script contents 49 | if [ -f "$@" ]; then set -- "$(cat $@)"; fi 50 | 51 | if [ "$type" = "down" ] || [ "$type" = "finish" ]; then 52 | create "${s6}/${name}/${type}" "$@" 53 | exit $? 54 | fi 55 | 56 | ################################################################################ 57 | 58 | if [ "$type" = "oneshot" ]; then 59 | create "${s6}/${name}/up" "exec ${s6}/${name}/run" 60 | fi 61 | 62 | create "${s6}/${name}/run" "$@" 63 | create "${s6}/${name}/type" "$type" 64 | create "${s6}/${name}/dependencies.d/base" 65 | create "${s6}/user/contents.d/${name}" 66 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/sbin/web-chown: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | del_flg=/etc/.fix-ownership 11 | 12 | case "$1" in 13 | fix) 14 | shift 15 | 16 | if [ $# -eq 0 ]; then 17 | rm -rf $del_flg 18 | set -- "$(app-path)" 19 | fi 20 | 21 | for target; do 22 | if [ ! -z "$target" ] && [ -e "$target" ]; then 23 | debug-echo "Fix ownership for $target" 24 | chown -R "$APP_USER:$APP_GROUP" "$target" 2>&1 || true 25 | fi 26 | done 27 | ;; 28 | path) 29 | echo $del_flg 30 | ;; 31 | *) 32 | touch $del_flg 33 | if [ ! -z "$@" ]; then debug-echo "$@"; fi 34 | ;; 35 | esac 36 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/sbin/web-cmd: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | allow_root=0 11 | if [ "$1" == "root" ]; then 12 | allow_root=1 13 | shift 14 | fi 15 | 16 | command=$1 17 | shift 18 | 19 | if [ -z "$command" ] || [ -z "$@" ]; then 20 | debug-echo -w "Usage: ${0##*/} [options]" 21 | exit 1 22 | fi 23 | 24 | if [ "$allow_root" = "1" ]; then 25 | command="/usr/local/aliases/$command" 26 | mkdir -p "$(dirname $command)" 27 | echo "#!/usr/bin/env sh 28 | if [ -d \$(app-path) ]; then cd \$(app-path); fi 29 | exec with-env $@ \"\$@\" 30 | " >$command 31 | chmod 4755 $command 32 | else 33 | command="/usr/local/sbin/$command" 34 | mkdir -p "$(dirname $command)" 35 | echo "#!/usr/bin/env sh 36 | if [ -d \$(app-path) ]; then cd \$(app-path); fi 37 | exec web-do $@ \"\$@\" 38 | " >$command 39 | fi 40 | 41 | chmod +x $command 42 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/sbin/web-do: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | set -- with-env "$@" 11 | 12 | # switch user:group and exec 13 | if has-cmd su-exec; then 14 | exec su-exec "$APP_USER:$APP_GROUP" "$@" 15 | else 16 | exec chroot --userspec="$APP_USER:$APP_GROUP" / "$@" 17 | fi 18 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/sbin/web-mkdir: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | for dir; do 11 | if [ ! -z "$dir" ] && [ ! -f "$dir" ]; then 12 | mkdir -vpm 4755 "$dir" 13 | if [ -d "$dir" ]; then chown "$APP_USER:$APP_GROUP" "$dir"; fi 14 | fi 15 | done 16 | -------------------------------------------------------------------------------- /src/php/common/rootfs/usr/local/sbin/with-env: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | DEFAULT_ENV=/etc/.docker-env 11 | 12 | # load extra env variables 13 | if [ -e /etc/environment ]; then 14 | set -a 15 | source /etc/environment 16 | set +a 17 | fi 18 | 19 | # load extra env variables 20 | if [ "$ENV" != "$DEFAULT_ENV" ] && [ -x "$DEFAULT_ENV" ]; then source "$DEFAULT_ENV"; fi 21 | if [ -x "$ENV" ]; then source "$ENV"; fi 22 | 23 | if [ $# -eq 0 ]; then 24 | # print the environment variables when no command is given 25 | exec env -0 | sort -dbfiz | tr '\0' '\n' 26 | else 27 | # execute the command 28 | exec "$@" 29 | fi 30 | -------------------------------------------------------------------------------- /src/php/common/shell-php/phpaddmod: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | if ! has-cmd php; then exit 0; fi 10 | if ! has-cmd install-php-extensions; then exit 0; fi 11 | 12 | INSTALLED_MODS="$(php -m 2>/dev/null | grep -v '^\[' | tr '[:upper:]' '[:lower:]')" 13 | 14 | for module; do 15 | if [ ! -z "$module" ] && grep -q "\<$module\>" <<< "$INSTALLED_MODS"; then 16 | debug-echo -i "Module $module is already installed." 17 | else 18 | NEW_MODS="$NEW_MODS${NEW_MODS:+ }$module" 19 | fi 20 | done 21 | 22 | if [ -z "$NEW_MODS" ]; then 23 | exit 0 24 | fi 25 | 26 | if ! has-cmd gcc; then 27 | debug-echo -i "\nInstall build tools" 28 | APK_PACKAGES="tar xz" \ 29 | APT_PACKAGES="xz-utils" \ 30 | pkg-add $PHPIZE_DEPS curl 31 | fi 32 | 33 | if [ ! -e "/usr/src/php.tar.xz" ] && [ ! -z "$PHP_URL" ]; then 34 | debug-echo -i "\nDownload PHP source from $PHP_URL" 35 | curl --retry 3 --retry-delay 5 -ksL "$PHP_URL" -o /usr/src/php.tar.xz 36 | 37 | if [ ! -z "$PHP_ASC_URL" ]; then 38 | curl --retry 3 --retry-delay 5 -ksL "$PHP_ASC_URL" -o /usr/src/php.tar.xz.asc 39 | fi 40 | fi 41 | 42 | PID=/tmp/$(php -r 'echo md5(uniqid());' || echo "$0-temp") 43 | 44 | set -o pipefail 45 | debug-echo -w "\nInstall PHP modules: $NEW_MODS" 46 | 47 | if is-debug; then env-default | grep IPE_ | debug-echo -i; fi 48 | 49 | with-env install-php-extensions $NEW_MODS | while read -r line; do 50 | echo "$line" 51 | if [[ "$line" == *"only for installation"* ]]; then 52 | echo ${line##*:} | xargs echo -n >$PID 53 | fi 54 | done | grep -vF StandWith | debug-echo -l 55 | 56 | EXIT_CODE=$? 57 | 58 | # clean up when failed 59 | if [ $EXIT_CODE -ne 0 ] && [ -f $PID ]; then 60 | pkg-del $(cat $PID) 61 | rm -f $PID 62 | fi 63 | 64 | exit $EXIT_CODE 65 | -------------------------------------------------------------------------------- /src/php/common/shell-php/phpdelmod: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | if ! has-cmd php; then exit 0; fi 10 | 11 | if [ -d "${PHP_INI_DIR}/conf.d" ]; then 12 | while [[ $# -gt 0 ]]; do 13 | MODULE="$1" 14 | PATTERN="/^extension *= *$MODULE/s/^/;/g" 15 | shift 16 | debug-echo -e "Disable PHP module $MODULE" 17 | sed -i "$PATTERN" "${PHP_INI_DIR}/conf.d"/*.ini &>/dev/null 18 | done 19 | fi 20 | -------------------------------------------------------------------------------- /src/php/meta.dockerfile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | # ARG BUILDPLATFORM 10 | # ARG BUILDOS 11 | # ARG BUILDARCH 12 | # ARG BUILDVARIANT 13 | # ARG TARGETPLATFORM 14 | # ARG TARGETOS 15 | # ARG TARGETARCH 16 | # ARG TARGETVARIAN 17 | 18 | ARG BUILD_REVISION 19 | ARG BUILD_DATE 20 | ARG BUILD_NAME="${BUILD_NAME:-shinsenter/php}" 21 | ARG BUILD_TAG="${BUILD_TAG:-"$BUILD_NAME:latest"}" 22 | ARG BUILD_DESC="${BUILD_DESC:-(PHP) A set of prebuilt PHP Docker images that simplify customization and extension installation.}" 23 | 24 | ENV DOCKER_NAME="$BUILD_NAME" 25 | ENV DOCKER_TAG="$BUILD_TAG" 26 | ENV DOCKER_DATE="$BUILD_DATE" 27 | ENV MAINTAINER="SHIN Company " 28 | 29 | LABEL org.opencontainers.image.authors="$MAINTAINER" 30 | LABEL org.opencontainers.image.created="$BUILD_DATE" 31 | LABEL org.opencontainers.image.description="$BUILD_DESC" 32 | LABEL org.opencontainers.image.documentation="https://hub.docker.com/r/${BUILD_NAME}" 33 | LABEL org.opencontainers.image.licenses="GPL-3.0" 34 | LABEL org.opencontainers.image.revision="$BUILD_REVISION" 35 | LABEL org.opencontainers.image.source="https://github.com/shinsenter/php" 36 | LABEL org.opencontainers.image.title="$BUILD_NAME" 37 | LABEL org.opencontainers.image.url="https://hub.docker.com/r/${BUILD_NAME}/tags" 38 | LABEL org.opencontainers.image.vendor="Docker Hub" 39 | -------------------------------------------------------------------------------- /src/php/with-apache.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | # ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-php} 18 | # ARG PHP_VERSION=${PHP_VERSION:-8.4} 19 | # ARG PHP_VARIANT=${PHP_VARIANT:-fpm-alpine} 20 | 21 | # FROM ./base-php AS php 22 | # ARG BUILDKIT_SBOM_SCAN_STAGE=true 23 | 24 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/php} 25 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 26 | 27 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 28 | ARG PHP_VARIANT=${PHP_VARIANT:-fpm-alpine} 29 | 30 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}${PHP_VERSION}-${PHP_VARIANT} 31 | ONBUILD RUN hook onbuild 32 | 33 | ################################################################################ 34 | 35 | INCLUDE ./with-apache/apache-install 36 | INCLUDE ./with-apache/apache-config 37 | INCLUDE ./common/os-s6-overlay 38 | 39 | RUN apache2 -v 40 | 41 | ################################################################################ 42 | 43 | EXPOSE 80 44 | EXPOSE 443 45 | EXPOSE 443/udp 46 | 47 | CMD [] 48 | 49 | ################################################################################ 50 | 51 | INCLUDE ./meta 52 | 53 | ################################################################################ 54 | 55 | LABEL traefik.enable=true 56 | -------------------------------------------------------------------------------- /src/php/with-apache/apache-config.dockerfile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | ADD --link ./with-apache/rootfs/ / 10 | 11 | ################################################################################ 12 | 13 | ENV PHP_LISTEN='/run/php-fpm.sock' 14 | 15 | ################################################################################ 16 | 17 | RUN <<'EOF' 18 | echo 'Configure Apache2' 19 | 20 | env-default '# Disable PHP-FPM logging to stdout' 21 | env-default PHP_ACCESS_LOG '/var/log/php-fpm.log' 22 | 23 | env-default '# Environment variables for Apache2' 24 | env-default APACHE_LOG_LEVEL 'error' 25 | env-default APACHE_ERROR_LOG '$(log-path)' 26 | env-default APACHE_ACCESS_LOG '$(log-path)' 27 | env-default APACHE_MAX_CONNECTIONS_PER_CHILD '0' 28 | env-default APACHE_MAX_REQUEST_WORKERS '150' 29 | env-default APACHE_MAX_SPARE_SERVERS '10' 30 | env-default APACHE_MAX_SPARE_THREADS '75' 31 | env-default APACHE_MIN_SPARE_SERVERS '5' 32 | env-default APACHE_MIN_SPARE_THREADS '10' 33 | env-default APACHE_START_SERVERS '2' 34 | env-default APACHE_THREADS_PER_CHILD '25' 35 | 36 | CONF_FILE=/etc/apache2/apache2.conf 37 | MODS_FILE=/etc/apache2/modules.conf 38 | 39 | if [ -e $CONF_FILE ]; then 40 | # detect available modules 41 | if [ -e /etc/apache2/modules ]; then 42 | echo -e "# Begin Modules\n# End Modules" >$MODS_FILE 43 | for module_path in /etc/apache2/modules/*.so ; do 44 | module="${module_path##*mod_}" 45 | module="${module/.so/_module}" 46 | echo "Found ${module} at ${module_path}" 47 | sed -i "s|^# End Modules|#LoadModule ${module} ${module_path}\n# End Modules|" $MODS_FILE >/dev/null 2>&1 48 | done 49 | fi 50 | 51 | # copy production config 52 | if has-cmd httpd; then 53 | mv -f $CONF_FILE /etc/apache2/httpd.conf 54 | fi 55 | fi 56 | 57 | # create folders 58 | mkdir -p /etc/apache2 \ 59 | /etc/apache2/custom.d \ 60 | /etc/apache2/conf-enabled \ 61 | /etc/apache2/mods-enabled \ 62 | /etc/apache2/sites-enabled \ 63 | /run/apache2 \ 64 | /var/lib/apache2 \ 65 | /var/log/apache2 \ 66 | /usr/logs 67 | 68 | # configure default modules 69 | a2dismod ado auth_digest autoindex cgi dav dbd include info mpm_prefork php reqtimeout userdir 2>&1 || true 70 | a2enmod \ 71 | access_compat alias auth_basic authn_core authn_file authz_core authz_host \ 72 | cache cgid deflate dir env expires filter headers http2 log_config mime mime_magic \ 73 | mpm_event negotiation proxy proxy_fcgi remoteip rewrite setenvif ssl status unixd 2>&1 || true 74 | 75 | # fix ProxyFCGIBackendType directive for Apache 2.4 76 | if apache-test 'ProxyFCGIBackendType'; then 77 | echo 'Disable ProxyFCGIBackendType because it is not supported in this Apache version' 78 | sed -i 's/ProxyFCGIBackendType/#ProxyFCGIBackendType/g' $CONF_FILE 79 | fi 80 | 81 | # create s6 services 82 | if has-cmd s6-service; then 83 | s6-service php-fpm longrun '#!/usr/bin/env sh 84 | cd "$(app-path)" 85 | exec php-fpm -y /usr/local/etc/php-fpm.d/zz-generated-settings.conf --nodaemonize --allow-to-run-as-root -d clear_env=no' 86 | 87 | s6-service apache depends php-fpm 88 | s6-service apache longrun '#!/usr/bin/env sh 89 | export APP_PATH="$(app-path)" 90 | export APP_ROOT="$(app-root)" 91 | if [ -f /etc/apache2/envvars ]; then source /etc/apache2/envvars; fi 92 | 93 | cd $APP_PATH 94 | rm -f ${APACHE_PID:-/run/apache2.pid} 95 | if is-debug; then 96 | exec apache2 -e error -DFOREGROUND -X 97 | else 98 | exec apache2 -e error -DFOREGROUND 99 | fi 100 | ' 101 | fi 102 | 103 | EOF 104 | -------------------------------------------------------------------------------- /src/php/with-apache/apache-install.dockerfile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | ENV APACHE_PID=/run/apache2.pid 10 | 11 | # Install Apache2 12 | RUN <<'EOF' 13 | echo 'Install Apache2' 14 | [ -z "$DEBUG" ] || set -ex && set -e 15 | 16 | # install apache 17 | APK_PACKAGES="apache2 apache2-proxy apache2-ssl apache2-utils" \ 18 | APT_PACKAGES="apache2" \ 19 | pkg-add 20 | 21 | # clean up 22 | rm -rf /etc/init.d/apache* \ 23 | /etc/ssl/apache* \ 24 | /var/www \ 25 | /etc/apache2/modules* \ 26 | /etc/apache2/conf.d \ 27 | /etc/apache2/conf-*/* \ 28 | /etc/apache2/mods-*/* \ 29 | /etc/apache2/sites-*/* \ 30 | /etc/apache2/apache2.conf \ 31 | /etc/apache2/httpd.conf \ 32 | /etc/apache2/ports.conf \ 33 | $APP_PATH/* 34 | 35 | # copy mime types 36 | if [ -f /etc/mime.types ]; then 37 | cp -rf /etc/mime.types /etc/apache2/mime.types 38 | fi 39 | 40 | # link modules directory 41 | module_dir="$(dirname $(find /usr/lib/ -type f -name mod_mpm_event.so | head -n 1))" 42 | if [ -d "$module_dir" ]; then 43 | rm -rf /etc/apache2/modules 44 | ln -nsf "$module_dir" /etc/apache2/modules 45 | 46 | if has-cmd strip; then 47 | strip --strip-all --strip-debug "$module_dir"/*.so 48 | fi 49 | fi 50 | 51 | # alias for apache2 52 | if has-cmd httpd && ! has-cmd apache2; then 53 | ln -nsf "$(command -v httpd)" "/usr/local/sbin/apache2" 54 | fi 55 | 56 | EOF 57 | -------------------------------------------------------------------------------- /src/php/with-apache/rootfs/etc/apache2/sites-enabled/00-default.conf: -------------------------------------------------------------------------------- 1 | Listen 80 2 | 3 | DocumentRoot ${APP_ROOT} 4 | FallbackResource /index.php 5 | IncludeOptional /etc/apache2/custom.d/*.conf 6 | 7 | 8 | 9 | Listen 443 10 | 11 | DocumentRoot ${APP_ROOT} 12 | FallbackResource /index.php 13 | IncludeOptional /etc/apache2/custom.d/*.conf 14 | 15 | Protocols h2 http/1.1 16 | SSLEngine On 17 | SSLCertificateFile /etc/ssl/site/server.crt 18 | SSLCertificateKeyFile /etc/ssl/site/server.key 19 | SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/php/with-apache/rootfs/etc/cont-init.d/zz-start-apache: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | export APP_PATH="$(app-path)" 11 | export APP_ROOT="$(app-root)" 12 | export APACHE_PID="${APACHE_PID:-/run/apache2.pid}" 13 | 14 | if [ ! -z "$PHP_MAX_EXECUTION_TIME" ] && [ "$PHP_MAX_EXECUTION_TIME" -gt "0" ]; then 15 | echo " 16 | Timeout ${PHP_MAX_EXECUTION_TIME} 17 | 18 | ProxyTimeout ${PHP_MAX_EXECUTION_TIME} 19 | 20 | " >/etc/apache2/conf-enabled/timeout.conf 21 | fi 22 | 23 | if ! is-true $DISABLE_GREETING && has-cmd apache2; then 24 | apache2 -v 2>&1 25 | fi 26 | 27 | if is-debug; then 28 | apache-conf 'LogLevel' 'debug' 29 | debug-echo -w "🐞 Apache is in DEBUG MODE 🐞" 30 | apache2 -S 31 | else 32 | apache-conf 'LogLevel' '${APACHE_LOG_LEVEL}' 33 | fi 34 | 35 | if [ -f /etc/apache2/envvars ]; then 36 | source /etc/apache2/envvars 37 | fi 38 | 39 | web-mkdir "$APACHE_LOG_DIR" "$APACHE_LOCK_DIR" "$APACHE_RUN_DIR" 40 | web-chown fix \ 41 | "$APACHE_LOG_DIR" "$APACHE_LOCK_DIR" "$APACHE_RUN_DIR" \ 42 | /var/lib/apache2 /var/log/apache2 /run/apache2 43 | 44 | if is-true $ENABLE_TUNING_MPM; then 45 | debug-echo -w "Tune Apache MPM" 46 | apache-mpm 47 | fi 48 | 49 | exec apache2 -t 50 | -------------------------------------------------------------------------------- /src/php/with-apache/rootfs/usr/local/sbin/a2dismod: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | while [[ $# -gt 0 ]]; do 11 | MODULE="$1" 12 | PATTERN="/^LoadModule ${MODULE}_module/s/^/#/g" 13 | shift 14 | debug-echo -e "Disable Apache module $MODULE" 15 | sed -i "$PATTERN" /etc/apache2/*.conf &>/dev/null 16 | done 17 | -------------------------------------------------------------------------------- /src/php/with-apache/rootfs/usr/local/sbin/a2enmod: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | while [[ $# -gt 0 ]]; do 11 | MODULE="$1" 12 | PATTERN="/^#LoadModule ${MODULE}_module/s/^#//g" 13 | shift 14 | debug-echo -i "Enable Apache module $MODULE" 15 | sed -i "$PATTERN" /etc/apache2/*.conf &>/dev/null 16 | done 17 | -------------------------------------------------------------------------------- /src/php/with-apache/rootfs/usr/local/sbin/apache-conf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | conf_dir=/etc/apache2 11 | disable="$([ "${1:0:1}" = "#" ] && echo "# " || echo "")" 12 | name="${1/#/}"; shift 13 | if [ -d $conf_dir ]; then 14 | grep -lr "^ *#* *${name} " $conf_dir | grep '\.conf$' | xargs -r sed -i "s~^ *#* *${name} *.*\$~${disable}${name} $@~g" &>/dev/null 15 | fi 16 | -------------------------------------------------------------------------------- /src/php/with-apache/rootfs/usr/local/sbin/apache-mpm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | config="${1:-/etc/apache2/conf-enabled/mpm_tuning.conf}" 11 | 12 | # Gather system information 13 | cpu_cores=$(grep -c ^processor /proc/cpuinfo) 14 | ram_mb=$(free -m | awk '/^Mem:/{print $2}') 15 | 16 | # Determine appropriate MPM module 17 | if [ "$(apache2 -M | grep mpm_prefork)"]; then 18 | mpm_module='prefork' 19 | else 20 | mpm_module='event' 21 | fi 22 | 23 | # Set MPM-specific directives based on system specs and best practices 24 | if [[ $mpm_module == "prefork" ]]; then 25 | start_servers=$((cpu_cores * 5)) 26 | min_spare_servers=$((cpu_cores * 2)) 27 | max_spare_servers=$((cpu_cores * 10)) 28 | max_clients=$((ram_mb / 10)) 29 | max_requests_per_child=1000 30 | cat <$config 31 | 32 | ServerLimit 20000 33 | StartServers $start_servers 34 | MinSpareServers $min_spare_servers 35 | MaxSpareServers $max_spare_servers 36 | MaxRequestWorkers $max_clients 37 | MaxConnectionsPerChild $max_requests_per_child 38 | 39 | EOF 40 | else 41 | start_servers=$((cpu_cores * 2)) 42 | min_spare_threads=$((cpu_cores * 10)) 43 | max_spare_threads=$((cpu_cores * 20)) 44 | threads_per_child=25 45 | max_clients=$((ram_mb / 10 / threads_per_child * threads_per_child)) 46 | cat <$config 47 | 48 | ServerLimit 20000 49 | StartServers $start_servers 50 | MinSpareThreads $min_spare_threads 51 | MaxSpareThreads $max_spare_threads 52 | ThreadsPerChild $threads_per_child 53 | MaxRequestWorkers $max_clients 54 | MaxConnectionsPerChild 0 55 | 56 | EOF 57 | fi 58 | -------------------------------------------------------------------------------- /src/php/with-apache/rootfs/usr/local/sbin/apache-test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | exec with-env apache2 -t 2>&1 | grep -qF "$@" 3 | -------------------------------------------------------------------------------- /src/php/with-f8p.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | # ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-php} 18 | # ARG PHP_VERSION=${PHP_VERSION:-8.4} 19 | # ARG PHP_VARIANT=${PHP_VARIANT:-zts-alpine} 20 | # ARG BUILD_SOURCE_IMAGE=${BUILD_SOURCE_IMAGE:-dunglas/frankenphp:1-php${PHP_VERSION}} 21 | 22 | # FROM $BUILD_SOURCE_IMAGE AS frankenphp 23 | # FROM ./base-php AS php 24 | # ARG BUILDKIT_SBOM_SCAN_STAGE=true 25 | 26 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/php} 27 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 28 | 29 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 30 | ARG PHP_VARIANT=${PHP_VARIANT:-zts-alpine} 31 | ARG BUILD_SOURCE_IMAGE=${BUILD_SOURCE_IMAGE:-dunglas/frankenphp:1-php${PHP_VERSION}} 32 | 33 | FROM ${BUILD_SOURCE_IMAGE} AS frankenphp 34 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}${PHP_VERSION}-${PHP_VARIANT} 35 | ONBUILD RUN hook onbuild 36 | 37 | ################################################################################ 38 | 39 | INCLUDE ./with-f8p/f8p-install 40 | INCLUDE ./with-f8p/f8p-config 41 | INCLUDE ./common/os-s6-overlay 42 | 43 | RUN frankenphp version 44 | 45 | ################################################################################ 46 | 47 | EXPOSE 2019 48 | EXPOSE 80 49 | EXPOSE 443 50 | EXPOSE 443/udp 51 | 52 | CMD [] 53 | HEALTHCHECK CMD curl -sf http://localhost:2019/metrics || exit 1 54 | 55 | ################################################################################ 56 | 57 | INCLUDE ./meta 58 | 59 | ARG BUILD_SOURCE_IMAGE 60 | LABEL build_from="$BUILD_SOURCE_IMAGE" 61 | 62 | ################################################################################ 63 | 64 | LABEL traefik.enable=true 65 | -------------------------------------------------------------------------------- /src/php/with-f8p/f8p-config.dockerfile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | ADD --link ./with-f8p/rootfs/ / 10 | 11 | ################################################################################ 12 | 13 | # See https://caddyserver.com/docs/conventions#file-locations for details 14 | ENV GODEBUG="cgocheck=0" 15 | ENV XDG_CONFIG_HOME="/config" 16 | ENV XDG_DATA_HOME="/data" 17 | 18 | ################################################################################ 19 | 20 | RUN <<'EOF' 21 | echo 'Configure FrankenPHP' 22 | 23 | env-default '# Environment variables for Caddy' 24 | env-default CADDY_GLOBAL_OPTIONS '' 25 | env-default CADDY_EXTRA_CONFIG '' 26 | env-default CADDY_SERVER_EXTRA_DIRECTIVES '' 27 | 28 | if [ -f /etc/caddy/Caddyfile ]; then 29 | frankenphp fmt --overwrite /etc/caddy/Caddyfile 30 | fi 31 | 32 | # create s6 services 33 | if has-cmd s6-service; then 34 | s6-service frankenphp longrun '#!/usr/bin/env sh 35 | export APP_PATH="$(app-path)" 36 | export APP_ROOT="$(app-root)" 37 | if [ -f /etc/caddy/envvars ]; then source /etc/caddy/envvars; fi 38 | 39 | cd $APP_PATH 40 | exec frankenphp run --config /etc/caddy/Caddyfile --adapter caddyfile 41 | ' 42 | fi 43 | 44 | EOF 45 | -------------------------------------------------------------------------------- /src/php/with-f8p/f8p-install.dockerfile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | # Copy files from the official image 10 | COPY --link --from=frankenphp /usr/local/lib/libwatcher* /usr/local/lib/ 11 | COPY --link --from=frankenphp /usr/local/bin/frankenphp /usr/local/bin/frankenphp 12 | 13 | ################################################################################ 14 | 15 | # Install FrankenPHP 16 | RUN <<'EOF' 17 | echo 'Install FrankenPHP' 18 | [ -z "$DEBUG" ] || set -ex && set -e 19 | 20 | # install common packages 21 | APK_PACKAGES='libstdc++ mailcap libcap' \ 22 | APT_PACKAGES='libstdc++6 mailcap libcap2-bin' \ 23 | pkg-add && ldconfig /usr/local/lib 24 | 25 | mkdir -p /config/caddy /data/caddy /etc/caddy 26 | 27 | if ! has-cmd frankenphp; then 28 | exit 1 29 | fi 30 | 31 | setcap cap_net_bind_service=+ep "$(command -v frankenphp)" 32 | ln -nsf "$(command -v frankenphp)" /usr/local/sbin/caddy 33 | 34 | EOF 35 | -------------------------------------------------------------------------------- /src/php/with-f8p/rootfs/etc/caddy/Caddyfile: -------------------------------------------------------------------------------- 1 | { 2 | {$CADDY_GLOBAL_OPTIONS} 3 | 4 | frankenphp { 5 | # worker {$APP_PATH}{$DOCUMENT_ROOT}/index.php 6 | {$FRANKENPHP_CONFIG} 7 | } 8 | } 9 | 10 | {$CADDY_EXTRA_CONFIG} 11 | 12 | {$SERVER_NAME:localhost} { 13 | log { 14 | format filter { 15 | request>uri query { 16 | replace authorization REDACTED 17 | } 18 | } 19 | } 20 | 21 | tls /etc/ssl/site/server.crt /etc/ssl/site/server.key 22 | 23 | root * {$APP_PATH}{$DOCUMENT_ROOT} 24 | encode zstd br gzip 25 | 26 | {$CADDY_SERVER_EXTRA_DIRECTIVES} 27 | 28 | php_server 29 | } 30 | 31 | # Source: https://raw.githubusercontent.com/dunglas/frankenphp/main/caddy/frankenphp/Caddyfile -------------------------------------------------------------------------------- /src/php/with-f8p/rootfs/etc/cont-init.d/zz-start-f8p: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | web-mkdir /config/caddy /data/caddy /etc/caddy 11 | 12 | if ! is-true $DISABLE_GREETING && has-cmd frankenphp; then 13 | frankenphp version 2>&1 14 | fi 15 | 16 | if is-debug; then 17 | echo 'export CADDY_GLOBAL_OPTIONS="$CADDY_GLOBAL_OPTIONS debug"' >/etc/caddy/envvars || true 18 | debug-echo -w "🐞 FrankenPHP is in DEBUG MODE 🐞" 19 | else 20 | rm -f /etc/caddy/envvars || true 21 | fi 22 | -------------------------------------------------------------------------------- /src/php/with-f8p/rootfs/usr/local/bin/f8p-conf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | -------------------------------------------------------------------------------- /src/php/with-nginx.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | # ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-php} 18 | # ARG PHP_VERSION=${PHP_VERSION:-8.4} 19 | # ARG PHP_VARIANT=${PHP_VARIANT:-fpm-alpine} 20 | 21 | # FROM ./base-php AS php 22 | # ARG BUILDKIT_SBOM_SCAN_STAGE=true 23 | 24 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/php} 25 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 26 | 27 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 28 | ARG PHP_VARIANT=${PHP_VARIANT:-fpm-alpine} 29 | 30 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}${PHP_VERSION}-${PHP_VARIANT} 31 | ONBUILD RUN hook onbuild 32 | 33 | ################################################################################ 34 | 35 | INCLUDE ./with-nginx/nginx-install 36 | INCLUDE ./with-nginx/nginx-config 37 | INCLUDE ./common/os-s6-overlay 38 | 39 | RUN nginx -V 40 | 41 | ################################################################################ 42 | 43 | EXPOSE 80 44 | EXPOSE 443 45 | EXPOSE 443/udp 46 | 47 | CMD [] 48 | 49 | ################################################################################ 50 | 51 | INCLUDE ./meta 52 | 53 | ################################################################################ 54 | 55 | LABEL traefik.enable=true 56 | -------------------------------------------------------------------------------- /src/php/with-nginx/nginx-config.dockerfile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | ADD --link ./with-nginx/rootfs/ / 10 | 11 | ################################################################################ 12 | 13 | ENV PHP_LISTEN='/run/php-fpm.sock' 14 | 15 | ################################################################################ 16 | 17 | RUN <<'EOF' 18 | echo 'Configure Nginx' 19 | 20 | usermod -G $APP_GROUP,nginx nginx >/dev/null 2>&1 21 | usermod -G $APP_GROUP,nginx $APP_USER >/dev/null 2>&1 22 | 23 | env-default '# Disable PHP-FPM logging to stdout' 24 | env-default PHP_ACCESS_LOG '/var/log/php-fpm.log' 25 | 26 | # create folders 27 | mkdir -p /etc/nginx \ 28 | /etc/nginx/custom.d \ 29 | /etc/nginx/modules-enabled \ 30 | /etc/nginx/sites-enabled \ 31 | /var/tmp/nginx \ 32 | /var/tmp/nginx/client_body \ 33 | /var/tmp/nginx/proxy \ 34 | /var/tmp/nginx/fastcgi \ 35 | /var/tmp/nginx/uwsgi \ 36 | /var/tmp/nginx/scgi \ 37 | /var/lib/nginx /var/log/nginx /run/nginx 38 | 39 | # disable TLSv1.3 when not supported 40 | if nginx-test 'invalid value "TLSv1.3"'; then 41 | echo 'Disable TLSv1.3 because it is not supported in this Nginx version' 42 | nginx-conf 'ssl_protocols' 'TLSv1.2' 43 | fi 44 | 45 | # fix deprecated listen http2 directive for Nginx 1.25.1 46 | if nginx-test 'use the "http2" directive'; then 47 | sed -i 's/listen \(.\+\?\) http2/listen \1/g' /etc/nginx/sites-enabled/*.conf >/dev/null 2>&1 48 | echo "http2 on;" >/etc/nginx/custom.d/00-ext-http2.conf 49 | fi 50 | 51 | # customize extensions 52 | if nginx-test 'brotli'; then rm -f /etc/nginx/custom.d/*brotli.conf; fi 53 | if nginx-test 'gzip'; then rm -f /etc/nginx/custom.d/*gzip.conf; fi 54 | if nginx-test 'http3'; then rm -f /etc/nginx/custom.d/*http3.conf; fi 55 | 56 | # create s6 services 57 | if has-cmd s6-service; then 58 | s6-service php-fpm longrun '#!/usr/bin/env sh 59 | cd "$(app-path)" 60 | exec php-fpm -y /usr/local/etc/php-fpm.d/zz-generated-settings.conf --nodaemonize --allow-to-run-as-root -d clear_env=no' 61 | 62 | s6-service nginx depends php-fpm 63 | s6-service nginx longrun '#!/usr/bin/env sh 64 | export APP_PATH="$(app-path)" 65 | export APP_ROOT="$(app-root)" 66 | 67 | cd $APP_PATH 68 | rm -rf ${NGINX_PID:-/run/nginx.pid} 69 | exec nginx -g "daemon off;" 70 | ' 71 | fi 72 | 73 | EOF 74 | -------------------------------------------------------------------------------- /src/php/with-nginx/nginx-install.dockerfile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | ENV NGINX_PID=/run/nginx.pid 10 | 11 | # Install Nginx 12 | RUN <<'EOF' 13 | echo 'Install Nginx' 14 | [ -z "$DEBUG" ] || set -ex && set -e 15 | 16 | # install nginx 17 | pkg-add nginx 18 | 19 | # clean up 20 | rm -rf /var/www/localhost \ 21 | /etc/init.d/nginx* \ 22 | /etc/ssl/nginx* \ 23 | /etc/nginx/nginx.conf \ 24 | /etc/nginx/http.d \ 25 | /etc/nginx/modules-* \ 26 | /etc/nginx/sites-* \ 27 | /etc/nginx/conf-* \ 28 | $APP_PATH/* 29 | EOF 30 | -------------------------------------------------------------------------------- /src/php/with-nginx/rootfs/etc/cont-init.d/zz-start-nginx: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | nginx-conf 'user' "$APP_USER $APP_GROUP" 11 | nginx-conf 'pid' "${NGINX_PID:-/run/nginx.pid}" 12 | 13 | # set variables 14 | echo " 15 | set \$APP_PATH $(app-path); 16 | set \$APP_ROOT $(app-root); 17 | " >/etc/nginx/custom.d/00-set-variables.conf 18 | 19 | # adjust max upload size 20 | if [ ! -z "$PHP_POST_MAX_SIZE" ]; then 21 | echo "client_max_body_size ${PHP_POST_MAX_SIZE};" >/etc/nginx/custom.d/00-client_max_body_size.conf 22 | fi 23 | 24 | # adjust max timeout 25 | if [ ! -z "$PHP_MAX_EXECUTION_TIME" ] && [ "$PHP_MAX_EXECUTION_TIME" -gt "0" ]; then 26 | echo " 27 | send_timeout ${PHP_MAX_EXECUTION_TIME}; 28 | client_body_timeout ${PHP_MAX_EXECUTION_TIME}; 29 | " >/etc/nginx/custom.d/00-client_body_timeout.conf 30 | 31 | echo " 32 | proxy_connect_timeout ${PHP_MAX_EXECUTION_TIME}; 33 | proxy_read_timeout ${PHP_MAX_EXECUTION_TIME}; 34 | proxy_send_timeout ${PHP_MAX_EXECUTION_TIME}; 35 | " >/etc/nginx/custom.d/00-proxy_timeout.conf 36 | fi 37 | 38 | web-chown fix /var/lib/nginx /var/log/nginx /run/nginx 39 | 40 | # turn on or off ssl_stapling 41 | if nginx-test '"ssl_stapling" ignored'; then 42 | nginx-conf 'ssl_stapling' 'off'; 43 | else 44 | nginx-conf 'ssl_stapling' 'off'; 45 | fi 46 | 47 | # enable debug logs 48 | if is-debug; then 49 | nginx-conf 'error_log' "$(log-path) debug" 50 | debug-echo -w "🐞 Nginx is in DEBUG MODE 🐞" 51 | else 52 | nginx-conf 'error_log' "$(log-path) error" 53 | fi 54 | 55 | if ! is-true $DISABLE_GREETING && has-cmd nginx; then 56 | nginx -v 2>&1 57 | fi 58 | 59 | exec nginx -t 60 | -------------------------------------------------------------------------------- /src/php/with-nginx/rootfs/etc/nginx/custom.d/00-ext-brotli.conf: -------------------------------------------------------------------------------- 1 | # brotli 2 | brotli on; 3 | brotli_comp_level 6; 4 | brotli_static on; 5 | brotli_types 6 | application/atom+xml 7 | application/csv 8 | application/ecmascript 9 | application/javascript 10 | application/json 11 | application/ld+json 12 | application/manifest+json 13 | application/octet-stream 14 | application/rss+xml 15 | application/vnd.geo+json 16 | application/vnd.ms-fontobject 17 | application/x-font 18 | application/x-font-opentype 19 | application/x-font-otf 20 | application/x-font-truetype 21 | application/x-font-ttf 22 | application/x-javascript 23 | application/x-web-app-manifest+json 24 | application/xhtml+xml 25 | application/xml 26 | font/eot 27 | font/opentype 28 | font/otf 29 | font/truetype 30 | font/ttf 31 | font/woff 32 | font/woff2 33 | image/bmp 34 | image/svg+xml 35 | image/vnd.microsoft.icon 36 | image/x-icon 37 | image/x-win-bitmap 38 | text/cache-manifest 39 | text/calendar 40 | text/css 41 | text/csv 42 | text/javascript 43 | text/plain 44 | text/vcard 45 | text/vnd.rim.location.xloc 46 | text/vtt 47 | text/x-component 48 | text/x-cross-domain-policy 49 | text/xml; 50 | -------------------------------------------------------------------------------- /src/php/with-nginx/rootfs/etc/nginx/custom.d/00-ext-gzip.conf: -------------------------------------------------------------------------------- 1 | # gzip 2 | gzip on; 3 | gzip_vary on; 4 | gzip_proxied any; 5 | gzip_comp_level 6; 6 | gzip_types 7 | application/atom+xml 8 | application/csv 9 | application/ecmascript 10 | application/javascript 11 | application/json 12 | application/ld+json 13 | application/manifest+json 14 | application/octet-stream 15 | application/rss+xml 16 | application/vnd.geo+json 17 | application/vnd.ms-fontobject 18 | application/x-font 19 | application/x-font-opentype 20 | application/x-font-otf 21 | application/x-font-truetype 22 | application/x-font-ttf 23 | application/x-javascript 24 | application/x-web-app-manifest+json 25 | application/xhtml+xml 26 | application/xml 27 | font/eot 28 | font/opentype 29 | font/otf 30 | font/truetype 31 | font/ttf 32 | font/woff 33 | font/woff2 34 | image/bmp 35 | image/svg+xml 36 | image/vnd.microsoft.icon 37 | image/x-icon 38 | image/x-win-bitmap 39 | text/cache-manifest 40 | text/calendar 41 | text/css 42 | text/csv 43 | text/javascript 44 | text/plain 45 | text/vcard 46 | text/vnd.rim.location.xloc 47 | text/vtt 48 | text/x-component 49 | text/x-cross-domain-policy 50 | text/xml; 51 | -------------------------------------------------------------------------------- /src/php/with-nginx/rootfs/etc/nginx/custom.d/00-ext-http3.conf: -------------------------------------------------------------------------------- 1 | # http3 2 | listen 443 quic reuseport; 3 | listen [::]:443 quic reuseport; 4 | 5 | http3 on; 6 | 7 | add_header Alt-Svc 'h3=":443"; ma=86400'; 8 | -------------------------------------------------------------------------------- /src/php/with-nginx/rootfs/etc/nginx/custom.d/01-common.conf: -------------------------------------------------------------------------------- 1 | # default index 2 | root $APP_ROOT; 3 | index index.php index.html; 4 | 5 | # logging 6 | access_log /proc/1/fd/2 custom; 7 | error_log /proc/1/fd/2 error; 8 | 9 | # security headers 10 | add_header X-XSS-Protection "1; mode=block" always; 11 | add_header X-Content-Type-Options "nosniff" always; 12 | add_header Referrer-Policy "no-referrer-when-downgrade" always; 13 | add_header Permissions-Policy "interest-cohort=()" always; 14 | # add_header Content-Security-Policy "default-src 'self' http: https: ws: wss: data: blob: 'unsafe-inline'; frame-ancestors 'self';" always; 15 | 16 | # . files 17 | location ~ /\.(?!well-known) { 18 | deny all; 19 | } 20 | 21 | # favicon.ico 22 | location = /favicon.ico { 23 | expires 1d; 24 | access_log off; 25 | } 26 | 27 | # svg, fonts 28 | location ~* \.(?:ttf|ttc|otf|eot|woff2?)$ { 29 | add_header Access-Control-Allow-Origin "*"; 30 | expires 30d; 31 | access_log off; 32 | } 33 | 34 | # robots.txt 35 | location = /robots.txt { 36 | access_log off; 37 | try_files $uri /index.php$is_args$args; 38 | } 39 | 40 | # css, js 41 | location ~* \.(?:css(\.map)?|js(\.map)?)$ { 42 | add_header Access-Control-Allow-Origin "*"; 43 | expires 30d; 44 | access_log off; 45 | try_files $uri /index.php$is_args$args; 46 | } 47 | 48 | # images 49 | location ~* \.(?:svgz?|jpe?g|png|gif|ico|cur|heic|webp|tiff?)$ { 50 | add_header Access-Control-Allow-Origin "*"; 51 | expires 30d; 52 | access_log off; 53 | try_files $uri /index.php$is_args$args; 54 | } 55 | 56 | # media 57 | location ~* \.(?:mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ { 58 | add_header Access-Control-Allow-Origin "*"; 59 | expires max; 60 | access_log off; 61 | } 62 | 63 | # handle .php 64 | location ~ [^/]\.php(/|$) { 65 | fastcgi_pass @php; 66 | 67 | # split path 68 | fastcgi_split_path_info ^(.+\.php)(/.+)$; 69 | set $_fastcgi_path_info $fastcgi_path_info; 70 | 71 | # 404 72 | try_files $fastcgi_script_name 404; 73 | 74 | # default fastcgi_params 75 | include fastcgi_params; 76 | 77 | # fastcgi settings 78 | fastcgi_index index.php; 79 | fastcgi_buffers 8 16k; 80 | fastcgi_buffer_size 32k; 81 | 82 | # fastcgi params 83 | fastcgi_param DOCUMENT_ROOT $realpath_root; 84 | fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; 85 | fastcgi_param PATH_INFO $_fastcgi_path_info; 86 | } 87 | -------------------------------------------------------------------------------- /src/php/with-nginx/rootfs/etc/nginx/sites-enabled/00-default.conf: -------------------------------------------------------------------------------- 1 | # Default server 2 | server { 3 | listen 80 reuseport default_server; 4 | listen [::]:80 reuseport default_server; 5 | listen 443 ssl http2 reuseport; 6 | listen [::]:443 ssl http2 reuseport; 7 | 8 | server_name localhost; 9 | 10 | # SSL 11 | ssl_certificate /etc/ssl/site/server.crt; 12 | ssl_certificate_key /etc/ssl/site/server.key; 13 | 14 | # load extra config 15 | include /etc/nginx/custom.d/*.conf; 16 | 17 | # index.php fallback 18 | location / { 19 | try_files $uri $uri/ /index.php$is_args$args; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/php/with-nginx/rootfs/usr/local/bin/nginx-conf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | conf_dir=/etc/nginx 11 | disable="$([ "${1:0:1}" = "#" ] && echo "# " || echo "")" 12 | name="${1/#/}"; shift 13 | if [ -d $conf_dir ]; then 14 | grep -lr "^ *#* *${name} " $conf_dir | grep '\.conf$' | xargs -r sed -i "s~^ *#* *${name} *.*\$~${disable}${name} $@;~g" &>/dev/null 15 | fi 16 | -------------------------------------------------------------------------------- /src/php/with-nginx/rootfs/usr/local/bin/nginx-test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | exec nginx -t 2>&1 | grep -qF "$@" 3 | -------------------------------------------------------------------------------- /src/php/with-roadrunner.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | # ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-php} 18 | # ARG PHP_VERSION=${PHP_VERSION:-8.4} 19 | # ARG PHP_VARIANT=${PHP_VARIANT:-cli-alpine} 20 | 21 | # FROM ./base-php AS php 22 | # ARG BUILDKIT_SBOM_SCAN_STAGE=true 23 | 24 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/php} 25 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 26 | 27 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 28 | ARG PHP_VARIANT=${PHP_VARIANT:-cli-alpine} 29 | 30 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}${PHP_VERSION}-${PHP_VARIANT} 31 | ONBUILD RUN hook onbuild 32 | 33 | ################################################################################ 34 | 35 | INCLUDE ./with-roadrunner/roadrunner-install 36 | INCLUDE ./with-roadrunner/roadrunner-config 37 | INCLUDE ./common/os-s6-overlay 38 | 39 | RUN /usr/local/bin/rr -v 40 | 41 | ################################################################################ 42 | 43 | EXPOSE 80 44 | EXPOSE 443 45 | EXPOSE 443/udp 46 | EXPOSE 6001 47 | 48 | CMD [] 49 | 50 | ################################################################################ 51 | 52 | INCLUDE ./meta 53 | 54 | ################################################################################ 55 | 56 | LABEL traefik.enable=true 57 | -------------------------------------------------------------------------------- /src/php/with-roadrunner/roadrunner-config.dockerfile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | ADD --link ./with-roadrunner/rootfs/ / 10 | 11 | ################################################################################ 12 | 13 | RUN <<'EOF' 14 | 15 | # create s6 services 16 | if has-cmd s6-service; then 17 | s6-service roadrunner longrun '#!/usr/bin/env sh 18 | export APP_PATH="$(app-path)" 19 | export APP_ROOT="$(app-root)" 20 | 21 | cd $APP_PATH 22 | exec /usr/local/bin/rr -w "$(app-path)" \ 23 | -o http.address=0.0.0.0:80 \ 24 | -o http.ssl.address=0.0.0.0:443 \ 25 | -o http.ssl.cert=/etc/ssl/site/server.crt \ 26 | -o http.ssl.key=/etc/ssl/site/server.key \ 27 | -o logs.level=$(if is-debug; then echo debug; else echo info; fi) \ 28 | -o logs.mode=$(if is-debug; then echo development; else echo production; fi) \ 29 | -o logs.output=$(log-path) \ 30 | -o rpc.listen=tcp://127.0.0.1:6001 \ 31 | $ROADRUNNER_COMMAND_OPTIONS \ 32 | $(if is-debug; then echo "-o http.pool.debug=1 -d"; fi) \ 33 | serve 34 | ' 35 | fi 36 | 37 | EOF 38 | -------------------------------------------------------------------------------- /src/php/with-roadrunner/roadrunner-install.dockerfile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 10 | 11 | # Install RoadRunner from the original binaries 12 | COPY --link --from=ghcr.io/roadrunner-server/roadrunner:latest /usr/bin/rr /usr/local/bin/rr 13 | COPY --link --from=ghcr.io/roadrunner-server/roadrunner:latest /etc/rr.yaml /etc/rr.yaml 14 | 15 | # Install PHP extensions 16 | RUN phpaddmod sockets 17 | -------------------------------------------------------------------------------- /src/php/with-roadrunner/rootfs/etc/cont-init.d/zz-start-roadrunner: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | set -e 11 | 12 | # enable debug logs 13 | if is-debug; then 14 | roadrunner-conf 'debug' 'true' 15 | debug-echo -w "🐞 RoadRunner is in DEBUG MODE 🐞" 16 | else 17 | roadrunner-conf 'debug' 'false' 18 | fi 19 | 20 | if ! is-true $DISABLE_GREETING && has-cmd rr; then 21 | rr -v 2>&1 | head -n1 22 | fi 23 | -------------------------------------------------------------------------------- /src/php/with-roadrunner/rootfs/source/.rr.yaml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | 3 | rpc: 4 | listen: tcp://127.0.0.1:6001 5 | 6 | server: 7 | command: "php index.php" 8 | relay: pipes 9 | 10 | http: 11 | address: 0.0.0.0:80 12 | middleware: [ "gzip", "static" ] 13 | ssl: 14 | address: 0.0.0.0:443 15 | cert: "/etc/ssl/site/server.crt" 16 | key: "/etc/ssl/site/server.key" 17 | static: 18 | dir: "." 19 | forbid: [ ".php", ".htaccess" ] 20 | -------------------------------------------------------------------------------- /src/php/with-roadrunner/rootfs/source/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "shinsenter/roadrunner", 3 | "description": "Sample application", 4 | "type": "project", 5 | "require": { 6 | "spiral/roadrunner-http": "*", 7 | "nyholm/psr7": "*" 8 | }, 9 | "scripts": { 10 | "post-create-project-cmd": [ 11 | "composer dump-autoload" 12 | ] 13 | }, 14 | "minimum-stability": "dev", 15 | "prefer-stable": true 16 | } 17 | -------------------------------------------------------------------------------- /src/php/with-roadrunner/rootfs/source/index.php: -------------------------------------------------------------------------------- 1 | waitRequest(); 17 | if ($request === null) { 18 | break; 19 | } 20 | } catch (\Throwable $e) { 21 | $psr7->respond(new Response(400)); 22 | continue; 23 | } 24 | 25 | try { 26 | ob_start(); 27 | if ((bool) trim((string) shell_exec('is-debug && echo 1 || echo 0'))) { 28 | phpinfo(); 29 | } else { 30 | echo 'It works!'; 31 | } 32 | $html = ob_get_contents(); 33 | ob_clean(); 34 | 35 | $psr7->respond(new Response(200, [], $html)); 36 | } catch (\Throwable $e) { 37 | $psr7->respond(new Response(500, [], 'Something went wrong!')); 38 | $psr7->getWorker()->error((string)$e); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/php/with-roadrunner/rootfs/usr/local/bin/roadrunner-conf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | conf_dir="$(app-path)" 11 | disable="$([ "${1:0:1}" = "#" ] && echo "# " || echo "")" 12 | name="${1/#/}"; shift 13 | if [ -d $conf_dir ]; then 14 | grep -lr "^ *#* *${name}: " $conf_dir | grep '.rr.yaml$' | xargs -r sed -i "s~^\( *\)#* *${name}: *.*\$~\1${disable}${name}: $@~g" &>/dev/null 15 | fi 16 | -------------------------------------------------------------------------------- /src/php/with-unit.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | # ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-php} 18 | # ARG PHP_VERSION=${PHP_VERSION:-8.4} 19 | # ARG PHP_VARIANT=${PHP_VARIANT:-zts-alpine} 20 | 21 | # FROM ./base-php AS php 22 | # ARG BUILDKIT_SBOM_SCAN_STAGE=true 23 | 24 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/php} 25 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 26 | 27 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 28 | ARG PHP_VARIANT=${PHP_VARIANT:-zts-alpine} 29 | 30 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}${PHP_VERSION}-${PHP_VARIANT} 31 | ONBUILD RUN hook onbuild 32 | 33 | ################################################################################ 34 | 35 | INCLUDE ./with-unit/unit-install 36 | INCLUDE ./with-unit/unit-config 37 | INCLUDE ./common/os-s6-overlay 38 | 39 | RUN unitd --version 40 | 41 | ################################################################################ 42 | 43 | EXPOSE 80 44 | EXPOSE 443 45 | EXPOSE 443/udp 46 | 47 | CMD [] 48 | 49 | ################################################################################ 50 | 51 | INCLUDE ./meta 52 | 53 | ################################################################################ 54 | 55 | LABEL traefik.enable=true 56 | -------------------------------------------------------------------------------- /src/php/with-unit/rootfs/etc/cont-init.d/zz-start-unit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | UNIT_CONTROL_SOCKET="${UNIT_CONTROL_SOCKET:-/run/control.unit.sock}" 11 | UNIT_CONTROL_PID="${UNIT_CONTROL_PID:-/run/unit.pid}" 12 | 13 | set -e 14 | 15 | if is-debug && has-cmd unitd-debug; then 16 | unitd="$(command -v unitd-debug)" 17 | else 18 | unitd="$(command -v unitd)" 19 | fi 20 | 21 | if ! is-true $DISABLE_GREETING && [ -x $unitd ]; then 22 | $unitd --version 2>&1 | grep version 23 | fi 24 | 25 | configtest() { 26 | curl --retry 3 --retry-delay 5 -sL -X GET --unix-socket $UNIT_CONTROL_SOCKET http://localhost/ || true 27 | } 28 | 29 | initial() { 30 | web-mkdir /var/lib/unit 31 | web-chown fix /var/lib/unit /var/log/unit /run/unit 32 | 33 | if [ -e /var/lib/unit/conf.json ]; then 34 | return 0 35 | fi 36 | 37 | # start daemon 38 | $unitd --control unix:$UNIT_CONTROL_SOCKET 39 | 40 | # wait for socket 41 | while [ ! -e "$UNIT_CONTROL_SOCKET" ]; do sleep 0.5; done 42 | configtest &>/dev/null 43 | 44 | # SSL bundle 45 | CERT_PATH="/etc/ssl/site/server_${PHP_POOL_NAME:-www}.pem" 46 | cat /etc/ssl/site/*.crt /etc/ssl/site/*.key >$CERT_PATH 47 | unit-conf $CERT_PATH "certificates/default" 48 | 49 | # enabled sites 50 | for json in $(find /etc/unit/sites-enabled -type f -name "*.json" | sort -dbfi); do 51 | unit-conf $json 52 | done 53 | 54 | # test config again 55 | if is-debug; then 56 | configtest >&2 57 | fi 58 | 59 | # stop Unit daemon after initial configuration 60 | kill -TERM $(cat $UNIT_CONTROL_PID) &>/dev/null || rm -f $UNIT_CONTROL_PID 61 | while [ -e "$UNIT_CONTROL_SOCKET" ]; do sleep 0.5; done 62 | } 63 | 64 | if is-debug; then 65 | debug-echo -w "🐞 Nginx Unit is in DEBUG MODE 🐞" 66 | initial || true 67 | else 68 | initial &>/dev/null || true 69 | fi 70 | -------------------------------------------------------------------------------- /src/php/with-unit/rootfs/etc/unit/sites-enabled/00-default.json: -------------------------------------------------------------------------------- 1 | { 2 | "applications": { 3 | "{{ PHP_POOL_NAME }}": { 4 | "type": "php", 5 | "targets": { 6 | "direct": { 7 | "root": "{{ APP_PATH }}{{ DOCUMENT_ROOT }}/" 8 | }, 9 | "index": { 10 | "root": "{{ APP_PATH }}{{ DOCUMENT_ROOT }}/", 11 | "script": "index.php" 12 | } 13 | } 14 | } 15 | }, 16 | "routes": [ 17 | { 18 | "match": { 19 | "uri": [ 20 | "*.php", 21 | "*.php/*" 22 | ] 23 | }, 24 | "action": { 25 | "pass": "applications/{{ PHP_POOL_NAME }}/direct" 26 | } 27 | }, 28 | { 29 | "action": { 30 | "share": "{{ APP_PATH }}{{ DOCUMENT_ROOT }}$uri", 31 | "fallback": { 32 | "pass": "applications/{{ PHP_POOL_NAME }}/index" 33 | } 34 | } 35 | } 36 | ], 37 | "listeners": { 38 | "*:80": { 39 | "pass": "routes", 40 | "forwarded": { 41 | "client_ip": "X-Forwarded-For", 42 | "protocol": "X-Forwarded-Proto", 43 | "recursive": true, 44 | "source": [ 45 | "*:80", 46 | "*:443" 47 | ] 48 | } 49 | }, 50 | "*:443": { 51 | "pass": "routes", 52 | "tls": { 53 | "certificate": "default" 54 | }, 55 | "forwarded": { 56 | "client_ip": "X-Forwarded-For", 57 | "protocol": "X-Forwarded-Proto", 58 | "recursive": true, 59 | "source": [ 60 | "*:80", 61 | "*:443" 62 | ] 63 | } 64 | } 65 | }, 66 | "settings": { 67 | "http": { 68 | "server_version": false 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/php/with-unit/rootfs/usr/local/bin/unit-conf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | config_file="$1" 11 | 12 | if [ -z "$config_file" ]; then 13 | debug-echo -w "Usage: ${0##*/} /path/to/config.json " 14 | exit 1 15 | fi 16 | 17 | if [ ! -f "$config_file" ]; then 18 | debug-echo -e "Error: Invalid config file: $config_file" 19 | exit 1 20 | fi 21 | 22 | set -e 23 | 24 | shift 25 | config_path="$@" 26 | 27 | if [ -z "$config_path" ]; then 28 | config_path="config/" 29 | fi 30 | 31 | envsubst() { 32 | while IFS= read -r line; do 33 | while [[ $line =~ (\{\{ [a-zA-Z_][a-zA-Z_0-9]* \}\}) ]]; do 34 | var="${BASH_REMATCH[1]}" 35 | var_name="${var:3:-3}" 36 | var_value="${!var_name}" 37 | line="${line//$var/$var_value}" 38 | done 39 | echo "$line" 40 | done 41 | } 42 | 43 | if [[ $config_file == *".json" ]]; then 44 | output="/tmp/${config_file##*/}" 45 | echo "$(cat "$config_file" | envsubst)" >$output 46 | config_file="$output" 47 | fi 48 | 49 | RET=$( 50 | if is-debug; then cat $config_file; set -x; fi; 51 | curl --retry 3 --retry-delay 5 -sL -w '%{http_code}' \ 52 | -X PUT --data-binary @$config_file \ 53 | --unix-socket ${UNIT_CONTROL_SOCKET:-/run/control.unit.sock} \ 54 | "http://localhost/$config_path" 55 | ) 56 | STATUS=$(echo $RET | tail -c 4) 57 | 58 | if [ ! -z "$output" ]; then 59 | rm -f "$output" 60 | fi 61 | 62 | debug-echo "$RET" 63 | 64 | if [ "$STATUS" != "200" ]; then 65 | debug-echo -e "Error: HTTP response status code is '$STATUS'" 66 | exit 1 67 | fi 68 | 69 | debug-echo -s "OK: HTTP response status code is '$STATUS'" 70 | -------------------------------------------------------------------------------- /src/php/with-unit/unit-config.dockerfile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | ADD --link ./with-unit/rootfs/ / 10 | 11 | ################################################################################ 12 | 13 | RUN <<'EOF' 14 | echo 'Configure Nginx Unit' 15 | 16 | if [ -z "$BUILD_SOURCE_IMAGE" ]; then 17 | exit 0 18 | fi 19 | 20 | # create folders 21 | mkdir -p /etc/unit /etc/unit/sites-enabled \ 22 | /var/lib/unit /var/log/unit /run/unit 23 | 24 | # create s6 services 25 | if has-cmd s6-service; then 26 | s6-service unit longrun '#!/usr/bin/env sh 27 | UNIT_CONTROL_PID=${UNIT_CONTROL_PID:-/run/unit.pid} 28 | UNIT_CONTROL_SOCKET=${UNIT_CONTROL_SOCKET:-/run/control.unit.sock} 29 | 30 | if is-debug && has-cmd unitd-debug; then 31 | unitd="$(command -v unitd-debug)" 32 | else 33 | unitd="$(command -v unitd)" 34 | fi 35 | 36 | export APP_PATH="$(app-path)" 37 | export APP_ROOT="$(app-root)" 38 | 39 | cd $APP_PATH 40 | rm -rf $UNIT_CONTROL_PID 41 | exec "$unitd" --no-daemon \ 42 | --user ${APP_USER:-www-data} \ 43 | --group ${APP_GROUP:-www-data} \ 44 | --control unix:$UNIT_CONTROL_SOCKET \ 45 | --pid $UNIT_CONTROL_PID \ 46 | --log "$(log-path)" 47 | ' 48 | fi 49 | 50 | EOF 51 | -------------------------------------------------------------------------------- /src/php/with-unit/unit-install.dockerfile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # The setups in this file belong to the project https://code.shin.company/php 3 | # I appreciate you respecting my intellectual efforts in creating them. 4 | # If you intend to copy or use ideas from this project, please credit properly. 5 | # Author: SHIN Company 6 | # License: https://code.shin.company/php/blob/main/LICENSE 7 | ################################################################################ 8 | 9 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 10 | ARG BUILD_SOURCE_IMAGE=${BUILD_SOURCE_IMAGE:-https://codeload.github.com/nginx/unit/legacy.tar.gz/refs/heads/branches/default} 11 | ADD $BUILD_SOURCE_IMAGE /tmp/unit.tar.gz 12 | 13 | ENV UNIT_CONTROL_PID=/run/unit.pid 14 | ENV UNIT_CONTROL_SOCKET=/run/control.unit.sock 15 | 16 | # Install Nginx 17 | RUN <<'EOF' 18 | echo 'Install Nginx Unit' 19 | [ -z "$DEBUG" ] || set -ex && set -e 20 | 21 | if [ ! -f "/tmp/unit.tar.gz" ]; then 22 | exit 1 23 | fi 24 | 25 | # install dependencies 26 | APK_PACKAGES="openssl-dev" \ 27 | APT_PACKAGES="libssl-dev" \ 28 | pkg-add $PHPIZE_DEPS 29 | 30 | # extract Unit source 31 | mkdir -p /tmp/unit 32 | tar -xzf /tmp/unit.tar.gz --strip=1 -C "/tmp/unit" 33 | 34 | cd /tmp/unit 35 | NCPU="$(getconf _NPROCESSORS_ONLN)" 36 | DEB_HOST_MULTIARCH="$(dpkg-architecture -q DEB_HOST_MULTIARCH)" 37 | CC_OPT="$(DEB_BUILD_MAINT_OPTIONS="hardening=+all,-pie" DEB_CFLAGS_MAINT_APPEND="-Wp,-D_FORTIFY_SOURCE=2 -fPIC" dpkg-buildflags --get CFLAGS)" 38 | LD_OPT="$(DEB_BUILD_MAINT_OPTIONS="hardening=+all,-pie" DEB_LDFLAGS_MAINT_APPEND="-Wl,--as-needed -pie" dpkg-buildflags --get LDFLAGS)" 39 | 40 | build() { 41 | local name="${1:-unitd}" 42 | local mod_dir="/usr/lib/unit/${name}-modules" 43 | local args="--no-regex --no-pcre2 --openssl \ 44 | --user=$APP_USER \ 45 | --control=unix:$UNIT_CONTROL_SOCKET \ 46 | --pid=$UNIT_CONTROL_PID \ 47 | --libdir=/usr/lib/$DEB_HOST_MULTIARCH \ 48 | --modulesdir=$mod_dir \ 49 | --statedir=/var/lib/unit \ 50 | --runstatedir=/var/run \ 51 | --logdir=/var/log \ 52 | --tmpdir=/var/tmp \ 53 | --log=$(log-path)" 54 | shift 55 | 56 | # make -j $NCPU -C pkg/contrib .njs 57 | # export PKG_CONFIG_PATH=$(pwd)/pkg/contrib/njs/build 58 | # ./configure $args --njs --cc-opt="$CC_OPT" --ld-opt="$LD_OPT" "$@" 59 | # make -j $NCPU unitd 60 | # test -d /usr/local/sbin || install -d /usr/local/sbin 61 | # install -p -m755 build/sbin/unitd /usr/local/sbin/$name 62 | # make clean 63 | 64 | # ./configure $args --cc-opt="$CC_OPT" "$@" 65 | # ./configure php --module=php 66 | # make -j $NCPU php-install 67 | # test -d $mod_dir || install -d $mod_dir 68 | # install -p build/lib/unit/modules/*.unit.so $mod_dir 69 | # make clean 70 | 71 | ./configure $args --cc-opt="$CC_OPT" "$@" 72 | ./configure php --module=php 73 | make -j $NCPU 74 | test -d $mod_dir || install -d $mod_dir 75 | test -d /usr/local/sbin || install -d /usr/local/sbin 76 | install -p build/lib/unit/modules/*.unit.so $mod_dir 77 | install -p -m755 build/sbin/unitd /usr/local/sbin/$name 78 | make clean 79 | } 80 | 81 | build unitd-debug --debug 82 | build unitd 83 | 84 | cd $HOME 85 | 86 | # clean up 87 | rm -rf /tmp/* 88 | EOF 89 | -------------------------------------------------------------------------------- /src/webapps/bedrock/bedrock.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://bedrock.org/documentation/category/installation/ 33 | ENV DOCUMENT_ROOT="/web" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "roots/bedrock" 36 | 37 | ################################################################################ 38 | 39 | # installs wp-cli 40 | ARG WPCLI_URL=https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar 41 | ARG WPCLI_PATH=/usr/local/bin/wp-cli 42 | 43 | RUN <<'EOF' 44 | echo 'Install WP-CLI' 45 | [ -z "$DEBUG" ] || set -ex && set -e 46 | 47 | web-mkdir "/.wp-cli" 48 | 49 | env-default '# Environment variables for WP-Cli' 50 | env-default WP_CLI_DIR '/.wp-cli' 51 | env-default WP_CLI_CACHE_DIR '$WP_CLI_DIR/cache/' 52 | env-default WP_CLI_PACKAGES_DIR '$WP_CLI_DIR/packages/' 53 | env-default WP_CLI_CONFIG_PATH '$WP_CLI_DIR/config.yml' 54 | env-default WP_DEBUG '$(is-debug && echo 1 || echo 0)' 55 | env-default WP_DEBUG_LOG '$(log-path)' 56 | 57 | php -r "copy('$WPCLI_URL', '$WPCLI_PATH');" && chmod +xr $WPCLI_PATH 58 | web-cmd wp "$WPCLI_PATH --allow-root --path=\"\$(app-path)/web/wp\"" 59 | wp package install aaemnnosttv/wp-cli-dotenv-command:^2.0 60 | EOF 61 | 62 | ################################################################################ 63 | 64 | INCLUDE ./meta 65 | 66 | ################################################################################ 67 | -------------------------------------------------------------------------------- /src/webapps/bedrock/rootfs/startup/boot-bedrock: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | 7 | web-mkdir "$APP_PATH" "$WP_CLI_DIR" "$WP_CLI_CACHE_DIR" "$WP_CLI_PACKAGES_DIR" 8 | -------------------------------------------------------------------------------- /src/webapps/cakephp4/cakephp4.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://book.cakephp.org/4/en/installation.html 33 | ENV DOCUMENT_ROOT="/webroot" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "cakephp/app:~4.0" 36 | 37 | ################################################################################ 38 | 39 | RUN web-cmd cake '$(app-path)/bin/cake' 40 | 41 | ################################################################################ 42 | 43 | INCLUDE ./meta 44 | 45 | ################################################################################ 46 | -------------------------------------------------------------------------------- /src/webapps/cakephp4/rootfs/startup/boot-cakephp4: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/cakephp5/cakephp5.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://book.cakephp.org/5/en/installation.html 33 | ENV DOCUMENT_ROOT="/webroot" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "cakephp/app:~5.0" 36 | 37 | ################################################################################ 38 | 39 | RUN web-cmd cake '$(app-path)/bin/cake' 40 | 41 | ################################################################################ 42 | 43 | INCLUDE ./meta 44 | 45 | ################################################################################ 46 | -------------------------------------------------------------------------------- /src/webapps/cakephp5/rootfs/startup/boot-cakephp5: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/codeigniter4/codeigniter4.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://codeigniter.com/user_guide/installation/index.html 33 | ENV DOCUMENT_ROOT="/public" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "codeigniter4/appstarter" 36 | 37 | ################################################################################ 38 | 39 | RUN web-cmd spark 'php $(app-path)/spark' 40 | 41 | ################################################################################ 42 | 43 | INCLUDE ./meta 44 | 45 | ################################################################################ 46 | -------------------------------------------------------------------------------- /src/webapps/codeigniter4/rootfs/startup/boot-codeigniter4: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/coolify/coolify.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-nginx} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | # COPY --link --chmod=755 --from=minio/mc:latest /usr/bin/mc /usr/bin/mc 30 | 31 | ################################################################################ 32 | 33 | # https://github.com/coollabsio/coolify 34 | ENV DOCUMENT_ROOT="/public" 35 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 36 | ENV COOLIFY_ENABLE_HORIZON=1 37 | RUN env-default INITIAL_PROJECT "https://codeload.github.com/coollabsio/coolify/legacy.tar.gz/refs/tags/$(curl --retry 3 --retry-delay 5 -ksLRJ https://api.github.com/repos/coollabsio/coolify/releases/latest | grep "tag_name" | cut -d \" -f 4)?ext=.tar.gz" 38 | 39 | # https://coolify.io/docs/installation 40 | ENV PHP_POST_MAX_SIZE="256M" 41 | ENV PHP_UPLOAD_MAX_FILESIZE="256M" 42 | ENV QUEUE_CONNECTION=sync 43 | 44 | ################################################################################ 45 | 46 | RUN <<'EOF' 47 | echo 'Configure Coolify' 48 | [ -z "$DEBUG" ] || set -ex && set -e 49 | 50 | # install pgsql php extension 51 | phpaddmod pdo_pgsql pgsql 52 | 53 | # create Horizon services 54 | if has-cmd s6-service; then 55 | s6-service horizon longrun '#!/usr/bin/env sh 56 | if is-true $COOLIFY_ENABLE_HORIZON; then 57 | export APP_PATH="$(app-path)" 58 | export APP_ROOT="$(app-root)" 59 | cd $APP_PATH && exec artisan start:horizon 60 | else 61 | exec s6-svc -Od . 62 | fi 63 | ' 64 | fi 65 | 66 | # make artisan command alias 67 | web-cmd artisan 'php $(app-path)/artisan' 68 | 69 | EOF 70 | 71 | ################################################################################ 72 | 73 | INCLUDE ./meta 74 | 75 | ################################################################################ 76 | -------------------------------------------------------------------------------- /src/webapps/coolify/rootfs/etc/hooks/post-package-update/00-coolify-env: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | if [ ! -e "$APP_PATH/.env" ] && [ -e "$APP_PATH/.env.development.example" ]; then 6 | cp -p "$APP_PATH/.env.development.example" "$APP_PATH/.env" 7 | php $APP_PATH/artisan key:generate 8 | fi 9 | -------------------------------------------------------------------------------- /src/webapps/coolify/rootfs/startup/boot-coolify: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/drupal/drupal.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://www.drupal.org/download 33 | ENV DOCUMENT_ROOT="/web" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "drupal/recommended-project" 36 | 37 | ################################################################################ 38 | 39 | INCLUDE ./meta 40 | 41 | ################################################################################ 42 | -------------------------------------------------------------------------------- /src/webapps/drupal/rootfs/startup/boot-drupal: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/espocrm/espocrm.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://github.com/espocrm/espocrm/tree/stable 33 | ENV DOCUMENT_ROOT="/public" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | 36 | # https://docs.espocrm.com/administration/server-configuration/#setting-up-crontab 37 | ENV ENABLE_CRONTAB=1 38 | ENV CRONTAB_SETTINGS='* * * * * php -f $(app-path)/cron.php &>/dev/null' 39 | ENV ESPOCRM_CONFIG_USE_WEB_SOCKET=0 40 | RUN env-default INITIAL_PROJECT "$(curl --retry 3 --retry-delay 5 -ksLRJ https://api.github.com/repos/espocrm/espocrm/releases/latest | grep "browser_download_url.*EspoCRM.*zip" | cut -d \" -f 4)" 41 | 42 | # https://docs.espocrm.com/administration/server-configuration/#php-requirements 43 | ENV PHP_MAX_EXECUTION_TIME="180" 44 | ENV PHP_MAX_INPUT_TIME="180" 45 | ENV PHP_MEMORY_LIMIT="256M" 46 | ENV PHP_POST_MAX_SIZE="50M" 47 | ENV PHP_UPLOAD_MAX_FILESIZE="50M" 48 | 49 | ################################################################################ 50 | 51 | RUN <<'EOF' 52 | echo 'Configure EspoCRM' 53 | [ -z "$DEBUG" ] || set -ex && set -e 54 | 55 | # install zmq php extension 56 | phpaddmod zmq 57 | 58 | # enable preload 59 | # see: https://docs.espocrm.com/administration/performance-tweaking/#preloading 60 | # env-default '# Enable preload to bring a significant performance boost' 61 | # env-default PHP_OPCACHE_PRELOAD '$(app-path)/preload.php' 62 | 63 | # enable mod_proxy and mod_proxy_wstunnel 64 | if has-cmd s6-service; then 65 | a2enmod proxy proxy_wstunnel 66 | fi 67 | 68 | # create WebSocket services 69 | if has-cmd s6-service; then 70 | s6-service espocrm-websocket longrun '#!/usr/bin/env sh 71 | if is-true $ESPOCRM_CONFIG_USE_WEB_SOCKET; then 72 | export APP_PATH="$(app-path)" 73 | export APP_ROOT="$(app-root)" 74 | export ESPOCRM_CONFIG_USE_WEB_SOCKET="true" 75 | export ESPOCRM_CONFIG_WEB_SOCKET_DEBUG_MODE="$(is-debug && echo 1 || echo 0)" 76 | export ESPOCRM_CONFIG_WEB_SOCKET_SSL_ALLOW_SELF_SIGNED="true" 77 | export ESPOCRM_CONFIG_WEB_SOCKET_URL="ws://localhost:8080" 78 | export ESPOCRM_CONFIG_WEB_SOCKET_ZERO_M_Q_SUBMISSION_DSN="tcp://espocrm-websocket:5555" 79 | export ESPOCRM_CONFIG_WEB_SOCKET_ZERO_M_Q_SUBSCRIBER_DSN="tcp://*:5555" 80 | cd $APP_PATH && exec php $APP_PATH/websocket.php 81 | else 82 | exec s6-svc -Od . 83 | fi 84 | ' 85 | fi 86 | 87 | EOF 88 | 89 | # https://docs.espocrm.com/administration/commands/ 90 | RUN web-cmd espocrm '$(app-path)/bin/command' 91 | RUN web-cmd clear_cache 'php $(app-path)/clear_cache.php' 92 | RUN web-cmd rebuild 'php $(app-path)/rebuild.php' 93 | 94 | ################################################################################ 95 | 96 | INCLUDE ./meta 97 | 98 | ################################################################################ 99 | -------------------------------------------------------------------------------- /src/webapps/espocrm/rootfs/etc/apache2/custom.d/espocrm-websocket.conf: -------------------------------------------------------------------------------- 1 | 2 | ProxyRequests Off 3 | 4 | ProxyPass ws://localhost:8080 5 | ProxyPassReverse ws://localhost:8080 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/webapps/espocrm/rootfs/etc/apache2/custom.d/espocrm.conf: -------------------------------------------------------------------------------- 1 | Alias /client/ ${APP_PATH}/client/ 2 | 3 | 4 | AllowOverride None 5 | 6 | 7 | 8 | AllowOverride All 9 | 10 | -------------------------------------------------------------------------------- /src/webapps/espocrm/rootfs/startup/boot-espocrm: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | 7 | if ! is-true $ESPOCRM_CONFIG_USE_WEB_SOCKET; then 8 | rm -rf /etc/apache2/custom.d/espocrm-websocket.conf 9 | fi 10 | 11 | # cd "$APP_PATH" 12 | # find . -type d -exec chmod 755 {} + && find . -type f -exec chmod 644 {} + 13 | # find data custom client/custom -type d -exec chmod 775 {} + && find data custom client/custom -type f -exec chmod 664 {} + 14 | # chmod 775 application/Espo/Modules client/modules 15 | # chmod 754 bin/command 16 | -------------------------------------------------------------------------------- /src/webapps/flarum/flarum.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://docs.flarum.org/install/ 33 | ENV DOCUMENT_ROOT="/public" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "flarum/flarum" 36 | 37 | ################################################################################ 38 | 39 | RUN web-cmd flarum 'php $(app-path)/flarum' 40 | 41 | ################################################################################ 42 | 43 | INCLUDE ./meta 44 | 45 | ################################################################################ 46 | -------------------------------------------------------------------------------- /src/webapps/flarum/rootfs/startup/boot-flarum: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/grav/grav.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://learn.getgrav.org/17/basics/installation 33 | ENV DOCUMENT_ROOT="" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | ENV COMPOSER_REQUIRES_GIT=1 36 | RUN env-default INITIAL_PROJECT "getgrav/grav" 37 | 38 | ################################################################################ 39 | 40 | RUN web-cmd grav 'php $(app-path)/bin/grav' 41 | RUN web-cmd gpm 'php $(app-path)/bin/gpm' 42 | RUN web-cmd plugin 'php $(app-path)/bin/plugin' 43 | 44 | ################################################################################ 45 | 46 | INCLUDE ./meta 47 | 48 | ################################################################################ 49 | -------------------------------------------------------------------------------- /src/webapps/grav/rootfs/startup/boot-grav: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/hyperf/hyperf.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-nginx} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://hyperf.wiki/3.1/#/en/quick-start/install 33 | ENV DOCUMENT_ROOT="" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "hyperf/hyperf-skeleton" 36 | 37 | ################################################################################ 38 | 39 | RUN <<'EOF' 40 | echo 'Install PHP extensions' 41 | [ -z "$DEBUG" ] || set -ex && set -e 42 | 43 | phpaddmod protobuf swoole 44 | 45 | web-cmd hyperf 'php $(app-path)/bin/hyperf.php' 46 | env-default PHP_SWOOLE_USE_SHORTNAME 'off' 47 | 48 | if has-cmd s6-service; then 49 | s6-service nginx depends hyperf 50 | s6-service hyperf longrun '#!/usr/bin/env sh 51 | export APP_PATH="$(app-path)" 52 | export APP_ROOT="$(app-root)" 53 | 54 | cd $APP_PATH 55 | exec php $APP_PATH/bin/hyperf.php start 56 | ' 57 | fi 58 | 59 | EOF 60 | 61 | ################################################################################ 62 | 63 | INCLUDE ./meta 64 | 65 | ################################################################################ 66 | -------------------------------------------------------------------------------- /src/webapps/hyperf/rootfs/etc/nginx/sites-enabled/00-default.conf: -------------------------------------------------------------------------------- 1 | # Default server 2 | server { 3 | listen 80 reuseport default_server; 4 | listen [::]:80 reuseport default_server; 5 | listen 443 ssl http2 reuseport; 6 | listen [::]:443 ssl http2 reuseport; 7 | 8 | server_name localhost; 9 | 10 | # SSL 11 | ssl_certificate /etc/ssl/site/server.crt; 12 | ssl_certificate_key /etc/ssl/site/server.key; 13 | 14 | # load extra config 15 | include /etc/nginx/custom.d/*.conf; 16 | 17 | # forward requests 18 | location / { 19 | proxy_set_header Host $http_host; 20 | proxy_set_header X-Real-IP $remote_addr; 21 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 22 | proxy_set_header X-Forwarded-Proto $scheme; 23 | proxy_pass http://127.0.0.1:9501; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/webapps/hyperf/rootfs/startup/boot-hyperf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/invoiceshelf/invoiceshelf.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://docs.invoiceshelf.com/install/manual.html 33 | ENV DOCUMENT_ROOT="/public" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "$(curl --retry 3 --retry-delay 5 -ksLRJ https://api.github.com/repos/InvoiceShelf/InvoiceShelf/releases/latest | grep "browser_download_url.*InvoiceShelf.*zip" | cut -d \" -f 4)" 36 | 37 | ################################################################################ 38 | 39 | RUN web-cmd artisan 'php $(app-path)/artisan' 40 | 41 | ################################################################################ 42 | 43 | INCLUDE ./meta 44 | 45 | ################################################################################ 46 | -------------------------------------------------------------------------------- /src/webapps/invoiceshelf/rootfs/startup/boot-invoiceshelf: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | touch $APP_PATH/database/database.sqlite &>/dev/null 7 | -------------------------------------------------------------------------------- /src/webapps/kirby/kirby.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://getkirby.com/docs/cookbook/setup/composer 33 | ENV DOCUMENT_ROOT="" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "getkirby/starterkit" 36 | 37 | ################################################################################ 38 | 39 | INCLUDE ./meta 40 | 41 | ################################################################################ 42 | -------------------------------------------------------------------------------- /src/webapps/kirby/rootfs/startup/boot-kirby: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/laminas/laminas.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://docs.laminas.dev/tutorials/getting-started/skeleton-application/ 33 | ENV DOCUMENT_ROOT="/public" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "laminas/laminas-mvc-skeleton" 36 | 37 | ################################################################################ 38 | 39 | INCLUDE ./meta 40 | 41 | ################################################################################ 42 | -------------------------------------------------------------------------------- /src/webapps/laminas/rootfs/startup/boot-laminas: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/laravel/laravel.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://laravel.com/docs/master/installation 33 | ENV DOCUMENT_ROOT="/public" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "laravel/laravel" 36 | 37 | ################################################################################ 38 | 39 | RUN web-cmd artisan 'php $(app-path)/artisan' 40 | 41 | ################################################################################ 42 | 43 | INCLUDE ./meta 44 | 45 | ################################################################################ 46 | -------------------------------------------------------------------------------- /src/webapps/laravel/rootfs/startup/boot-laravel: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | touch $APP_PATH/database/database.sqlite &>/dev/null 7 | -------------------------------------------------------------------------------- /src/webapps/magento/magento.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-nginx} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | ADD https://raw.githubusercontent.com/magento/magento2/2.4/nginx.conf.sample /etc/nginx/custom.d/magento.conf 30 | 31 | ################################################################################ 32 | 33 | # https://experienceleague.adobe.com/en/docs/commerce-operations/installation-guide/system-requirements 34 | ENV DOCUMENT_ROOT="/pub" 35 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 36 | RUN env-default INITIAL_PROJECT "magento/community-edition" 37 | 38 | ################################################################################ 39 | 40 | RUN <<'EOF' 41 | echo 'Install PHP extensions' 42 | [ -z "$DEBUG" ] || set -ex && set -e 43 | 44 | # install PHP modules 45 | phpaddmod soap sodium sockets xsl 46 | 47 | # override nginx config 48 | rm -f /etc/nginx/custom.d/00-ext-*.conf 49 | rm -f /etc/nginx/custom.d/*common.conf 50 | sed -i 's|MAGE_ROOT|APP_PATH|g' /etc/nginx/custom.d/magento.conf 51 | sed -i 's|fastcgi_backend|@php|g' /etc/nginx/custom.d/magento.conf 52 | if grep -qF 'location / {' /etc/nginx/custom.d/magento.conf; then 53 | sed -i 's#location / {#location @old {#' /etc/nginx/sites-enabled/00-default.conf 54 | fi 55 | 56 | # make aliases 57 | web-cmd magento 'php $(app-path)/bin/magento' 58 | 59 | EOF 60 | 61 | ################################################################################ 62 | 63 | INCLUDE ./meta 64 | 65 | ################################################################################ 66 | -------------------------------------------------------------------------------- /src/webapps/magento/rootfs/startup/boot-magento: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/mautic/mautic.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://docs.mautic.org/en/5.x/getting_started/how_to_install_mautic.html#installing-with-composer 33 | ENV DOCUMENT_ROOT="/docroot" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | ENV COMPOSER_REQUIRES_GIT=1 36 | RUN env-default INITIAL_PROJECT "mautic/recommended-project" 37 | 38 | ################################################################################ 39 | 40 | RUN <<'EOF' 41 | echo 'Install PHP extensions' 42 | [ -z "$DEBUG" ] || set -ex && set -e 43 | 44 | phpaddmod imap 45 | 46 | web-cmd console 'php $(app-path)/bin/console' 47 | web-cmd mautic 'php $(app-path)/bin/console' 48 | 49 | EOF 50 | 51 | ################################################################################ 52 | 53 | INCLUDE ./meta 54 | 55 | ################################################################################ 56 | -------------------------------------------------------------------------------- /src/webapps/mautic/rootfs/startup/boot-mautic: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/phpmyadmin/phpmyadmin.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://docs.phpmyadmin.net/en/latest/setup.html 33 | ENV DOCUMENT_ROOT="" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "phpmyadmin/phpmyadmin" 36 | 37 | ################################################################################ 38 | 39 | INCLUDE ./meta 40 | 41 | ################################################################################ 42 | -------------------------------------------------------------------------------- /src/webapps/phpmyadmin/rootfs/startup/boot-phpmyadmin: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | 7 | PMA_CONFIG="$APP_PATH/config.inc.php" 8 | 9 | web-mkdir "$APP_PATH/tmp" "$APP_PATH/tmp/save" "$APP_PATH/tmp/upload" 10 | 11 | if [ -f /etc/phpmyadmin-config.php ] && [ ! -f "$PMA_CONFIG" ] ; then 12 | cp -p /etc/phpmyadmin-config.php "$PMA_CONFIG" 13 | sed -i "s/random_string_with_32_chars_long/$(php -r 'echo md5(uniqid());')/g" "$PMA_CONFIG" &>/dev/null 14 | 15 | chmod 0644 "$PMA_CONFIG" 16 | 17 | if [ -f $APP_PATH/libraries/vendor_config.php ]; then 18 | sed -i "s@'configFile'.*@'configFile' => '${PMA_CONFIG}',@" \ 19 | $APP_PATH/libraries/vendor_config.php &>/dev/null 20 | fi 21 | fi 22 | -------------------------------------------------------------------------------- /src/webapps/slim/rootfs/startup/boot-slim: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/slim/slim.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://www.slimframework.com/docs/v4/start/installation.html 33 | ENV DOCUMENT_ROOT="/public" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "slim/slim-skeleton" 36 | 37 | ################################################################################ 38 | 39 | INCLUDE ./meta 40 | 41 | ################################################################################ 42 | -------------------------------------------------------------------------------- /src/webapps/spiral/rootfs/startup/boot-spiral: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/spiral/spiral.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/roadrunner} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://spiral.dev/docs/start-installation/current/en 33 | ENV DOCUMENT_ROOT="/public" 34 | ENV DISABLE_AUTORUN_COPYING_SOURCE=1 35 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 36 | RUN env-default INITIAL_PROJECT "spiral/app" 37 | 38 | ################################################################################ 39 | 40 | INCLUDE ./meta 41 | 42 | ################################################################################ 43 | -------------------------------------------------------------------------------- /src/webapps/statamic/rootfs/startup/boot-statamic: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | touch $APP_PATH/database/database.sqlite &>/dev/null 7 | -------------------------------------------------------------------------------- /src/webapps/statamic/statamic.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-nginx} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://statamic.dev/installing 33 | ENV DOCUMENT_ROOT="/public" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "statamic/statamic" 36 | 37 | ################################################################################ 38 | 39 | RUN web-cmd artisan 'php $(app-path)/artisan' 40 | RUN web-cmd please 'php $(app-path)/please' 41 | 42 | ################################################################################ 43 | 44 | INCLUDE ./meta 45 | 46 | ################################################################################ 47 | -------------------------------------------------------------------------------- /src/webapps/sulu/rootfs/startup/boot-sulu: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/sulu/sulu.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://github.com/sulu/skeleton 33 | ENV DOCUMENT_ROOT="/public" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "sulu/skeleton" 36 | 37 | ################################################################################ 38 | 39 | RUN web-cmd console 'php $(app-path)/bin/console' 40 | RUN web-cmd symfony 'php $(app-path)/bin/console' 41 | RUN web-cmd sulu 'php $(app-path)/bin/console' 42 | 43 | ################################################################################ 44 | 45 | INCLUDE ./meta 46 | 47 | ################################################################################ 48 | -------------------------------------------------------------------------------- /src/webapps/symfony/rootfs/startup/boot-symfony: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/symfony/symfony.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://symfony.com/doc/current/setup.html 33 | ENV DOCUMENT_ROOT="/public" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "symfony/skeleton" 36 | 37 | ################################################################################ 38 | 39 | RUN web-cmd console 'php $(app-path)/bin/console' 40 | RUN web-cmd symfony 'php $(app-path)/bin/console' 41 | 42 | ################################################################################ 43 | 44 | INCLUDE ./meta 45 | 46 | ################################################################################ 47 | -------------------------------------------------------------------------------- /src/webapps/wordpress/rootfs/etc/hooks/bootstrap/10-create-project: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | APP_PATH="$(app-path)" 11 | APP_ROOT="$(app-root)" 12 | WPCONFIG_URL=https://raw.githubusercontent.com/docker-library/wordpress/master/wp-config-docker.php 13 | 14 | web-mkdir "$APP_PATH" "$WP_CLI_DIR" "$WP_CLI_CACHE_DIR" "$WP_CLI_PACKAGES_DIR" 15 | 16 | # create wordpress project 17 | if ! is-true $DISABLE_AUTORUN_CREATING_PROJECT; then 18 | if [ -z "$(ls -A "$APP_PATH")" ]; then 19 | debug-echo -w "Install Wordpress to $APP_PATH" 20 | hook pre-create-project 21 | 22 | cd "$APP_PATH" 23 | wp core download \ 24 | --locale="${WORDPRESS_LOCALE:-en_US}" \ 25 | --force 26 | 27 | if [ ! -f "$APP_PATH/wp-config.php" ]; then 28 | php -r "copy('$WPCONFIG_URL', '$APP_PATH/wp-config.php');" 29 | fi 30 | 31 | hook post-create-project 32 | web-chown "Wordpress core downloaded to $APP_PATH." 33 | else 34 | debug-echo "Skip creating project because $APP_PATH is not empty." 35 | fi 36 | fi 37 | -------------------------------------------------------------------------------- /src/webapps/wordpress/rootfs/startup/boot-wordpress: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | 7 | web-mkdir "$APP_PATH" "$WP_CLI_DIR" "$WP_CLI_CACHE_DIR" "$WP_CLI_PACKAGES_DIR" 8 | -------------------------------------------------------------------------------- /src/webapps/wordpress/wordpress.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://wordpress.org/documentation/category/installation/ 33 | ENV DOCUMENT_ROOT="" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | 36 | ################################################################################ 37 | 38 | # installs wp-cli 39 | ARG WPCLI_URL=https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar 40 | ARG WPCLI_PATH=/usr/local/bin/wp-cli 41 | 42 | RUN <<'EOF' 43 | echo 'Install WP-CLI' 44 | [ -z "$DEBUG" ] || set -ex && set -e 45 | 46 | web-mkdir "/.wp-cli" 47 | 48 | env-default '# Environment variables for WP-Cli' 49 | env-default WP_CLI_DIR '/.wp-cli' 50 | env-default WP_CLI_CACHE_DIR '$WP_CLI_DIR/cache/' 51 | env-default WP_CLI_PACKAGES_DIR '$WP_CLI_DIR/packages/' 52 | env-default WP_CLI_CONFIG_PATH '$WP_CLI_DIR/config.yml' 53 | env-default WORDPRESS_DEBUG '$(is-debug && echo 1 || echo 0)' 54 | 55 | php -r "copy('$WPCLI_URL', '$WPCLI_PATH');" && chmod +xr $WPCLI_PATH 56 | web-cmd wp "$WPCLI_PATH --allow-root --path=\"\$(app-path)\"" 57 | EOF 58 | 59 | ################################################################################ 60 | 61 | INCLUDE ./meta 62 | 63 | ################################################################################ 64 | -------------------------------------------------------------------------------- /src/webapps/yii/rootfs/startup/boot-yii: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/yii/yii.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://www.yiiframework.com/doc/guide/2.0/en/start-installation 33 | ENV DOCUMENT_ROOT="/web" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "yiisoft/yii2-app-basic" 36 | 37 | ################################################################################ 38 | 39 | RUN web-cmd yii 'php $(app-path)/yii' 40 | 41 | ################################################################################ 42 | 43 | INCLUDE ./meta 44 | 45 | ################################################################################ 46 | -------------------------------------------------------------------------------- /src/webapps/zz-crater/crater.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://github.com/crater-invoice/crater 33 | ENV DOCUMENT_ROOT="/public" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "bytefury/crater" 36 | 37 | ################################################################################ 38 | 39 | RUN web-cmd artisan 'php $(app-path)/artisan' 40 | 41 | ################################################################################ 42 | 43 | INCLUDE ./meta 44 | 45 | ################################################################################ 46 | -------------------------------------------------------------------------------- /src/webapps/zz-crater/rootfs/startup/boot-crater: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | touch $APP_PATH/database/database.sqlite &>/dev/null 7 | -------------------------------------------------------------------------------- /src/webapps/zz-fuelphp/fuelphp.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://fuelphp.com/docs/installation/instructions.html 33 | ENV DOCUMENT_ROOT="/public" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "fuel/fuel" 36 | 37 | ################################################################################ 38 | 39 | RUN web-cmd oil 'php $(app-path)/bin/console' 40 | 41 | ################################################################################ 42 | 43 | INCLUDE ./meta 44 | 45 | ################################################################################ 46 | -------------------------------------------------------------------------------- /src/webapps/zz-fuelphp/rootfs/startup/boot-fuelphp: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /src/webapps/zz-phpixie/phpixie.dockerfile: -------------------------------------------------------------------------------- 1 | # syntax = ghcr.io/shinsenter/dockerfile-x:v1 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | # Enable SBOM attestations 11 | # See: https://docs.docker.com/build/attestations/sbom/ 12 | ARG BUILDKIT_SBOM_SCAN_CONTEXT=true 13 | ARG BUILDKIT_SBOM_SCAN_STAGE=true 14 | 15 | ################################################################################ 16 | 17 | ARG BUILD_FROM_IMAGE=${BUILD_FROM_IMAGE:-shinsenter/phpfpm-apache} 18 | ARG BUILD_TAG_PREFIX=${BUILD_TAG_PREFIX:-} 19 | 20 | ARG PHP_VERSION=${PHP_VERSION:-8.4} 21 | ARG PHP_VARIANT=${PHP_VARIANT:-} 22 | 23 | FROM ${BUILD_FROM_IMAGE}:${BUILD_TAG_PREFIX}php${PHP_VERSION}${PHP_VARIANT} 24 | ONBUILD RUN hook onbuild 25 | 26 | ################################################################################ 27 | 28 | ADD --link ./rootfs/ / 29 | 30 | ################################################################################ 31 | 32 | # https://phpixie.com/quickstart.html 33 | ENV DOCUMENT_ROOT="/web" 34 | ENV DISABLE_AUTORUN_GENERATING_INDEX=1 35 | RUN env-default INITIAL_PROJECT "phpixie/project" 36 | 37 | ################################################################################ 38 | 39 | RUN web-cmd phpixie 'php $(app-path)/console' 40 | 41 | ################################################################################ 42 | 43 | INCLUDE ./meta 44 | 45 | ################################################################################ 46 | -------------------------------------------------------------------------------- /src/webapps/zz-phpixie/rootfs/startup/boot-phpixie: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | APP_PATH="$(app-path)" 3 | APP_ROOT="$(app-root)" 4 | 5 | debug-echo "Your web application must be in {$APP_PATH}." 6 | -------------------------------------------------------------------------------- /tests/action-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | BASE_DIR="$(git rev-parse --show-toplevel)" 11 | 12 | if [ ! -x "$(command -v docker)" ]; then 13 | echo "docker is not installed. See https://docs.docker.com/get-docker/" 1>&2 14 | exit 1 15 | fi 16 | 17 | if [ ! -x "$(command -v act)" ]; then 18 | echo "act is not installed. See https://github.com/nektos/act" 1>&2 19 | exit 1 20 | fi 21 | 22 | if [ "$1" = "clean" ] || [ "$1" = "clear" ]; then 23 | docker system prune -af 24 | docker volume prune -f 25 | rm -rf /.cache/act 26 | clear 27 | shift 28 | fi 29 | 30 | ################################################################################ 31 | 32 | export DOCKER_HOST=$(docker context inspect --format '{{.Endpoints.docker.Host}}') 33 | 34 | set -xe 35 | act --bind --network host --use-gitignore=false --reuse=false --rm=true \ 36 | --workflows "$BASE_DIR/.github/workflows/${ACTION_WORKFLOW:-02-servers.yml}" \ 37 | --platform "ubuntu-22.04=catthehacker/ubuntu:act-22.04" \ 38 | --secret-file "$BASE_DIR/build/.secrets" \ 39 | --env "TESTING=1" \ 40 | --env "SKIP_SQUASH=${SKIP_SQUASH:-1}" \ 41 | --env "DUMMY=${DUMMY:-}" \ 42 | --env "DEBUG=${DEBUG:-}" \ 43 | --env "PUBLISH_TO_GHCR=${PUBLISH_TO_GHCR:-}" \ 44 | "$@" 45 | 46 | # Exmaples 47 | # ACTION_WORKFLOW=00-s6-overlay.yml ./tests/action-test.sh --job debian-s6 48 | # ACTION_WORKFLOW=01-php.yml ./tests/action-test.sh --job php --matrix "app:fpm" 49 | # ACTION_WORKFLOW=02-servers.yml ./tests/action-test.sh --job php-servers --matrix "app:with-apache" 50 | # ACTION_WORKFLOW=03-apps.yml ./tests/action-test.sh --job php-apps --matrix "app:app-laravel" 51 | -------------------------------------------------------------------------------- /tests/logs/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /tests/sbom-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | exec docker buildx imagetools inspect "$@" \ 11 | --format "{{ range .SBOM.SPDX.packages }}{{ .name }}@{{ .versionInfo }}{{ println }}{{ end }}" 12 | 13 | # Examples 14 | # ./tests/sbom-test.sh shinsenter/php:latest 15 | -------------------------------------------------------------------------------- /tests/squash-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | ################################################################################ 3 | # The setups in this file belong to the project https://code.shin.company/php 4 | # I appreciate you respecting my intellectual efforts in creating them. 5 | # If you intend to copy or use ideas from this project, please credit properly. 6 | # Author: SHIN Company 7 | # License: https://code.shin.company/php/blob/main/LICENSE 8 | ################################################################################ 9 | 10 | BASE_DIR="$(git rev-parse --show-toplevel)" 11 | LOG_DIR="$BASE_DIR/tests/logs" 12 | 13 | if [ ! -x "$BASE_DIR/build/docker-squash/docker-squash.sh" ]; then 14 | echo "No squash script." 1>&2 15 | exit 1 16 | fi 17 | 18 | if [ "$1" = "clean" ] || [ "$1" = "clear" ]; then 19 | docker system prune -af 20 | docker volume prune -f 21 | rm -rf "$LOG_DIR/"* 22 | clear 23 | shift 24 | fi 25 | 26 | . $BASE_DIR/build/helpers.sh 27 | 28 | # docker logout ghcr.io 29 | # . $BASE_DIR/build/.secrets 30 | # echo $GITHUB_TOKEN | docker login ghcr.io -u shinsenter --password-stdin 31 | 32 | platform="linux/${PLATFORM:-amd64}" 33 | variant="${PHP_VARIANT:-}" 34 | dockerfile="$BASE_DIR/src/${DOCKERFILE:-php/base-php.dockerfile}" 35 | context=$(dirname $dockerfile) 36 | s6_version=$(get_github_latest_tag "just-containers/s6-overlay" 1) 37 | 38 | if [ ! -f "$context/meta.dockerfile" ]; then 39 | cp -p "$BASE_DIR/src/php/meta.dockerfile" "$context/meta.dockerfile" 40 | fi 41 | 42 | for version; do 43 | set -xe 44 | $BASE_DIR/build/docker-squash/docker-squash.sh "$dockerfile" \ 45 | --no-cache \ 46 | --tag "docker-php-$version-${DOCKERTAG:-$variant}:squashed" \ 47 | --platform "$platform" \ 48 | --build-arg S6_VERSION=$s6_version \ 49 | --build-arg PHP_VERSION=$version \ 50 | --build-arg PHP_VARIANT=$variant \ 51 | --build-arg BUILD_TAG_PREFIX=$BUILD_TAG_PREFIX \ 52 | 2>&1 | tee "$BASE_DIR/tests/logs/squash-$version-${DOCKERTAG:-$variant}.txt" & 53 | done 54 | 55 | # build examples 56 | # PLATFORM=arm64 DOCKERTAG=s6 DOCKERFILE=php/base-s6.dockerfile ./tests/squash-test.sh latest 57 | # PLATFORM=arm64 DOCKERTAG=cli DOCKERFILE=php/base-php.dockerfile PHP_VARIANT=cli ./tests/squash-test.sh 5.6 8.3 58 | # PLATFORM=arm64 DOCKERTAG=fpm DOCKERFILE=php/base-php.dockerfile PHP_VARIANT=fpm ./tests/squash-test.sh 5.6 8.3 59 | # PLATFORM=arm64 DOCKERTAG=nginx DOCKERFILE=php/with-nginx.dockerfile PHP_VARIANT=fpm-alpine ./tests/squash-test.sh 5.6 8.3 60 | # PLATFORM=arm64 DOCKERTAG=apache DOCKERFILE=php/with-apache.dockerfile PHP_VARIANT=fpm ./tests/squash-test.sh 5.6 8.3 61 | # PLATFORM=arm64 DOCKERTAG=f8p DOCKERFILE=php/with-f8p.dockerfile PHP_VARIANT=zts ./tests/squash-test.sh 8.3 62 | # PLATFORM=arm64 DOCKERTAG=unit DOCKERFILE=php/with-unit.dockerfile PHP_VARIANT=zts ./tests/squash-test.sh 8.2 63 | # PLATFORM=arm64 DOCKERTAG=roadrunner DOCKERFILE=php/with-roadrunner.dockerfile PHP_VARIANT=zts-alpine ./tests/squash-test.sh 8.0 8.3 64 | # PLATFORM=arm64 DOCKERTAG=bedrock DOCKERFILE=webapps/bedrock/bedrock.dockerfile PHP_VARIANT= ./tests/squash-test.sh 8.3 65 | # PLATFORM=arm64 DOCKERTAG=coolify DOCKERFILE=webapps/coolify/coolify.dockerfile PHP_VARIANT= ./tests/squash-test.sh 8.4 66 | 67 | # run examples 68 | # PLATFORM=arm64 DOCKERTAG=apache DOCKERFILE=php/with-apache.dockerfile PHP_VARIANT=fpm ./tests/squash-test.sh 5.6 8.3 69 | # docker run --rm -p 443:443 -p 80:80 -e DEBUG=1 -e ENABLE_CRONTAB=1 -e S6_VERBOSITY=3 docker-php-5.6-apache:squashed 70 | # docker run --rm -p 443:443 -p 80:80 -e DEBUG=1 -e ENABLE_CRONTAB=1 -e S6_VERBOSITY=3 docker-php-8.3-apache:squashed 71 | # docker run --rm -p 443:443 -p 80:80 -e APP_USER=dev -e APP_GROUP=developers -e APP_UID=555 -e APP_GID=666 -e DEBUG=1 -e ENABLE_CRONTAB=1 -e S6_VERBOSITY=3 shinsenter/php-archives:20240731-8.3-fpm-apache 72 | # docker run --rm -p 443:443 -p 80:80 -e APP_USER=dev -e APP_GROUP=developers -e APP_UID=555 -e APP_GID=666 -e DEBUG=1 -e ENABLE_CRONTAB=1 -e S6_VERBOSITY=3 shinsenter/php:8.3-fpm-apache 73 | --------------------------------------------------------------------------------