diff --git a/.bin/fix-attr b/.bin/fix-attr new file mode 100755 index 00000000..4873b65e --- /dev/null +++ b/.bin/fix-attr @@ -0,0 +1,13 @@ +#!/bin/bash +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +BASE_DIR="$(git rev-parse --show-toplevel)" +TARGET=${1:-$BASE_DIR} + +echo -e "\nπŸ—‚ Fixing permission for ${TARGET/$BASE_DIR/.}/" +find $TARGET -type d | grep -v 'tests\?' | xargs -I {} chmod 755 {} +find $TARGET -type f | grep -v 'tests\?' | xargs -I {} chmod 644 {} +find $TARGET -type f | grep -v 'tests\?' | grep '\/\.\?bin\|\/command\/\|git-config\/hooks\|root\/startup\|s6-overlay\|cont-init\|services\.d\|\.sh' | xargs -I {} chmod +xr {} \ No newline at end of file diff --git a/.bin/prebuild b/.bin/prebuild new file mode 100755 index 00000000..0f2891a2 --- /dev/null +++ b/.bin/prebuild @@ -0,0 +1,147 @@ +#!/bin/bash +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +[ -z "$1" ] && echo "Missing build target." && exit 1; + +TARGET=$1 +BASE_DIR="$(git rev-parse --show-toplevel)" +SRC_DIR="$BASE_DIR/src" +CACHE_DIR="/tmp/build-cache" +S6_VERSION="$(cat ${BASE_DIR}/S6_VERSION | sort -r | head -n1)" +OS_VERSIONS="$(cat ${BASE_DIR}/OS_VERSIONS | sort -r )" +PHP_VERSIONS="$(cat ${BASE_DIR}/PHP_VERSIONS | sort -r )" +LATEST_OS="$(echo "$OS_VERSIONS" | head -n1)" +LATEST_PHP="$(echo "$PHP_VERSIONS" | head -n1)" + +BUILD_DATE="$(date +%Y-%m-%dT%T%z)" +BUILD_REVISION="$(git rev-parse HEAD)" + +################################################################################ +# Helper methods +################################################################################ + +tee_or_print () { + local file="$1" ; shift + if [ -f $file ]; then cat $file; else "$@" | tee $file; fi +} + +basehash () { shasum -a1 "$@" 2>/dev/null | cut -c1-40; } + +dirhash () { + find ${1:-$BASE_DIR} -type f \ + | grep -v 'README\.md\|\.dockerignore\|.checksum' \ + | sort -u \ + | xargs -I {} shasum -a1 {} \ + | basehash +} + +imagehash () { + for image in "$@"; do + echo "$(docker manifest inspect --insecure "$@" 2>/dev/null | basehash) - $image" + done +} + +linkhash () { + for url in "$@"; do + echo "$(curl -skL "$url" 2>/dev/null | basehash) - $url" + done +} + +treehash() { + local target + local checksum + for path in "$@"; do + target="$BASE_DIR/$path" + if [ -d $target ]; then + checksum="$target/.checksum" + if [ -f $checksum ]; then cat $checksum; continue; fi + touch $checksum ; case "$path" in + src/base-s6 ) treehash S6_VERSION src/base | tee -a $checksum ;; + src/base-ubuntu ) treehash src/base-s6 | tee -a $checksum ;; + src/php/cli ) treehash src/base-ubuntu | tee -a $checksum ;; + src/php/fpm ) treehash src/php/cli | tee -a $checksum ;; + src/servers/* ) treehash src/php/fpm | tee -a $checksum ;; + src/webapps/* ) treehash src/servers/fpm-$(grep nginx $target/Dockerfile >/dev/null && echo 'nginx' || echo 'apache') | tee -a $checksum ;; + esac; + echo "$(dirhash ${target/$BASE_DIR/.}) - $path/" | tee -a $checksum + else + echo "$(basehash ${target/$BASE_DIR/.}) - $path" + fi + done +} + +prebuild () { + local checksum + local desc + local context + + context="$BASE_DIR/$1" ; [ -d $context ] || return 1 + mkdir -p ${context}/root + + if [ -f ${context}/README.md ] && [ -z "$(cat ${context}/README.md | grep SPONSOR\.md)" ]; then + echo -e "\n\n$(cat ${BASE_DIR}/SPONSOR.md)" >>${context}/README.md + desc="$(sed '3q;d' ${context}/README.md)" + fi + + if [ -f ${context}/Dockerfile ]; then + cp -rpf $SRC_DIR/.dockerignore ${context}/.dockerignore + if [ "$2" != "nometa" ] && [ -z "$(cat ${context}/Dockerfile | grep Metafile)" ]; then + echo -e "\n\n$(cat $SRC_DIR/Metafile)" >>${context}/Dockerfile + fi + fi + + $BASE_DIR/.bin/fix-attr $context + checksum="$(basehash $context/.checksum)" + echo " ${desc:-No description}" + echo " #️⃣ Checksum: $checksum" + + echo -e "\nπŸ–¨ Making output for the next steps" + echo "::set-output name=BUILD_CACHE_DIR::$CACHE_DIR" + echo "::set-output name=BUILD_CACHE::shinsenter/php:build-cache" + echo "::set-output name=BUILD_DATE::$BUILD_DATE" + echo "::set-output name=BUILD_DESC::$desc" + echo "::set-output name=BUILD_PLATFORM::linux/amd64,linux/arm/v7,linux/arm64/v8,linux/ppc64le" + echo "::set-output name=BUILD_REVISION::$BUILD_REVISION" + echo "::set-output name=CHECKSUM::$checksum" + echo "::set-output name=LATEST_OS::$LATEST_OS" + echo "::set-output name=LATEST_PHP::$LATEST_PHP" + echo "::set-output name=S6_VERSION::$S6_VERSION" + # echo "::set-output name=OS_VERSIONS::$OS_VERSIONS" + # echo "::set-output name=PHP_VERSIONS::$PHP_VERSIONS" +} + +################################################################################ +# Prebuild steps +################################################################################ + +echo -e "\nπŸ€– Cheking dependencies for $TARGET" + +mkdir -p $SRC_DIR/base/scratch + +tee_or_print $SRC_DIR/base-s6/.source \ + imagehash ubuntu + +tee_or_print $SRC_DIR/php/cli/.source \ + linkhash \ + 'http://ppa.launchpad.net/ondrej/php/ubuntu/dists/?C=M;O=D' \ + 'https://getcomposer.org/download/latest-stable/composer.phar.sha256sum' + +tee_or_print $SRC_DIR/servers/fpm-apache/.source \ + linkhash 'http://ppa.launchpadcontent.net/ondrej/apache2/ubuntu/dists/?C=M;O=D' + +tee_or_print $SRC_DIR/servers/fpm-nginx/.source \ + linkhash \ + 'http://ppa.launchpadcontent.net/ondrej/nginx-mainline/ubuntu/dists/?C=M;O=D' + +tee_or_print $SRC_DIR/webapps/wordpress/.source \ + linkhash \ + 'https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar.sha512' + +echo -e "\nπŸ€– Preparing $TARGET" +treehash $TARGET +prebuild $TARGET $2 +mkdir -p $CACHE_DIR +echo -e "\nCompleted." \ No newline at end of file diff --git a/.bin/tidy-docker b/.bin/tidy-docker new file mode 100755 index 00000000..b4b2e37c --- /dev/null +++ b/.bin/tidy-docker @@ -0,0 +1,169 @@ +#!/bin/bash +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +[ ! -x "$(command -v docker)" ] && echo "Missing Docker." && exit 1 + +################################################################################ + +PARSE_CACHE= + +# extracts docker repository name and tag +d_name_id () { + docker images --format "{{.Repository}}:{{.Tag}}\t{{.ID}}" \ + | grep -F $1 \ + | head -n1 +} + +# parses instruction from image +d_local_history () { + docker history --no-trunc --format "{{.CreatedBy}}" $1 \ + | awk '{arr[i++]=$0}END{while(i>0)print arr[--i]}' +} + +# parses instruction from docker hub +d_net_history () { + repo="$1" + tag="$2" + curl -skL 'https://hub.docker.com/v2/repositories/$repo/tags/$tag/images' \ + | jq '.[1].layers' \ + | jq '.[].instruction' -r +} + +# parses instruction and replace all '/bin/sh -c #(nop)' +d_parse () { + if [ -z "$PARSE_CACHE" ]; then + PARSE_CACHE="$(d_local_history $1 \ + | sed 's/^\/[^ ]* *-c */RUN /' \ + | sed 's/^|[0-9]* */RUN /' \ + | sed 's/^RUN \#[^ ]* *//' \ + | sed 's#EXPOSE map\[\(.*\):.*\]#EXPOSE \1#g' \ + | awk ' + { + if($1=="SHELL"){ + gsub("\\\[","[\"",$0); gsub("\\\]","\"]",$0) + i=1; printf("%s ",$i) + while(i++2){printf("\", \"%s",$i)}else{printf("%s",$i)} + } + printf "\n" + } else print $0 + }' 2>/dev/null \ + | awk ' + { + if(($1=="WORKDIR")||($1=="ENTRYPOINT")||($1=="CMD")||($1=="STOPSIGNAL")) + {cmd[$1]=$0;if($1=="ENTRYPOINT")delete cmd["CMD"]} + else print $0 + } END { + if(cmd["WORKDIR"]) print cmd["WORKDIR"] + if(cmd["ENTRYPOINT"]) print cmd["ENTRYPOINT"] + if(cmd["CMD"]) print cmd["CMD"] + if(cmd["STOPSIGNAL"]) print cmd["STOPSIGNAL"] + }' + )" + fi + echo "$PARSE_CACHE" +} + +# extracts given unique key-value instruction list +d_attr () { + d_parse $1 \ + | grep "^${2:-ENV}" \ + | awk -F= ' + {p=index($0,"=");v=substr($0,p+1);a[$1]=v} + END{for(k in a)printf("%s=\"%s\"\n",k,a[k])} + ' \ + | sort +} + +# extracts other instructions +ins_cmd () { + d_parse $1 | grep -v '^\(ADD\|ARG\|COPY\|ENV\|HEALTHCHECK\|LABEL\|ONBUILD\|RUN\)' +} + +# aliases +ins_name () { d_name_id $1 | awk '{printf $1}'; } +ins_id () { d_name_id $1 | awk '{printf $2}'; } + +# command aliases +ins_env () { d_attr $1 ENV; } +ins_labels () { d_attr $1 LABEL; } +ins_shell () { ins_cmd $1 | grep '^SHELL'; } +ins_others () { ins_cmd $1 | grep -v '^SHELL'; } + +# builds minified image +# @param $output Output new Dockerfile (optional, must be a valid file path) +# @param $base The original image (ID or name:tag) +# @param $save Target image name +minify() { + PARSE_CACHE= + local output="$1" ; [ ! -z "$output" ] && [ -f "$output" ] && shift || output="" + local base="$1" ; [ ! -z "$base" ] && shift || return 1 + local save="$1" ; [ ! -z "$save" ] && shift || save="${base}-tidy" + local repo="$(ins_name $base)" ; [ -z "$output" ] && [ -z "$repo" ] && echo "Invalid image ID $base" && return 1 + local temp="$([ ! -z "$output" ] && echo "$base" || echo "tidy-docker:build-$(ins_id $base)")" + local command="$([ ! -z "$output" ] && echo "tee $output" || echo "docker build $@ --rm -t $save -")" + + # make temporary tag name for building image + [ -z "$output" ] && docker tag $base $temp 2>/dev/null + + # build the tidy + echo "πŸ—œ Start minifying image '$repo'" + echo " Build arguments: $@" + DOCKER_BUILDKIT=${DOCKER_BUILDKIT:-1} $command </dev/null; fi +} + +################################################################################ + +echo ; date +minify $@ && echo "Done." || echo "Failed." \ No newline at end of file diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..02ebc686 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false +end_of_line = crlf + +[.bin/*] +indent_size = 2 + +[*.{yml,yaml}] +indent_size = 2 + +[docker-compose.yml] +indent_size = 4 diff --git a/.git-config/hooks/pre-build b/.git-config/hooks/pre-build deleted file mode 100755 index 6c39058b..00000000 --- a/.git-config/hooks/pre-build +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh - -BASE_DIR="$(git rev-parse --show-toplevel)" -BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" -BUILD_DESC= -VCS_REF="$(git rev-parse HEAD)" - -prebuild () { - local source - local dockerfile - source="$BASE_DIR/$1" - dockerfile=${source}/Dockerfile - readmefile=${source}/README.md - - if [ -f $readmefile ]; then - echo "\n\n$(cat ${BASE_DIR}/SPONSOR.md)" >>$readmefile - BUILD_DESC="$(sed '3q;d' $readmefile)" - fi - - if [ -f $dockerfile ]; then - echo "\n\n$(cat ${BASE_DIR}/src/Metafile)" >>$dockerfile - fi - - echo "::set-output name=BUILD_DATE::${BUILD_DATE}" - echo "::set-output name=BUILD_DESC::${BUILD_DESC}" - echo "::set-output name=VCS_REF::${VCS_REF}" -} - -mkdir -p /tmp/buildx 2>/dev/null -prebuild $1 \ No newline at end of file diff --git a/.git-config/hooks/pre-commit b/.git-config/hooks/pre-commit deleted file mode 100755 index 5004b9ea..00000000 --- a/.git-config/hooks/pre-commit +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -BASE="$(git rev-parse --show-toplevel)" - -echo -echo "πŸ—‚ Fixing permission for ${BASE}/..." -find $BASE -type d | xargs -I {} chmod 755 {} -find $BASE -type f | xargs -I {} chmod 644 {} -find $BASE -type f | grep '\/bin\|git-config\/hooks\|cont-init\|services\.d\|\.sh' | xargs -I {} chmod +x {} - -echo "πŸ€– Generating checksums for workflow..." -exec $BASE/checksum.sh \ No newline at end of file diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 79fa004d..6261690f 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,4 +1,7 @@ -# These are supported funding model platforms +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ github: shinsenter -custom: ['https://www.paypal.me/shinsenter'] +custom: ['https://www.paypal.me/shinsenter'] \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 6abc9aad..cad91c6b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,10 +7,10 @@ assignees: - shinsenter --- - @@ -25,9 +25,9 @@ assignees: ## Steps to reproduce the issue -1. -2. -3. +1. +2. +3. ## What is expected? diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 4c1ec462..f875b80e 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,9 +1,9 @@ blank_issues_enabled: false contact_links: - name: ✨ Request a feature - url: https://github.com/shinsenter/php/discussions/new?category=ideas + url: https://code.shin.company/php/discussions/new?category=ideas about: Suggest an idea for a feature. - name: 🀡 Get Professional Support & Customizations - url: mailto:admin@appseeds.net?subject=I%20need%20professional%20support%20for%20docker-phpfpm&body=I%20am%20looking%20for%20professional%20support%20for%20docker-phpfpm.%0D%0Ahttps%3A%2F%2Fgithub.com%2Fshinsenter%2Fdocker-phpfpm + url: mailto:shin@shin.company?subject=I%20need%20professional%20support%20for%20docker-phpfpm&body=I%20am%20looking%20for%20professional%20support%20for%20the%20Docker%20image%20shinsenter%2Fphp.%0D%0A%0D%0A about: Skip the line and get priority support directly from the project owner. diff --git a/.github/workflows/build-v2.yml b/.github/workflows/build-v2.yml new file mode 100644 index 00000000..b8f45f0f --- /dev/null +++ b/.github/workflows/build-v2.yml @@ -0,0 +1,637 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +name: Publish shinsenter/php (v2.x) + +################################################################################ +################################################################################ + +on: + push: + branches: + - main + paths: + - .github/workflows/build-v2.yml + - PHP_VERSIONS + - S6_VERSION + - src/** + pull_request: + types: + - opened + - reopened + branches: + - main + paths: + - .github/workflows/build-v2.yml + - PHP_VERSIONS + - S6_VERSION + - src/** + schedule: + - cron: "0 0 * * *" + +################################################################################ +################################################################################ + +jobs: + ############################################################################## + # Scratch images + ############################################################################## + + scratch: + runs-on: ubuntu-latest + env: + DOCKER_BUILDKIT: "1" + steps: + - uses: actions/checkout@v3 + - + id: config + run: | + ./.bin/prebuild src/base nometa + echo "::set-output name=BUILD_CONTEXT::src/base" + echo "::set-output name=BUILD_NAME::shinsenter/scratch" + - + id: cache + uses: actions/cache@v3 + with: + path: ${{ steps.config.outputs.BUILD_CACHE_DIR }} + key: ${{ runner.os }}-${{ steps.config.outputs.CHECKSUM }} + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/setup-qemu-action@v2 + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/setup-buildx-action@v2 + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - + if: steps.cache.outputs.cache-hit != 'true' + name: Build ${{ steps.config.outputs.BUILD_NAME }} + uses: docker/build-push-action@v3 + with: + push: ${{ github.ref_name == 'main' }} + context: ${{ steps.config.outputs.BUILD_CONTEXT }} + platforms: | + linux/386 + linux/amd64 + linux/amd64/v2 + linux/amd64/v3 + linux/amd64/v4 + linux/arm/v6 + linux/arm/v7 + linux/arm64/v8 + linux/mips64 + linux/mips64le + linux/ppc64le + linux/riscv64 + linux/s390x + build-args: | + BUILD_CONTEXT=${{ steps.config.outputs.BUILD_CONTEXT }} + BUILD_DATE=${{ steps.config.outputs.BUILD_DATE }} + BUILD_DESC=${{ steps.config.outputs.BUILD_DESC }} + BUILD_NAME=${{ steps.config.outputs.BUILD_NAME }} + BUILD_REVISION=${{ steps.config.outputs.BUILD_REVISION }} + tags: ${{ steps.config.outputs.BUILD_NAME }}:latest + - + name: Update ${{ steps.config.outputs.BUILD_NAME }}/README.md + uses: peter-evans/dockerhub-description@v3 + continue-on-error: true + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PASSWORD }} + repository: ${{ steps.config.outputs.BUILD_NAME }} + short-description: '${{ steps.config.outputs.BUILD_DESC }}' + readme-filepath: ${{ steps.config.outputs.BUILD_CONTEXT }}/README.md + + ############################################################################## + # S6 Overlay build stage + ############################################################################## + + s6-overlay: + needs: scratch + runs-on: ubuntu-latest + env: + DOCKER_BUILDKIT: "1" + steps: + - uses: actions/checkout@v3 + - + id: config + run: | + ./.bin/prebuild src/base-s6 + echo "::set-output name=BUILD_CONTEXT::src/base-s6" + echo "::set-output name=BUILD_NAME::shinsenter/s6-overlay" + - + id: cache + uses: actions/cache@v3 + with: + path: ${{ steps.config.outputs.BUILD_CACHE_DIR }} + key: ${{ runner.os }}-${{ steps.config.outputs.CHECKSUM }} + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/setup-qemu-action@v2 + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/setup-buildx-action@v2 + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - + if: steps.cache.outputs.cache-hit != 'true' + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ steps.config.outputs.BUILD_NAME }} + tags: | + type=raw,value=latest + type=raw,value=${{ steps.config.outputs.S6_VERSION }} + - + if: steps.cache.outputs.cache-hit != 'true' + name: Build ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.S6_VERSION }} + uses: docker/build-push-action@v3 + with: + push: ${{ github.ref_name == 'main' }} + context: ${{ steps.config.outputs.BUILD_CONTEXT }} + platforms: | + linux/amd64 + linux/arm/v7 + linux/arm64/v8 + linux/ppc64le + linux/riscv64 + linux/s390x + build-args: | + BUILD_CONTEXT=${{ steps.config.outputs.BUILD_CONTEXT }} + BUILD_DATE=${{ steps.config.outputs.BUILD_DATE }} + BUILD_DESC=${{ steps.config.outputs.BUILD_DESC }} + BUILD_NAME=${{ steps.config.outputs.BUILD_NAME }} + BUILD_REVISION=${{ steps.config.outputs.BUILD_REVISION }} + S6_VERSION=${{ steps.config.outputs.S6_VERSION }} + tags: ${{ steps.meta.outputs.tags }} + - + name: Update ${{ steps.config.outputs.BUILD_NAME }}/README.md + uses: peter-evans/dockerhub-description@v3 + continue-on-error: true + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PASSWORD }} + repository: ${{ steps.config.outputs.BUILD_NAME }} + short-description: '${{ steps.config.outputs.BUILD_DESC }}' + readme-filepath: ${{ steps.config.outputs.BUILD_CONTEXT }}/README.md + + ############################################################################## + # Base Ubuntu with S6 Overlay + ############################################################################## + + ubuntu: + needs: s6-overlay + runs-on: ubuntu-latest + strategy: + max-parallel: 20 + matrix: + base: + - ubuntu + version: + - 22.04 + - 20.04 + env: + DOCKER_BUILDKIT: "1" + steps: + - uses: actions/checkout@v3 + - + id: config + run: | + ./.bin/prebuild src/base-ubuntu + echo "::set-output name=BUILD_CONTEXT::src/base-ubuntu" + echo "::set-output name=BUILD_NAME::shinsenter/s6-ubuntu" + - + id: cache + uses: actions/cache@v3 + with: + path: ${{ steps.config.outputs.BUILD_CACHE_DIR }} + key: ${{ runner.os }}-ubuntu${{ matrix.version }}-${{ steps.config.outputs.CHECKSUM }} + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/setup-qemu-action@v2 + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/setup-buildx-action@v2 + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - + if: steps.cache.outputs.cache-hit != 'true' + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ steps.config.outputs.BUILD_NAME }} + tags: | + type=raw,value=latest,enable=${{ matrix.version == steps.config.outputs.LATEST_OS }} + type=raw,value=s6-${{ steps.config.outputs.S6_VERSION }},enable=${{ matrix.version == steps.config.outputs.LATEST_OS }} + type=raw,value=${{ matrix.version }} + type=raw,value=${{ matrix.version }}-s6-${{ steps.config.outputs.S6_VERSION }} + type=raw,value=focal,enable=${{ matrix.version == '20.04' }} + type=raw,value=focal-s6-${{ steps.config.outputs.S6_VERSION }},enable=${{ matrix.version == '20.04' }} + type=raw,value=jammy,enable=${{ matrix.version == '22.04' }} + type=raw,value=jammy-s6-${{ steps.config.outputs.S6_VERSION }},enable=${{ matrix.version == '22.04' }} + - + if: steps.cache.outputs.cache-hit != 'true' + name: Build ${{ steps.config.outputs.BUILD_NAME }}:${{ matrix.version }} + uses: docker/build-push-action@v3 + with: + push: ${{ github.ref_name == 'main' }} + context: ${{ steps.config.outputs.BUILD_CONTEXT }} + platforms: | + linux/amd64 + linux/arm/v7 + linux/arm64/v8 + linux/ppc64le + linux/riscv64 + linux/s390x + build-args: | + BASE_OS_IMAGE=${{ matrix.base }}:${{ matrix.version }} + BUILD_CONTEXT=${{ steps.config.outputs.BUILD_CONTEXT }} + BUILD_DATE=${{ steps.config.outputs.BUILD_DATE }} + BUILD_DESC=${{ steps.config.outputs.BUILD_DESC }} + BUILD_NAME=${{ steps.config.outputs.BUILD_NAME }} + BUILD_REVISION=${{ steps.config.outputs.BUILD_REVISION }} + S6_VERSION=${{ steps.config.outputs.S6_VERSION }} + tags: ${{ steps.meta.outputs.tags }} + - + name: Update ${{ steps.config.outputs.BUILD_NAME }}/README.md + uses: peter-evans/dockerhub-description@v3 + continue-on-error: true + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PASSWORD }} + repository: ${{ steps.config.outputs.BUILD_NAME }} + short-description: '${{ steps.config.outputs.BUILD_DESC }}' + readme-filepath: ${{ steps.config.outputs.BUILD_CONTEXT }}/README.md + + ############################################################################## + # Base PHP-CLI & PHP-FPM + ############################################################################## + + php: + needs: ubuntu + runs-on: ubuntu-latest + strategy: + max-parallel: 20 + matrix: + version: + - "7.3" + - "7.4" + - "8.0" + - "8.1" + env: + DOCKER_BUILDKIT: "1" + steps: + - uses: actions/checkout@v3 + - + id: config + run: | + ./.bin/prebuild src/php/cli + ./.bin/prebuild src/php/fpm + echo "::set-output name=BUILD_CONTEXT_CLI::src/php/cli" + echo "::set-output name=BUILD_CONTEXT_FPM::src/php/fpm" + echo "::set-output name=BUILD_NAME::shinsenter/php" + - + id: cache + uses: actions/cache@v3 + with: + path: ${{ steps.config.outputs.BUILD_CACHE_DIR }} + key: ${{ runner.os }}-php${{ matrix.version }}-${{ steps.config.outputs.CHECKSUM }} + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/setup-qemu-action@v2 + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/setup-buildx-action@v2 + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - + if: steps.cache.outputs.cache-hit != 'true' + id: meta-cli + uses: docker/metadata-action@v4 + with: + images: ${{ steps.config.outputs.BUILD_NAME }} + tags: | + type=raw,value=latest,enable=${{ matrix.version == steps.config.outputs.LATEST_PHP }} + type=raw,value=cli,enable=${{ matrix.version == steps.config.outputs.LATEST_PHP }} + type=raw,value=${{ matrix.version }}-cli + type=raw,value=${{ matrix.version }} + - + if: steps.cache.outputs.cache-hit != 'true' + id: meta-fpm + uses: docker/metadata-action@v4 + with: + images: ${{ steps.config.outputs.BUILD_NAME }} + tags: | + type=raw,value=fpm,enable=${{ matrix.version == steps.config.outputs.LATEST_PHP }} + type=raw,value=${{ matrix.version }}-fpm + - + if: steps.cache.outputs.cache-hit != 'true' + name: Build ${{ steps.config.outputs.BUILD_NAME }}:${{ matrix.version }}-cli + uses: docker/build-push-action@v3 + with: + push: ${{ github.ref_name == 'main' }} + context: ${{ steps.config.outputs.BUILD_CONTEXT_CLI }} + platforms: ${{ steps.config.outputs.BUILD_PLATFORM }} + build-args: | + BUILD_CONTEXT=${{ steps.config.outputs.BUILD_CONTEXT_CLI }} + BUILD_DATE=${{ steps.config.outputs.BUILD_DATE }} + BUILD_DESC=${{ steps.config.outputs.BUILD_DESC }} + BUILD_NAME=${{ steps.config.outputs.BUILD_NAME }} + BUILD_REVISION=${{ steps.config.outputs.BUILD_REVISION }} + PHP_VERSION=${{ matrix.version }} + tags: ${{ steps.meta-cli.outputs.tags }} + - + if: steps.cache.outputs.cache-hit != 'true' + name: Build ${{ steps.config.outputs.BUILD_NAME }}:${{ matrix.version }}-fpm + uses: docker/build-push-action@v3 + with: + push: ${{ github.ref_name == 'main' }} + context: ${{ steps.config.outputs.BUILD_CONTEXT_FPM }} + platforms: ${{ steps.config.outputs.BUILD_PLATFORM }} + build-args: | + BUILD_CONTEXT=${{ steps.config.outputs.BUILD_CONTEXT_FPM }} + BUILD_DATE=${{ steps.config.outputs.BUILD_DATE }} + BUILD_DESC=${{ steps.config.outputs.BUILD_DESC }} + BUILD_NAME=${{ steps.config.outputs.BUILD_NAME }} + BUILD_REVISION=${{ steps.config.outputs.BUILD_REVISION }} + PHP_VERSION=${{ matrix.version }} + tags: ${{ steps.meta-fpm.outputs.tags }} + + ############################################################################## + # Update README.md for main repo + ############################################################################## + + readme: + needs: ubuntu + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - + id: config + run: | + echo -e "\n\n$(cat ./SPONSOR.md)" >>./README.md + echo "::set-output name=BUILD_DESC::$(sed '3q;d' ./README.md)" + - + name: Update README.md + uses: peter-evans/dockerhub-description@v3 + continue-on-error: true + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PASSWORD }} + repository: shinsenter/php + short-description: '${{ steps.config.outputs.BUILD_DESC }}' + readme-filepath: ./README.md + + ############################################################################## + # Base PHP Web Servers (Apache or Nginx) + ############################################################################## + + php-servers: + needs: php + runs-on: ubuntu-latest + strategy: + max-parallel: 20 + matrix: + version: + - "7.3" + - "7.4" + - "8.0" + - "8.1" + variation: + - fpm-apache + - fpm-nginx + env: + DOCKER_BUILDKIT: "1" + steps: + - uses: actions/checkout@v3 + - + id: config + run: | + ./.bin/prebuild src/servers/${{ matrix.variation }} + echo "::set-output name=BUILD_CONTEXT::src/servers/${{ matrix.variation }}" + echo "::set-output name=BUILD_NAME::shinsenter/php${{ matrix.variation }}" + echo "::set-output name=BUILD_VERSION::php${{ matrix.version }}" + - + id: cache + uses: actions/cache@v3 + with: + path: ${{ steps.config.outputs.BUILD_CACHE_DIR }} + key: ${{ runner.os }}-php${{ matrix.version }}-${{ matrix.variation }}-${{ steps.config.outputs.CHECKSUM }} + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/setup-qemu-action@v2 + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/setup-buildx-action@v2 + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - + if: steps.cache.outputs.cache-hit != 'true' + id: meta-php + uses: docker/metadata-action@v4 + with: + images: shinsenter/php + tags: | + type=raw,value=${{ matrix.variation }},enable=${{ matrix.version == steps.config.outputs.LATEST_PHP }} + type=raw,value=${{ matrix.version }}-${{ matrix.variation }} + - + if: steps.cache.outputs.cache-hit != 'true' + id: meta-server + uses: docker/metadata-action@v4 + with: + images: ${{ steps.config.outputs.BUILD_NAME }} + tags: | + type=raw,value=latest,enable=${{ matrix.version == steps.config.outputs.LATEST_PHP }} + type=raw,value=${{ steps.config.outputs.BUILD_VERSION }} + - + if: steps.cache.outputs.cache-hit != 'true' + name: Build ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }} + uses: docker/build-push-action@v3 + with: + push: ${{ github.ref_name == 'main' }} + context: ${{ steps.config.outputs.BUILD_CONTEXT }} + platforms: ${{ steps.config.outputs.BUILD_PLATFORM }} + build-args: | + BUILD_CONTEXT=${{ steps.config.outputs.BUILD_CONTEXT }} + BUILD_DATE=${{ steps.config.outputs.BUILD_DATE }} + BUILD_DESC=${{ steps.config.outputs.BUILD_DESC }} + BUILD_NAME=${{ steps.config.outputs.BUILD_NAME }} + BUILD_REVISION=${{ steps.config.outputs.BUILD_REVISION }} + PHP_VERSION=${{ matrix.version }} + tags: | + ${{ steps.meta-php.outputs.tags }} + ${{ steps.meta-server.outputs.tags }} + - + if: steps.cache.outputs.cache-hit != 'true' + id: minify + run: | + tidy="${{ steps.config.outputs.BUILD_CONTEXT }}/Dockerfile.tidy" + name="${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }}" + docker pull $name && touch $tidy && ./.bin/tidy-docker $tidy $name "${name}-tidy" + if [ -f $tidy ]; then + echo "::set-output name=BUILD_TIDY_FILE::${tidy}" + echo "::set-output name=BUILD_TIDY_NAME::${name}-tidy" + fi + - + if: steps.cache.outputs.cache-hit != 'true' && steps.minify.outputs.BUILD_TIDY_FILE != '' + name: Minify ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }} + uses: docker/build-push-action@v3 + with: + push: ${{ github.ref_name == 'main' }} + context: ${{ steps.config.outputs.BUILD_CONTEXT }} + file: ${{ steps.minify.outputs.BUILD_TIDY_FILE }} + tags: ${{ steps.minify.outputs.BUILD_TIDY_NAME }} + platforms: ${{ steps.config.outputs.BUILD_PLATFORM }} + - + name: Update ${{ steps.config.outputs.BUILD_NAME }}/README.md + uses: peter-evans/dockerhub-description@v3 + continue-on-error: true + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PASSWORD }} + repository: ${{ steps.config.outputs.BUILD_NAME }} + short-description: '${{ steps.config.outputs.BUILD_DESC }}' + readme-filepath: ${{ steps.config.outputs.BUILD_CONTEXT }}/README.md + + ############################################################################## + # PHP-Based Popular Web Applications + ############################################################################## + + php-webapps: + needs: php-servers + runs-on: ubuntu-latest + strategy: + max-parallel: 20 + matrix: + version: + - "7.3" + - "7.4" + - "8.0" + - "8.1" + app: + - cakephp4 + - codeigniter4 + - crater + - flarum + - fuelphp + - grav + - hyperf + - kirby + - laminas + - laravel + - phpmyadmin + - slim + - statamic + - symfony + - wordpress + - yii + env: + DOCKER_BUILDKIT: "1" + steps: + - uses: actions/checkout@v3 + - + id: config + run: | + ./.bin/prebuild src/webapps/${{ matrix.app }} + echo "::set-output name=BUILD_CONTEXT::src/webapps/${{ matrix.app }}" + echo "::set-output name=BUILD_NAME::shinsenter/${{ matrix.app }}" + echo "::set-output name=BUILD_VERSION::php${{ matrix.version }}" + - + id: cache + uses: actions/cache@v3 + with: + path: ${{ steps.config.outputs.BUILD_CACHE_DIR }} + key: ${{ runner.os }}-php${{ matrix.version }}-${{ matrix.app }}-${{ steps.config.outputs.CHECKSUM }} + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/setup-qemu-action@v2 + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/setup-buildx-action@v2 + - + if: steps.cache.outputs.cache-hit != 'true' + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - + if: steps.cache.outputs.cache-hit != 'true' + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ steps.config.outputs.BUILD_NAME }} + tags: | + type=raw,value=latest,enable=${{ matrix.version == steps.config.outputs.LATEST_PHP }} + type=raw,value=${{ steps.config.outputs.BUILD_VERSION }} + - + if: steps.cache.outputs.cache-hit != 'true' + name: Build ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }} + uses: docker/build-push-action@v3 + with: + push: ${{ github.ref_name == 'main' }} + context: ${{ steps.config.outputs.BUILD_CONTEXT }} + platforms: ${{ steps.config.outputs.BUILD_PLATFORM }} + build-args: | + BUILD_CONTEXT=${{ steps.config.outputs.BUILD_CONTEXT }} + BUILD_DATE=${{ steps.config.outputs.BUILD_DATE }} + BUILD_DESC=${{ steps.config.outputs.BUILD_DESC }} + BUILD_NAME=${{ steps.config.outputs.BUILD_NAME }} + BUILD_REVISION=${{ steps.config.outputs.BUILD_REVISION }} + PHP_VERSION=${{ matrix.version }} + tags: ${{ steps.meta.outputs.tags }} + - + if: steps.cache.outputs.cache-hit != 'true' + id: minify + run: | + tidy="${{ steps.config.outputs.BUILD_CONTEXT }}/Dockerfile.tidy" + name="${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }}" + docker pull $name && touch $tidy && ./.bin/tidy-docker $tidy $name "${name}-tidy" + if [ -f $tidy ]; then + echo "::set-output name=BUILD_TIDY_FILE::${tidy}" + echo "::set-output name=BUILD_TIDY_NAME::${name}-tidy" + fi + - + if: steps.cache.outputs.cache-hit != 'true' && steps.minify.outputs.BUILD_TIDY_FILE != '' + name: Minify ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }} + uses: docker/build-push-action@v3 + with: + push: ${{ github.ref_name == 'main' }} + context: ${{ steps.config.outputs.BUILD_CONTEXT }} + file: ${{ steps.minify.outputs.BUILD_TIDY_FILE }} + tags: ${{ steps.minify.outputs.BUILD_TIDY_NAME }} + platforms: ${{ steps.config.outputs.BUILD_PLATFORM }} + - + name: Update ${{ steps.config.outputs.BUILD_NAME }}/README.md + uses: peter-evans/dockerhub-description@v3 + continue-on-error: true + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PASSWORD }} + repository: ${{ steps.config.outputs.BUILD_NAME }} + short-description: '${{ steps.config.outputs.BUILD_DESC }}' + readme-filepath: ${{ steps.config.outputs.BUILD_CONTEXT }}/README.md + +################################################################################ +################################################################################ diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog-v2.yml similarity index 83% rename from .github/workflows/changelog.yml rename to .github/workflows/changelog-v2.yml index ffc7cb95..ad0a6b44 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog-v2.yml @@ -1,3 +1,8 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + name: Update Changelog ################################################################################ diff --git a/.github/workflows/devskim.yml b/.github/workflows/devskim.yml new file mode 100644 index 00000000..9d21b138 --- /dev/null +++ b/.github/workflows/devskim.yml @@ -0,0 +1,22 @@ +name: DevSkim +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + schedule: + - cron: '0 0 * * 2' +jobs: + lint: + name: DevSkim + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + steps: + - uses: actions/checkout@v3 + - uses: microsoft/DevSkim-Action@v1 + - uses: github/codeql-action/upload-sarif@v2 + with: + sarif_file: devskim-results.sarif diff --git a/.github/workflows/publish-images.yml b/.github/workflows/publish-images.yml deleted file mode 100644 index 2b7d4135..00000000 --- a/.github/workflows/publish-images.yml +++ /dev/null @@ -1,453 +0,0 @@ -name: Publish Images (shinsenter/php) - -################################################################################ -################################################################################ - -on: - # pull_request: - # types: - # - opened - # - reopened - # branches: - # - main - # paths: - # - '.github/workflows/publish-images.yml' - # - 'src/**' - push: - branches: - - main - paths: - - 'checksum.sh' - - '.github/workflows/publish-images.yml' - - 'src/**' - schedule: - - cron: "0 0 * * 0,3" - -################################################################################ -################################################################################ - -jobs: - ############################################################################## - # S6 Overlay build stage - ############################################################################## - - s6-overlay: - runs-on: ubuntu-latest - strategy: - max-parallel: 10 - matrix: - image: - - shinsenter/s6-overlay - env: - DOCKER_BUILDKIT: "1" - steps: - - uses: actions/checkout@v3 - - uses: docker/setup-qemu-action@v1 - - uses: docker/setup-buildx-action@v1 - - - id: config - run: | - ./.git-config/hooks/pre-commit - ./.git-config/hooks/pre-build src/base-s6 - echo "::set-output name=BUILD_NAME::${{ matrix.image }}" - echo "::set-output name=BUILD_VERSION::$(cat ./S6_VERSION.txt)" - echo "::set-output name=S6_VERSION::$(cat ./S6_VERSION.txt)" - - - uses: actions/cache@v2 - with: - path: /tmp/buildx - key: ${{ runner.os }}-buildx-${{ steps.config.outputs.S6_VERSION }} - restore-keys: "${{ runner.os }}-buildx-" - - - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Building ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }} - uses: docker/build-push-action@v2 - with: - push: true - cache-from: type=local,src=/tmp/buildx - cache-to: type=local,dest=/tmp/buildx,mode=max - context: ./src/base-s6/ - platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/riscv64,linux/s390x - build-args: | - BUILD_NAME=${{ steps.config.outputs.BUILD_NAME }} - BUILD_VERSION=${{ steps.config.outputs.BUILD_VERSION }} - BUILD_DESC=${{ steps.config.outputs.BUILD_DESC }} - BUILD_DATE=${{ steps.config.outputs.BUILD_DATE }} - VCS_REF=${{ steps.config.outputs.VCS_REF }} - S6_VERSION=${{ steps.config.outputs.S6_VERSION }} - tags: | - ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.S6_VERSION }} - ${{ steps.config.outputs.BUILD_NAME }}:latest - - - name: Updating ${{ steps.config.outputs.BUILD_NAME }}/README.md - uses: peter-evans/dockerhub-description@v2 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_PASSWORD }} - repository: ${{ steps.config.outputs.BUILD_NAME }} - short-description: '${{ steps.config.outputs.BUILD_DESC }}' - readme-filepath: ./src/base-s6/README.md - - ############################################################################## - # Base Ubuntu with S6 Overlay - ############################################################################## - - base: - needs: s6-overlay - runs-on: ubuntu-latest - strategy: - max-parallel: 2 - matrix: - base: - - ubuntu - version: - - 20.04 - - focal - image: - - shinsenter/s6-ubuntu - env: - DOCKER_BUILDKIT: "1" - steps: - - uses: actions/checkout@v3 - - uses: docker/setup-qemu-action@v1 - - uses: docker/setup-buildx-action@v1 - - - id: config - run: | - ./.git-config/hooks/pre-commit - ./.git-config/hooks/pre-build src/base-ubuntu - cat versions/base.txt - echo "::set-output name=BUILD_NAME::${{ matrix.image }}" - echo "::set-output name=BUILD_VERSION::${{ matrix.version }}-s6-$(cat ./S6_VERSION.txt)" - echo "::set-output name=S6_VERSION::$(cat ./S6_VERSION.txt)" - - - uses: actions/cache@v2 - with: - path: /tmp/buildx - key: "${{ runner.os }}-buildx-\ - ${{ hashFiles('versions/base.txt') }}" - restore-keys: "${{ runner.os }}-buildx-" - - - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Building ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }} - uses: docker/build-push-action@v2 - with: - push: true - cache-from: type=local,src=/tmp/buildx - cache-to: type=local,dest=/tmp/buildx-new,mode=max - context: ./src/base-ubuntu/ - platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le,linux/riscv64,linux/s390x - build-args: | - BUILD_NAME=${{ steps.config.outputs.BUILD_NAME }} - BUILD_VERSION=${{ steps.config.outputs.BUILD_VERSION }} - BUILD_DESC=${{ steps.config.outputs.BUILD_DESC }} - BUILD_DATE=${{ steps.config.outputs.BUILD_DATE }} - VCS_REF=${{ steps.config.outputs.VCS_REF }} - BASE_IMAGE=${{ matrix.base }}:${{ matrix.version }} - S6_VERSION=${{ steps.config.outputs.S6_VERSION }} - tags: | - ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }} - ${{ steps.config.outputs.BUILD_NAME }}:${{ matrix.version }} - ${{ steps.config.outputs.BUILD_NAME }}:s6-${{ steps.config.outputs.S6_VERSION }} - ${{ steps.config.outputs.BUILD_NAME }}:latest - - - name: Updating ${{ steps.config.outputs.BUILD_NAME }}/README.md - uses: peter-evans/dockerhub-description@v2 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_PASSWORD }} - repository: ${{ steps.config.outputs.BUILD_NAME }} - short-description: '${{ steps.config.outputs.BUILD_DESC }}' - readme-filepath: ./src/base-ubuntu/README.md - - - run: | - rm -rf /tmp/buildx - mv /tmp/buildx-new /tmp/buildx - - ############################################################################## - # Base PHP-CLI & PHP-FPM - ############################################################################## - - php: - needs: base - runs-on: ubuntu-latest - strategy: - max-parallel: 2 - matrix: - version: - - "7.4" - - "8.0" - - "8.1" - image: - - shinsenter/php - env: - DOCKER_BUILDKIT: "1" - steps: - - uses: actions/checkout@v3 - - uses: docker/setup-qemu-action@v1 - - uses: docker/setup-buildx-action@v1 - - - id: config - run: | - ./.git-config/hooks/pre-commit - ./.git-config/hooks/pre-build src/php/fpm - cat versions/fpm.txt - echo "::set-output name=BUILD_NAME::${{ matrix.image }}" - echo "::set-output name=BUILD_VERSION::${{ matrix.version }}" - - - uses: actions/cache@v2 - with: - path: /tmp/buildx - key: "${{ runner.os }}-buildx-php-${{ matrix.version }}-\ - ${{ hashFiles('versions/cli.txt') }}" - restore-keys: "${{ runner.os }}-buildx-" - - - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Building ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }}-cli - uses: docker/build-push-action@v2 - with: - push: true - cache-from: type=local,src=/tmp/buildx - cache-to: type=local,dest=/tmp/buildx,mode=max - context: ./src/php/cli/ - platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le - build-args: | - BUILD_NAME=${{ steps.config.outputs.BUILD_NAME }} - BUILD_VERSION=${{ steps.config.outputs.BUILD_VERSION }}-cli - BUILD_DESC=${{ steps.config.outputs.BUILD_DESC }} - BUILD_DATE=${{ steps.config.outputs.BUILD_DATE }} - VCS_REF=${{ steps.config.outputs.VCS_REF }} - BASE_IMAGE=shinsenter/s6-ubuntu:latest - PHP_VERSION=${{ matrix.version }} - tags: | - ${{ steps.config.outputs.BUILD_NAME }}:cli - ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }} - ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }}-cli - ${{ steps.config.outputs.BUILD_NAME }}:latest - - - name: Building ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }}-fpm - uses: docker/build-push-action@v2 - with: - push: true - cache-from: type=local,src=/tmp/buildx - cache-to: type=local,dest=/tmp/buildx-new,mode=max - context: ./src/php/fpm/ - platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le - build-args: | - BUILD_NAME=${{ steps.config.outputs.BUILD_NAME }} - BUILD_VERSION=${{ steps.config.outputs.BUILD_VERSION }}-fpm - BUILD_DESC=${{ steps.config.outputs.BUILD_DESC }} - BUILD_DATE=${{ steps.config.outputs.BUILD_DATE }} - VCS_REF=${{ steps.config.outputs.VCS_REF }} - PHP_VERSION=${{ matrix.version }} - tags: | - ${{ steps.config.outputs.BUILD_NAME }}:fpm - ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }}-fpm - - - run: | - rm -rf /tmp/buildx - mv /tmp/buildx-new /tmp/buildx - - ############################################################################## - # Update README.md - ############################################################################## - - readme: - needs: php - runs-on: ubuntu-latest - strategy: - max-parallel: 1 - matrix: - image: - - shinsenter/php - steps: - - uses: actions/checkout@v3 - - - id: config - run: | - echo -e "\n\n$(cat ./SPONSOR.md)" >>./README.md - echo "::set-output name=BUILD_DESC::$(sed '3q;d' ./README.md)" - - - name: Updating ${{ matrix.image }}/README.md - uses: peter-evans/dockerhub-description@v2 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_PASSWORD }} - repository: ${{ matrix.image }} - short-description: '${{ steps.config.outputs.BUILD_DESC }}' - readme-filepath: ./README.md - - ############################################################################## - # Base PHP Web Servers (Apache or Nginx) - ############################################################################## - - php-servers: - needs: php - runs-on: ubuntu-latest - strategy: - max-parallel: 4 - matrix: - version: - - "7.4" - - "8.0" - - "8.1" - variation: - - fpm-apache - - fpm-nginx - image: - - shinsenter/php - env: - DOCKER_BUILDKIT: "1" - steps: - - uses: actions/checkout@v3 - - uses: docker/setup-qemu-action@v1 - - uses: docker/setup-buildx-action@v1 - - - id: config - run: | - ./.git-config/hooks/pre-commit - ./.git-config/hooks/pre-build src/servers/${{ matrix.variation }} - cat versions/servers.txt - echo "::set-output name=BUILD_NAME::shinsenter/php${{ matrix.variation }}" - echo "::set-output name=BUILD_VERSION::php${{ matrix.version }}" - - - uses: actions/cache@v2 - with: - path: /tmp/buildx - key: "${{ runner.os }}-buildx-php-${{ matrix.version }}-${{ matrix.variation }}-\ - ${{ hashFiles('versions/servers.txt') }}" - restore-keys: "${{ runner.os }}-buildx-php-${{ matrix.version }}-" - - - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Building ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }} - uses: docker/build-push-action@v2 - with: - push: true - cache-from: type=local,src=/tmp/buildx - cache-to: type=local,dest=/tmp/buildx-new,mode=max - context: ./src/servers/${{ matrix.variation }}/ - platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le - build-args: | - BUILD_NAME=${{ steps.config.outputs.BUILD_NAME }} - BUILD_VERSION=${{ steps.config.outputs.BUILD_VERSION }} - BUILD_DESC=${{ steps.config.outputs.BUILD_DESC }} - BUILD_DATE=${{ steps.config.outputs.BUILD_DATE }} - VCS_REF=${{ steps.config.outputs.VCS_REF }} - BASE_IMAGE=${{ matrix.image }} - PHP_VERSION=${{ matrix.version }} - tags: | - ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }} - ${{ steps.config.outputs.BUILD_NAME }}:latest - ${{ matrix.image }}:${{ matrix.version }}-${{ matrix.variation }} - ${{ matrix.image }}:${{ matrix.variation }} - - - name: Updating ${{ steps.config.outputs.BUILD_NAME }}/README.md - uses: peter-evans/dockerhub-description@v2 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_PASSWORD }} - repository: ${{ steps.config.outputs.BUILD_NAME }} - short-description: '${{ steps.config.outputs.BUILD_DESC }}' - readme-filepath: ./src/servers/${{ matrix.variation }}/README.md - - - run: | - rm -rf /tmp/buildx - mv /tmp/buildx-new /tmp/buildx - - ############################################################################## - # PHP-Based Popular Web Applications - ############################################################################## - - php-webapps: - needs: php-servers - runs-on: ubuntu-latest - strategy: - max-parallel: 10 - matrix: - version: - - "7.4" - - "8.0" - - "8.1" - app: - - wordpress - - phpmyadmin - - laravel - - codeigniter4 - - symfony - env: - DOCKER_BUILDKIT: "1" - steps: - - uses: actions/checkout@v3 - - uses: docker/setup-qemu-action@v1 - - uses: docker/setup-buildx-action@v1 - - - id: config - run: | - ./.git-config/hooks/pre-commit - ./.git-config/hooks/pre-build src/webapps/${{ matrix.app }} - cat versions/webapps.txt - echo "::set-output name=BUILD_NAME::shinsenter/${{ matrix.app }}" - echo "::set-output name=BUILD_VERSION::php${{ matrix.version }}" - - - uses: actions/cache@v2 - with: - path: /tmp/buildx - key: "${{ runner.os }}-buildx-php-${{ matrix.version }}-${{ matrix.app }}-\ - ${{ hashFiles('versions/webapps.txt') }}" - restore-keys: "${{ runner.os }}-buildx-php-${{ matrix.version }}-" - - - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Building ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }} - uses: docker/build-push-action@v2 - with: - push: true - cache-from: type=local,src=/tmp/buildx - cache-to: type=local,dest=/tmp/buildx-new,mode=max - context: ./src/webapps/${{ matrix.app }}/ - platforms: linux/amd64,linux/arm/v7,linux/arm64,linux/ppc64le - build-args: | - BUILD_NAME=${{ steps.config.outputs.BUILD_NAME }} - BUILD_VERSION=${{ steps.config.outputs.BUILD_VERSION }} - BUILD_DESC=${{ steps.config.outputs.BUILD_DESC }} - BUILD_DATE=${{ steps.config.outputs.BUILD_DATE }} - VCS_REF=${{ steps.config.outputs.VCS_REF }} - PHP_VERSION=${{ matrix.version }} - tags: | - ${{ steps.config.outputs.BUILD_NAME }}:${{ steps.config.outputs.BUILD_VERSION }} - ${{ steps.config.outputs.BUILD_NAME }}:latest - - - name: Updating ${{ steps.config.outputs.BUILD_NAME }}/README.md - uses: peter-evans/dockerhub-description@v2 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_PASSWORD }} - repository: ${{ steps.config.outputs.BUILD_NAME }} - short-description: '${{ steps.config.outputs.BUILD_DESC }}' - readme-filepath: ./src/webapps/${{ matrix.app }}/README.md - - - run: | - rm -rf /tmp/buildx - mv /tmp/buildx-new /tmp/buildx - -################################################################################ -################################################################################ diff --git a/.gitignore b/.gitignore index ef9dc131..6ca10637 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ +.checksum +.Dockerfile.tidy .DS_Store +.source *.log -tests/data/ -versions/ \ No newline at end of file +builds/ +scratch/ +tests/data/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 045ff46d..81b16899 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,11 @@ { - "editor.rulers": [80, 100, 120], + "editor.rulers": [ + 60, + 80, + 100, + 120, + 160 + ], "editor.trimAutoWhitespace": true, "files.encoding": "utf8", "files.eol": "\n" diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a622bc4..36ccea87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,41 @@ # Changelog +## 2.0.0 - 2022-06-10 + +Hello Ubuntu Jammy (22.04 LTS)! + +Ubuntu 22.04 LTS β€œJammy Jellyfish” was released on April 21, 2022. + +So I decided that new Docker images from the v2.0 releases should be built from this Ubuntu version to ensure they are up to date with system security patches. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/php)](https://docker.shin.company/php) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/php/latest?label=shinsenter%2Fphp)](https://docker.shin.company/php) + +--- + +I also added more popular PHP open source projects: + +- [![`shinsenter/cakephp4`](https://img.shields.io/docker/image-size/shinsenter/cakephp4/latest?label=shinsenter%2Fcakephp4)](https://docker.shin.company/cakephp4) +- [![`shinsenter/codeigniter4`](https://img.shields.io/docker/image-size/shinsenter/codeigniter4/latest?label=shinsenter%2Fcodeigniter4)](https://docker.shin.company/codeigniter4) +- [![`shinsenter/crater`](https://img.shields.io/docker/image-size/shinsenter/crater/latest?label=shinsenter%2Fcrater)](https://docker.shin.company/crater) +- [![`shinsenter/flarum`](https://img.shields.io/docker/image-size/shinsenter/flarum/latest?label=shinsenter%2Fflarum)](https://docker.shin.company/flarum) +- [![`shinsenter/fuelphp`](https://img.shields.io/docker/image-size/shinsenter/fuelphp/latest?label=shinsenter%2Ffuelphp)](https://docker.shin.company/fuelphp) +- [![`shinsenter/grav`](https://img.shields.io/docker/image-size/shinsenter/grav/latest?label=shinsenter%2Fgrav)](https://docker.shin.company/grav) +- [![`shinsenter/hyperf`](https://img.shields.io/docker/image-size/shinsenter/hyperf/latest?label=shinsenter%2Fhyperf)](https://docker.shin.company/hyperf) +- [![`shinsenter/kirby`](https://img.shields.io/docker/image-size/shinsenter/kirby/latest?label=shinsenter%2Fkirby)](https://docker.shin.company/kirby) +- [![`shinsenter/laminas`](https://img.shields.io/docker/image-size/shinsenter/laminas/latest?label=shinsenter%2Flaminas)](https://docker.shin.company/laminas) +- [![`shinsenter/laravel`](https://img.shields.io/docker/image-size/shinsenter/laravel/latest?label=shinsenter%2Flaravel)](https://docker.shin.company/laravel) +- [![`shinsenter/phpmyadmin`](https://img.shields.io/docker/image-size/shinsenter/phpmyadmin/latest?label=shinsenter%2Fphpmyadmin)](https://docker.shin.company/phpmyadmin) +- [![`shinsenter/symfony`](https://img.shields.io/docker/image-size/shinsenter/symfony/latest?label=shinsenter%2Fsymfony)](https://docker.shin.company/symfony) +- [![`shinsenter/slim`](https://img.shields.io/docker/image-size/shinsenter/slim/latest?label=shinsenter%2Fslim)](https://docker.shin.company/slim) +- [![`shinsenter/statamic`](https://img.shields.io/docker/image-size/shinsenter/statamic/latest?label=shinsenter%2Fstatamic)](https://docker.shin.company/statamic) +- [![`shinsenter/wordpress`](https://img.shields.io/docker/image-size/shinsenter/wordpress/latest?label=shinsenter%2Fwordpress)](https://docker.shin.company/wordpress) +- [![`shinsenter/yii`](https://img.shields.io/docker/image-size/shinsenter/yii/latest?label=shinsenter%2Fyii)](https://docker.shin.company/yii) + +--- + +Let's enjoy! ☺️ + + ## 1.7.0 - 2022-03-17 Upgraded Apache2 to v2.4.53 to fix these vulnerabilities. @@ -10,48 +46,55 @@ Upgraded Apache2 to v2.4.53 to fix these vulnerabilities. Improved the docker build workflow. + ## 1.6.0 - 2022-03-13 Added images which contain only the unpacked s6-overlay as a multi-platform build stage. -https://hub.docker.com/r/shinsenter/s6-overlay +> https://docker.shin.company/s6-overlay -[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/s6-overlay)](https://hub.docker.com/r/shinsenter/s6-overlay) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/s6-overlay/latest?label=shinsenter%2Fs6-overlay)](https://hub.docker.com/r/shinsenter/s6-overlay/tags) +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/s6-overlay)](https://docker.shin.company/s6-overlay) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/s6-overlay/latest?label=shinsenter%2Fs6-overlay)](https://docker.shin.company/s6-overlay) ### Usage The `shinsenter/s6-overlay` image is not intended to be used directly, but rather consumed in other Dockerfiles as a multi-platform and reusable build stage. ```Dockerfile -FROM ubuntu +FROM ubuntu:latest # adds file from the shinsenter/s6-overlay image COPY --from=shinsenter/s6-overlay / / + +# important: sets s6-overlay entrypoint ENTRYPOINT ["/init"] # runs other commands RUN ... +``` -``` ## 1.5.0 - 2022-03-12 - Small bug fixes. - Added README.md for each image page. + ## 1.4.0 - 2022-03-09 All files and folders in previous images that were granted 777 permissions have been modified with default permissions (755 for folders and 644 for files). + ## 1.3.0 - 2022-03-08 - Use S6 Overlay v3.1.0.1 - Small bug fixes + ## 1.2.0 - 2022-03-07 Added Symfony images. + ## 1.1.0 - 2022-03-07 Unify the WEBHOME environment variable for all Docker images. @@ -63,10 +106,8 @@ Unify the WEBHOME environment variable for all Docker images. ENV WEBHOME="/var/www/html" ################################################################################ - - - ``` + For Apache and Nginx base images, there are additional environment variables to specify to the root directory within this WEBHOME directory. ### shinsenter/php:fpm-apache @@ -82,10 +123,8 @@ ENV WEBHOME="/var/www/html" ENV APACHE_DOCUMENT_ROOT="" ################################################################################ - - - ``` + ### shinsenter/php:fpm-nginx ```Dockerfile @@ -99,32 +138,43 @@ ENV WEBHOME="/var/www/html" ENV NGINX_DOCUMENT_ROOT="" ################################################################################ +``` - -``` ## 1.0.0 - 2022-03-04 -## The very first release +### The very first release Docker images for PHP applications, from CLI to standalone web server. -https://hub.docker.com/r/shinsenter/php/tags - -[![Docker Pulls shinsenter/php](https://img.shields.io/docker/pulls/shinsenter/php)](https://hub.docker.com/r/shinsenter/php/tags) +> https://docker.shin.company/php/tags +[![Docker Pulls shinsenter/php](https://img.shields.io/docker/pulls/shinsenter/php)](https://docker.shin.company/php) --- +## Community + +As an open source project, we'd appreciate any help and contributions! + +[![Become a stargazer](https://img.shields.io/badge/Become-Stargazer-yellow)](https://code.shin.company/php/stargazers) [![Report an issue](https://img.shields.io/badge/New-Discussions-green)](https://code.shin.company/php/discussions/new) [![Join us on Gitter](https://badges.gitter.im/shinsenter/php.svg)](https://gitter.im/shinsenter/php?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Join us on Discord](https://img.shields.io/discord/962919929307357234?color=blueviolet)](https://discord.com/channels/962919929307357234/962920416559652924) + +We follow the standard [github pull request process](https://help.github.com/articles/about-pull-requests). It is appreciated when you [report an issue](https://code.shin.company/php/issues/new/choose) or event [start a discussion](https://code.shin.company/php/discussions/new). We'll try to review your contributions as soon as possible. + +Not ready to contribute code, but see something that needs work? From contributing to source code to improving readability of the documentation, all suggestions are welcome! + ## Support my activities -If you like this repository, please [hit the star button](https://github.com/shinsenter/php/stargazers) on my Github to follow further updates, or buy me a coffee πŸ˜‰. +If you like this repository, please [become a stargazer](https://code.shin.company/php/stargazers) on my Github or join Gitter to follow further updates. -[![Donate via PayPal](https://img.shields.io/badge/Donate-Paypal-blue)](https://www.paypal.me/shinsenter) [![Become a sponsor](https://img.shields.io/badge/Donate-Patreon-orange)](https://www.patreon.com/appseeds) [![Become a stargazer](https://img.shields.io/badge/Support-Stargazer-yellow)](https://github.com/shinsenter/php/stargazers) [![Report an issue](https://img.shields.io/badge/Support-Issues-green)](https://github.com/shinsenter/php/discussions/new) [![Join the chat at https://gitter.im/shinsenter/php](https://badges.gitter.im/shinsenter/php.svg)](https://gitter.im/shinsenter/php?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +I also love to have your help, please consider buying me a coffee, or sponsoring my works so I can create more helpful stuffs πŸ˜‰. + +[![Donate via PayPal](https://img.shields.io/badge/Donate-Paypal-blue)](https://www.paypal.me/shinsenter) [![Become a sponsor](https://img.shields.io/badge/Donate-Patreon-orange)](https://www.patreon.com/appseeds) I really appreciate your love and supports. +* * * ---- +Explore more Docker images at [docker.shin.company](https://docker.shin.company). -From Vietnam πŸ‡»πŸ‡³ with love. + \ No newline at end of file diff --git a/CONTRIBUTING.MD b/CONTRIBUTING.MD index 55c11aaa..0f774735 100644 --- a/CONTRIBUTING.MD +++ b/CONTRIBUTING.MD @@ -1,15 +1,13 @@ -# Contribution guide +# Contributions -Thanks for your interest in contributing to this project! -As stated in the README, there are a lot of dependencies on these images, so please understand that it can make it complicated on merging your pull request. -We'd love to have your help, but it might be best to explain your intentions first before contributing. +## Interested in contributing? -## Support my activities +As an open source project, we'd appreciate any help and contributions! -If you like this repository, please hit the star button to follow further updates, or buy me a coffee πŸ˜‰. +We follow the standard [github pull request process](https://help.github.com/articles/about-pull-requests). We'll try to review your contributions as soon as possible. -[![Donate via PayPal](https://img.shields.io/badge/Donate-Paypal-blue)](https://www.paypal.me/shinsenter) [![Become a sponsor](https://img.shields.io/badge/Donate-Patreon-orange)](https://www.patreon.com/appseeds) [![Become a stargazer](https://img.shields.io/badge/Support-Stargazer-yellow)](https://github.com/shinsenter/php/stargazers) [![Report an issue](https://img.shields.io/badge/Support-Issues-green)](https://github.com/shinsenter/php/discussions/new) [![Join the chat at https://gitter.im/shinsenter/php](https://badges.gitter.im/shinsenter/php.svg)](https://gitter.im/shinsenter/php?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +## File an Issue -I really appreciate your love and supports. +Not ready to contribute code, but see something that needs work? While we encourage everyone to contribute code, it is also appreciated when someone reports an issue. We use [github issues](https://github.com/shinsenter/php/issues) for this. -From Vietnam πŸ‡»πŸ‡³ with love. \ No newline at end of file +From contributing to source code to improving readability of the documentation, all suggestions are welcome! \ No newline at end of file diff --git a/LICENSE b/LICENSE index f288702d..e72bfdda 100644 --- a/LICENSE +++ b/LICENSE @@ -671,4 +671,4 @@ into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read -. +. \ No newline at end of file diff --git a/OS_VERSIONS b/OS_VERSIONS new file mode 100644 index 00000000..95b83673 --- /dev/null +++ b/OS_VERSIONS @@ -0,0 +1,2 @@ +22.04 +20.04 \ No newline at end of file diff --git a/PHP_VERSIONS b/PHP_VERSIONS new file mode 100644 index 00000000..1ed46c5b --- /dev/null +++ b/PHP_VERSIONS @@ -0,0 +1,4 @@ +7.3 +7.4 +8.0 +8.1 \ No newline at end of file diff --git a/README.md b/README.md index 150b9acb..9fc7e7fd 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,116 @@ # shinsenter/php -🧭 Production-ready Docker images for PHP, support PHP CLI and many types of PHP web applications. +πŸ“¦ (PHP) Production-ready Ubuntu + PHP-FPM + Nginx/Apache Docker images for your PHP applications. -https://hub.docker.com/r/shinsenter/php +> πŸ”— https://docker.shin.company/php -[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/php)](https://hub.docker.com/r/shinsenter/php) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/php/latest?label=shinsenter%2Fphp)](https://hub.docker.com/r/shinsenter/php/tags) [![Publish Images (shinsenter/php)](https://github.com/shinsenter/php/actions/workflows/publish-images.yml/badge.svg?branch=main)](https://github.com/shinsenter/php/actions/workflows/publish-images.yml) +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/php)](https://docker.shin.company/php) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/php/latest?label=shinsenter%2Fphp)](https://docker.shin.company/php/tags) [![Publish Images (shinsenter/php)](https://code.shin.company/php/actions/workflows/build-v2.yml/badge.svg?branch=main)](https://code.shin.company/php/actions/workflows/build-v2.yml) -[![shinsenter/php](https://repository-images.githubusercontent.com/458053748/656fbcf4-7b70-4d98-aa17-2b562dc270b2)](https://hub.docker.com/r/shinsenter/php) +[![shinsenter/php](https://repository-images.githubusercontent.com/458053748/24e848e1-c0fc-4893-b2b9-f7dbfad263f3)](https://docker.shin.company/php) * * * ## About this project -- Tired of waiting around for Docker images to build before you can start your website? -- Tired of customizing modules from official docker php images, or your docker image after installing more modules becomes too big? -- Tired of installing web sevrers like Apache or Nginx to run your PHP applications in the browser? +I have had those concerns when building environments for PHP applications. -Not only you, but I also had those concerns when building environments for PHP applications. These jobs are quite boring and time consuming. +- Tired of waiting around for Docker images to build. +- Tired of customizing modules from official Docker PHP images, and Docker image after installing more modules becomes too big. +- Tired of installing web server like Apache or Nginx on the top of PHP, in order to run a PHP application on browser. + +Above jobs are quite boring and time consuming, am I right? Therefore, based on my many years of experience, I created this project to help you quickly build an environment to run your PHP applications (regardless of whether it is a production or development environment). -Let's check it out!! +I hope you find this project helpful, please consider [supporting my works](https://code.shin.company/php/blob/main/SPONSOR.md) if you like it. + +> ### Special thanks +> +> This project is inspired by the [serversideup/docker-php](https://github.com/serversideup/docker-php) project, I love it. +> +> However the owners seem to be quite busy updating their projects, so I made my own version. + +Let's check it out! ## Container OS -This project is built on top of my Docker base image, which is Ubuntu 20.04 (Focal) with s6-overlay v3 and OpenSSL included. Learn more at: [shinsenter/s6-ubuntu](https://hub.docker.com/r/shinsenter/s6-ubuntu). +This project is built on top of my Docker base image, which is Ubuntu 22.04 (Jammy) with [s6-overlay v3](https://docker.shin.company/s6-overlay) and OpenSSL included. + +> Learn more: +> - [![`shinsenter/s6-overlay`](https://img.shields.io/docker/image-size/shinsenter/s6-overlay/latest?label=shinsenter%2Fs6-overlay)](https://docker.shin.company/s6-overlay) +> - [![`shinsenter/s6-ubuntu`](https://img.shields.io/docker/image-size/shinsenter/s6-ubuntu/latest?label=shinsenter%2Fs6-ubuntu)](https://docker.shin.company/s6-ubuntu) + +## Available images + +These images are actively maintained. + +### PHP versions + +- [![`shinsenter/php:7.3`](https://img.shields.io/docker/image-size/shinsenter/php/7.3?label=shinsenter%2Fphp%3A7.3)](https://docker.shin.company/php/tags?page=1&name=7.3) +- [![`shinsenter/php:7.4`](https://img.shields.io/docker/image-size/shinsenter/php/7.4?label=shinsenter%2Fphp%3A7.4)](https://docker.shin.company/php/tags?page=1&name=7.4) +- [![`shinsenter/php:8.0`](https://img.shields.io/docker/image-size/shinsenter/php/8.0?label=shinsenter%2Fphp%3A8.0)](https://docker.shin.company/php/tags?page=1&name=8.0) +- [![`shinsenter/php:8.1`](https://img.shields.io/docker/image-size/shinsenter/php/8.1?label=shinsenter%2Fphp%3A8.1)](https://docker.shin.company/php/tags?page=1&name=8.1) + +### PHP-CLI + +- [![`shinsenter/php:${PHP_VERSION}-cli`](https://img.shields.io/docker/image-size/shinsenter/php/cli?label=shinsenter%2Fphp%3Acli)](https://docker.shin.company/php/tags?page=1&name=cli) + +### PHP-FPM +- [![`shinsenter/php:${PHP_VERSION}-fpm`](https://img.shields.io/docker/image-size/shinsenter/php/fpm?label=shinsenter%2Fphp%3Afpm)](https://docker.shin.company/php/tags?page=1&name=fpm) + +### PHP-FPM + Apache +- [![`shinsenter/phpfpm-apache`](https://img.shields.io/docker/image-size/shinsenter/phpfpm-apache/latest?label=shinsenter%2Fphpfpm-apache)](https://docker.shin.company/phpfpm-apache) + +### PHP-FPM + Nginx +- [![`shinsenter/phpfpm-nginx`](https://img.shields.io/docker/image-size/shinsenter/phpfpm-nginx/latest?label=shinsenter%2Fphpfpm-nginx)](https://docker.shin.company/phpfpm-nginx) + +### Popular PHP open source projects + +I also added more popular PHP open source projects: + +- [![`shinsenter/cakephp4`](https://img.shields.io/docker/image-size/shinsenter/cakephp4/latest?label=shinsenter%2Fcakephp4)](https://docker.shin.company/cakephp4) +- [![`shinsenter/codeigniter4`](https://img.shields.io/docker/image-size/shinsenter/codeigniter4/latest?label=shinsenter%2Fcodeigniter4)](https://docker.shin.company/codeigniter4) +- [![`shinsenter/crater`](https://img.shields.io/docker/image-size/shinsenter/crater/latest?label=shinsenter%2Fcrater)](https://docker.shin.company/crater) +- [![`shinsenter/flarum`](https://img.shields.io/docker/image-size/shinsenter/flarum/latest?label=shinsenter%2Fflarum)](https://docker.shin.company/flarum) +- [![`shinsenter/fuelphp`](https://img.shields.io/docker/image-size/shinsenter/fuelphp/latest?label=shinsenter%2Ffuelphp)](https://docker.shin.company/fuelphp) +- [![`shinsenter/grav`](https://img.shields.io/docker/image-size/shinsenter/grav/latest?label=shinsenter%2Fgrav)](https://docker.shin.company/grav) +- [![`shinsenter/hyperf`](https://img.shields.io/docker/image-size/shinsenter/hyperf/latest?label=shinsenter%2Fhyperf)](https://docker.shin.company/hyperf) +- [![`shinsenter/kirby`](https://img.shields.io/docker/image-size/shinsenter/kirby/latest?label=shinsenter%2Fkirby)](https://docker.shin.company/kirby) +- [![`shinsenter/laminas`](https://img.shields.io/docker/image-size/shinsenter/laminas/latest?label=shinsenter%2Flaminas)](https://docker.shin.company/laminas) +- [![`shinsenter/laravel`](https://img.shields.io/docker/image-size/shinsenter/laravel/latest?label=shinsenter%2Flaravel)](https://docker.shin.company/laravel) +- [![`shinsenter/phpmyadmin`](https://img.shields.io/docker/image-size/shinsenter/phpmyadmin/latest?label=shinsenter%2Fphpmyadmin)](https://docker.shin.company/phpmyadmin) +- [![`shinsenter/symfony`](https://img.shields.io/docker/image-size/shinsenter/symfony/latest?label=shinsenter%2Fsymfony)](https://docker.shin.company/symfony) +- [![`shinsenter/slim`](https://img.shields.io/docker/image-size/shinsenter/slim/latest?label=shinsenter%2Fslim)](https://docker.shin.company/slim) +- [![`shinsenter/statamic`](https://img.shields.io/docker/image-size/shinsenter/statamic/latest?label=shinsenter%2Fstatamic)](https://docker.shin.company/statamic) +- [![`shinsenter/wordpress`](https://img.shields.io/docker/image-size/shinsenter/wordpress/latest?label=shinsenter%2Fwordpress)](https://docker.shin.company/wordpress) +- [![`shinsenter/yii`](https://img.shields.io/docker/image-size/shinsenter/yii/latest?label=shinsenter%2Fyii)](https://docker.shin.company/yii) + +## Pre-installed PHP modules + +``` +apcu json shmop +bcmath libxml simple_xml +calendar mbstring simplexml +core memcached soap +ctype msgpack sockets +curl mysqli sodium +date mysqlnd spl +dom opcache sqlite3 +exif openssl standard +ffi pcntl sysvmsg +fileinfo pcre sysvsem +filter pdo sysvshm +ftp pdo_mysql tidy +gd pdo_sqlite tokenizer +gettext phar xml +gmp posix xmlreader +hash readline xmlwriter +iconv redis xsl +igbinary reflection zip +intl session zlib +``` + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [install Ubuntu packages](#installing-linux-packages) by [customizing your Docker image](#customize-docker-image). ## Usage @@ -34,105 +120,102 @@ This project is built on top of my Docker base image, which is Ubuntu 20.04 (Foc docker pull shinsenter/php:${PHP_VERSION}-${PHP_VARIATION} ``` -### Docker Compose example +> View more image tags at [shinsenter/php/tags](https://docker.shin.company/php/tags). -```yml -version: '3' -services: - my-container: - image: shinsenter/php:${PHP_VERSION}-${PHP_VARIATION} +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. + +```Dockerfile +ENV WEBHOME="/var/www/html" ``` -View more image tags at [shinsenter/php/tags](https://hub.docker.com/r/shinsenter/php/tags). +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. + +> Sometimes you may wish to change the default document root (away from `/var/www/html`), please consider changing the `$WEBHOME` value. + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). -### Available PHP modules +### Access to your container +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash ``` -apcu -bcmath -calendar -ctype -curl -dom -exif -ffi -fileinfo -ftp -gd -gettext -gmp -iconv -igbinary -intl -mbstring -mysqli -mysqlnd -opcache -pdo -pdo_mysql -pdo_sqlite -phar -posix -readline -redis -shmop -simplexml -soap -sockets -sqlite3 -sysvmsg -sysvsem -sysvshm -tokenizer -xml -xmlreader -xmlwriter -xsl -zip + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod ``` -### Install more packages +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` -Just open a terminal within your container: +#### Removing PHP modules: ```bash -docker exec -it /bin/bash +docker exec -it phpdelmod ``` -Then type these command: +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: ```bash -apt-update && apt-install +docker exec -it composer ``` -## Available images +E.g.: `docker exec -it my-container composer install` + +### Installing linux packages -### PHP version +Access to your container by running `bash` inside the container: -- [`shinsenter/php:7.4`](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=7.4)
[![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/php/7.4?label=shinsenter%2Fphp%3A7.4)](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=7.4) -- [`shinsenter/php:8.0`](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=8.0)
[![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/php/8.0?label=shinsenter%2Fphp%3A8.0)](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=8.0) -- [`shinsenter/php:8.1`](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=8.1)
[![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/php/8.1?label=shinsenter%2Fphp%3A8.1)](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=8.1) +```bash +docker exec -it /bin/bash +``` -### Image variations +Run following Ubuntu's `apt` commands to install packages and any dependency needed. -- [`shinsenter/php:${PHP_VERSION}-cli`](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=cli)
[![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/php/cli?label=shinsenter%2Fphp%3Acli)](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=cli) -- [`shinsenter/php:${PHP_VERSION}-fpm`](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=fpm)
[![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/php/fpm?label=shinsenter%2Fphp%3Afpm)](https://hub.docker.com/r/shinsenter/php/tags?page=1&name=fpm) +```bash +apt-get update -y +apt-get install -y +``` -### Images for Web applications -- [`shinsenter/phpfpm-apache`](https://hub.docker.com/r/shinsenter/phpfpm-apache/tags)
[![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/phpfpm-apache/latest?label=shinsenter%2Fphpfpm-apache)](https://hub.docker.com/r/shinsenter/phpfpm-apache/tags) -- [`shinsenter/phpfpm-nginx`](https://hub.docker.com/r/shinsenter/phpfpm-nginx/tags)
[![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/phpfpm-nginx/latest?label=shinsenter%2Fphpfpm-nginx)](https://hub.docker.com/r/shinsenter/phpfpm-nginx/tags) +### Docker Run command -### Images for popular PHP projects +```bash +docker run --rm [run options] shinsenter/php:${PHP_VERSION}-${PHP_VARIATION} +``` -- [`shinsenter/wordpress`](https://hub.docker.com/r/shinsenter/wordpress/tags)
[![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/wordpress/latest?label=shinsenter%2Fwordpress)](https://hub.docker.com/r/shinsenter/wordpress/tags) -- [`shinsenter/phpmyadmin`](https://hub.docker.com/r/shinsenter/phpmyadmin/tags)
[![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/phpmyadmin/latest?label=shinsenter%2Fphpmyadmin)](https://hub.docker.com/r/shinsenter/phpmyadmin/tags) -- [`shinsenter/laravel`](https://hub.docker.com/r/shinsenter/laravel/tags)
[![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/laravel/latest?label=shinsenter%2Flaravel)](https://hub.docker.com/r/shinsenter/laravel/tags) -- [`shinsenter/codeigniter4`](https://hub.docker.com/r/shinsenter/codeigniter4/tags)
[![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/codeigniter4/latest?label=shinsenter%2Fcodeigniter4)](https://hub.docker.com/r/shinsenter/codeigniter4/tags) -- [`shinsenter/symfony`](https://hub.docker.com/r/shinsenter/symfony/tags)
[![Docker Image Size (tag)](https://img.shields.io/docker/image-size/shinsenter/symfony/latest?label=shinsenter%2Fsymfony)](https://hub.docker.com/r/shinsenter/symfony/tags) +For example: -## Customize your own image +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/php:8.1-cli composer create-project laravel/laravel my-app +``` -Dockerfile example for building your own Docker image extending one of those images. +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending one of above images. You also can change below pre-defined Docker's ENV lines to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). ```Dockerfile # change the PHP_VERSION and PHP_VARIATION as your need @@ -142,6 +225,14 @@ ARG PHP_VARIATION=fpm-nginx # extends from base image FROM shinsenter/php:${PHP_VERSION}-${PHP_VARIATION} +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== + # Control your timezone ENV TZ="UTC" @@ -152,18 +243,8 @@ ENV PGID=9999 # sets web server root path ENV WEBHOME="/var/www/html" -# sets the working directory -WORKDIR $WEBHOME - -# ========================================================== - -# you may want to install some PHP modules -# e.g: this block will install sorl and swoole modules -RUN apt-update \ - && apt-install \ - php${PHP_VERSION}-solr \ - php${PHP_VERSION}-swoole \ - && apt-cleanup +# set ENABLE_CRONTAB=true to enable crontab +ENV ENABLE_CRONTAB=false # ========================================================== @@ -189,7 +270,9 @@ ENV PHP_MAX_EXECUTION_TIME="99" ENV PHP_MEMORY_LIMIT="256M" # Limit the files that can be accessed by PHP to the specified directory-tree -ENV PHP_OPEN_BASEDIR="/var/www/html" +# Default: PHP_OPEN_BASEDIR="$WEBHOME" +# Example: PHP_OPEN_BASEDIR="$WEBHOME:/data/uploads" +ENV PHP_OPEN_BASEDIR="$WEBHOME" # Sets max size of post data allowed ENV PHP_POST_MAX_SIZE="100M" @@ -222,13 +305,16 @@ ENV PHP_PM_START_SERVERS="7" # ========================================================== # The amount of memory used to store interned strings, in megabytes. -ENV PHP_OPCACHE_INTERNED_STRINGS_BUFFER="8" +ENV PHP_OPCACHE_INTERNED_STRINGS_BUFFER="64" # The maximum number of keys (and therefore scripts) in the OPcache hash table -ENV PHP_OPCACHE_MAX_ACCELERATED_FILES="1048793" +ENV PHP_OPCACHE_MAX_ACCELERATED_FILES="130987" + +# The maximum percentage of wasted memory that is allowed before a restart is scheduled +ENV PHP_OPCACHE_MAX_WASTED_PERCENTAGE="15" # The size of the shared memory storage used by OPcache, in megabytes -ENV PHP_OPCACHE_MEMORY_CONSUMPTION="128" +ENV PHP_OPCACHE_MEMORY_CONSUMPTION="256" # This directive facilitates to let the preloading to be run as another user ENV PHP_OPCACHE_PRELOAD_USER="webuser" @@ -237,7 +323,7 @@ ENV PHP_OPCACHE_PRELOAD_USER="webuser" ENV PHP_OPCACHE_PRELOAD= # How often to check script timestamps for updates, in seconds -ENV PHP_OPCACHE_REVALIDATE_FREQ="2" +ENV PHP_OPCACHE_REVALIDATE_FREQ="5" # If disabled, existing cached files using the same include_path will be reused ENV PHP_OPCACHE_REVALIDATE_PATH="0" @@ -251,6 +337,57 @@ ENV PHP_OPCACHE_SAVE_COMMENTS="1" ENV PHP_OPCACHE_VALIDATE_TIMESTAMPS="1" ``` +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +```yml +version: '3' +services: + my-container: + image: shinsenter/php:${PHP_VERSION}-${PHP_VARIATION} + volumes: + - ./myapp:/var/www/html + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: my_database + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. + +```bash +docker-compose up -d +``` + ## Supported platforms Currently, the supported architectures are: @@ -260,10 +397,4 @@ Currently, the supported architectures are: - linux/arm64 - linux/ppc64le -You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. - -## Thank you [@serversideup](https://github.com/serversideup) - -This project is inspired by the [serversideup/docker-php](https://github.com/serversideup/docker-php) project, I love it. - -However the owners seem to be quite busy updating their projects, so I made my own version. \ No newline at end of file +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/S6_VERSION.txt b/S6_VERSION similarity index 100% rename from S6_VERSION.txt rename to S6_VERSION diff --git a/SECURITY.md b/SECURITY.md index db06c9b3..2908a516 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,6 +4,7 @@ The following versions of Ubuntu are being actively updated: +- 22.04 (Jammy) - 20.04 (Focal) ## Reporting a vulnerability diff --git a/SPONSOR.md b/SPONSOR.md index c54bd87b..72bb0b89 100644 --- a/SPONSOR.md +++ b/SPONSOR.md @@ -1,15 +1,27 @@ -* * * + + +## Community + +As an open source project, we'd appreciate any help and contributions! + +[![Become a stargazer](https://img.shields.io/badge/Become-Stargazer-yellow)](https://code.shin.company/php/stargazers) [![Report an issue](https://img.shields.io/badge/New-Discussions-green)](https://code.shin.company/php/discussions/new) [![Join us on Gitter](https://badges.gitter.im/shinsenter/php.svg)](https://gitter.im/shinsenter/php?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Join us on Discord](https://img.shields.io/discord/962919929307357234?color=blueviolet)](https://discord.com/channels/962919929307357234/962920416559652924) + +We follow the standard [github pull request process](https://help.github.com/articles/about-pull-requests). It is appreciated when you [report an issue](https://code.shin.company/php/issues/new/choose) or event [start a discussion](https://code.shin.company/php/discussions/new). We'll try to review your contributions as soon as possible. + +Not ready to contribute code, but see something that needs work? From contributing to source code to improving readability of the documentation, all suggestions are welcome! ## Support my activities -If you like this repository, please [hit the star button](https://github.com/shinsenter/php/stargazers) on my Github to follow further updates, or buy me a coffee πŸ˜‰. +If you like this repository, please [become a stargazer](https://code.shin.company/php/stargazers) on my Github or join Gitter to follow further updates. + +I also love to have your help, please consider buying me a coffee, or sponsoring my works so I can create more helpful stuffs πŸ˜‰. -[![Donate via PayPal](https://img.shields.io/badge/Donate-Paypal-blue)](https://www.paypal.me/shinsenter) [![Become a sponsor](https://img.shields.io/badge/Donate-Patreon-orange)](https://www.patreon.com/appseeds) [![Become a stargazer](https://img.shields.io/badge/Support-Stargazer-yellow)](https://github.com/shinsenter/php/stargazers) [![Report an issue](https://img.shields.io/badge/Support-Issues-green)](https://github.com/shinsenter/php/discussions/new) [![Join the chat at https://gitter.im/shinsenter/php](https://badges.gitter.im/shinsenter/php.svg)](https://gitter.im/shinsenter/php?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Donate via PayPal](https://img.shields.io/badge/Donate-Paypal-blue)](https://www.paypal.me/shinsenter) [![Become a sponsor](https://img.shields.io/badge/Donate-Patreon-orange)](https://www.patreon.com/appseeds) I really appreciate your love and supports. * * * -Explore more Docker images at [hub.docker.com/u/shinsenter](https://hub.docker.com/u/shinsenter). +Explore more Docker images at [docker.shin.company](https://docker.shin.company). -From Vietnam πŸ‡»πŸ‡³ with love. \ No newline at end of file + \ No newline at end of file diff --git a/_config.yml b/_config.yml new file mode 100644 index 00000000..3397c9a4 --- /dev/null +++ b/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-architect \ No newline at end of file diff --git a/checksum.sh b/checksum.sh deleted file mode 100755 index 36777684..00000000 --- a/checksum.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - -BASE_DIR="$(git rev-parse --show-toplevel)" -HASH_DIR="$BASE_DIR/versions" - -curlhash () { - local output - local url - - output=${HASH_DIR}/${1:-checksums.txt} - url=$2 - - echo "$(curl -sL "$url" | shasum | cut -c1-40) - $url" >$output -} - -treehash() { - local output - local location - - output=${HASH_DIR}/${1:-checksums.txt};shift - location=$@ - - rm -f $output && touch $output - for path in $location; do - if [ -f ${HASH_DIR}/$path ]; then - cat ${HASH_DIR}/$path >>$output - else - echo "$(git rev-parse HEAD:$path 2>/dev/null| cut -c1-40) - $path" >>$output - fi - done -} - -mkdir -p $HASH_DIR - -curlhash .dep-ondrej-php.txt 'http://ppa.launchpad.net/ondrej/php/ubuntu/dists/?C=M;O=D' -curlhash .dep-ondrej-apache.txt 'http://ppa.launchpadcontent.net/ondrej/apache2/ubuntu/dists/?C=M;O=D' -curlhash .dep-ondrej-nginx.txt 'http://ppa.launchpadcontent.net/ondrej/nginx-mainline/ubuntu/dists/?C=M;O=D' - -treehash base.txt S6_VERSION.txt src/base-ubuntu/ -treehash cli.txt base.txt .dep-ondrej-php.txt src/php/cli/ -treehash fpm.txt cli.txt src/php/fpm/ -treehash servers.txt fpm.txt .dep-ondrej-apache.txt .dep-ondrej-nginx.txt src/servers/ -treehash webapps.txt servers.txt src/webapps/ diff --git a/src/.dockerignore b/src/.dockerignore new file mode 100644 index 00000000..6b0cff9e --- /dev/null +++ b/src/.dockerignore @@ -0,0 +1,7 @@ +.checksum +.dockerignore +.source +docker-compose.yml +Dockerfile +Dockerfile.tidy +README.md \ No newline at end of file diff --git a/src/Metafile b/src/Metafile index 716e5365..83dc4508 100644 --- a/src/Metafile +++ b/src/Metafile @@ -1,21 +1,24 @@ +# Metafile +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE ################################################################################ +ARG BUILD_CONTEXT ARG BUILD_DATE ARG BUILD_DESC ARG BUILD_NAME -ARG BUILD_VERSION -ARG VCS_REF +ARG BUILD_REVISION +ENV IMAGE_NAME="$BUILD_NAME" -LABEL org.label-schema.schema-version="1.0" -LABEL org.label-schema.name="$BUILD_NAME" -LABEL org.label-schema.build-date="$BUILD_DATE" -LABEL org.label-schema.version="$BUILD_VERSION" -LABEL org.label-schema.description="$BUILD_DESC" -LABEL org.label-schema.vcs-ref="$VCS_REF" -LABEL org.label-schema.url="https://hub.docker.com/r/$BUILD_NAME" -LABEL org.label-schema.vcs-url="https://github.com/shinsenter/php" -LABEL org.label-schema.vendor="SHIN Company" -LABEL maintainer="shin@shin.company" -LABEL publisher="https://hub.docker.com/u/shinsenter" +LABEL org.opencontainers.image.authors="shin@shin.company" +LABEL org.opencontainers.image.created="$BUILD_DATE" +LABEL org.opencontainers.image.description="$BUILD_DESC" +LABEL org.opencontainers.image.documentation="https://hub.docker.com/r/${BUILD_NAME}" +LABEL org.opencontainers.image.licenses="GPL-3.0" +LABEL org.opencontainers.image.revision="$BUILD_REVISION" +LABEL org.opencontainers.image.source="https://code.shin.company/php/blob/main/${BUILD_CONTEXT}/Dockerfile" +LABEL org.opencontainers.image.title="$BUILD_NAME" +LABEL org.opencontainers.image.url="https://hub.docker.com/r/${BUILD_NAME}/tags" ################################################################################ \ No newline at end of file diff --git a/src/base-s6/Dockerfile b/src/base-s6/Dockerfile index c326b857..9fc4acba 100644 --- a/src/base-s6/Dockerfile +++ b/src/base-s6/Dockerfile @@ -1,55 +1,63 @@ -# This file is the work of https://github.com/shinsenter/php +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE ################################################################################ -ARG BASE_IMAGE=ubuntu:latest +ARG BASE_OS_IMAGE=ubuntu:latest +ARG SCRATCH_IMAGE=shinsenter/scratch ################################################################################ -# prepares base image -FROM ${BASE_IMAGE} as build +# override scratch image +FROM ${SCRATCH_IMAGE} as scratch + +################################################################################ + +# base image +FROM ${BASE_OS_IMAGE} as build + +# changes the behavior of apt-get +ARG DEBIAN_FRONTEND=noninteractive # sets version for s6 overlay -ARG S6_DIR=/usr/src/s6/ +ARG S6_DIR=/opt/s6/ ARG S6_SRC_DEP="xz-utils wget" ARG S6_SRC_URL="https://github.com/just-containers/s6-overlay/releases/download" ARG S6_VERSION -# disable frontend -ENV DEBIAN_FRONTEND=noninteractive -ENV TERM=xterm - # checks build argument RUN if [ -z "$S6_VERSION" ]; then \ echo "Please set S6_VERSION build argument."; exit 1; \ fi # adds build dependencies -RUN apt-get update -y -RUN apt-get install -y $S6_SRC_DEP --no-install-recommends --no-install-suggests +RUN mkdir -p $S6_DIR +RUN apt-get update -yqq +RUN apt-get install -yq $S6_SRC_DEP --no-install-recommends --no-install-suggests # detect system arch then select the right version of s6 RUN export SYS_ARCH=$(uname -m); \ case "$SYS_ARCH" in \ aarch64 ) export S6_ARCH='aarch64' ;; \ - arm ) export S6_ARCH='arm' ;; \ - arm* ) export S6_ARCH='armhf' ;; \ - i4+ ) export S6_ARCH='i486' ;; \ - i6+ ) export S6_ARCH='i686' ;; \ + arm64 ) export S6_ARCH='aarch64' ;; \ + armhf ) export S6_ARCH='armhf' ;; \ + arm* ) export S6_ARCH='arm' ;; \ + i4* ) export S6_ARCH='i486' ;; \ + i6* ) export S6_ARCH='i686' ;; \ riscv64 ) export S6_ARCH='riscv64' ;; \ s390* ) export S6_ARCH='s390x' ;; \ * ) export S6_ARCH='x86_64' ;; \ esac; \ - \ - # adds s6 overlay - echo "⬇️ Downloading s6 overlay:${S6_ARCH}-${S6_VERSION} for ${SYS_ARCH}..." \ - && mkdir -p $S6_DIR \ - && untar (){ \ + untar (){ \ echo " ⏬ Downloading $1"; \ - wget --no-check-certificate -O- $1 | tar Jxp -C ${2:-"$S6_DIR"}; \ - } \ - && untar ${S6_SRC_URL}/${S6_VERSION}/s6-overlay-noarch.tar.xz \ - && untar ${S6_SRC_URL}/${S6_VERSION}/s6-overlay-${S6_ARCH}.tar.xz \ - && du -sh $S6_DIR + wget --no-check-certificate -O- $1 | tar Jxp -C "${2:-$S6_DIR}"; \ + }; \ + \ + echo "⬇️ Downloading s6 overlay:${S6_ARCH}-${S6_VERSION} for ${SYS_ARCH}" \ + && untar ${S6_SRC_URL}/${S6_VERSION}/s6-overlay-noarch.tar.xz \ + && untar ${S6_SRC_URL}/${S6_VERSION}/s6-overlay-${S6_ARCH}.tar.xz \ + && untar ${S6_SRC_URL}/${S6_VERSION}/syslogd-overlay-noarch.tar.xz \ + && du -sh $S6_DIR ################################################################################ @@ -57,7 +65,6 @@ RUN export SYS_ARCH=$(uname -m); \ FROM scratch # copies from from build stage -COPY --from=build /usr/src/s6/ / -ENTRYPOINT ["/init"] +COPY --from=build /opt/s6/ / ################################################################################ \ No newline at end of file diff --git a/src/base-s6/README.md b/src/base-s6/README.md index 9d1d2e36..6a5ec8f7 100644 --- a/src/base-s6/README.md +++ b/src/base-s6/README.md @@ -1,43 +1,61 @@ # shinsenter/s6-overlay -The images in this repository contain only the unpacked s6-overlay as a multi-platform build stage. +πŸ—‚ The images in this repository contain unpacked s6-overlay v3 as a multi-platform build stage. -https://hub.docker.com/r/shinsenter/s6-overlay +> πŸ”— https://docker.shin.company/s6-overlay -[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/s6-overlay)](https://hub.docker.com/r/shinsenter/s6-overlay) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/s6-overlay/latest?label=shinsenter%2Fs6-overlay)](https://hub.docker.com/r/shinsenter/s6-overlay/tags) +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/s6-overlay)](https://docker.shin.company/s6-overlay) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/s6-overlay/latest?label=shinsenter%2Fs6-overlay)](https://docker.shin.company/s6-overlay) * * * ## About this project -The images in this repository contain only the unpacked [s6-overlay](https://github.com/just-containers/s6-overlay) as a multi-platform and reusable build stage. +The images in this repository contain only unpacked [s6-overlay v3](https://github.com/just-containers/s6-overlay) as a multi-platform and reusable build stage. The s6-overlay was built specifically for the lifecycle of containers, giving you a more accurate way of bringing containers down and monitoring their health. +These images are actively maintained. + ## Usage This repository is not intended to be used directly, but rather consumed in other Dockerfiles as a multi-platform and reusable build stage. ```Dockerfile -FROM ubuntu +FROM ubuntu:latest # adds file from the shinsenter/s6-overlay image COPY --from=shinsenter/s6-overlay / / + +# important: sets s6-overlay entrypoint ENTRYPOINT ["/init"] # runs other commands RUN ... ``` +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## My other projects + +Most of my [other docker projects](https://docker.shin.company) are built on top of Ubuntu 22.04 (Jammy) with s6-overlay v3 using my Ubuntu docker base images: + +> πŸ”— https://docker.shin.company/s6-ubuntu + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/s6-ubuntu)](https://docker.shin.company/s6-ubuntu) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/s6-ubuntu/latest?label=shinsenter%2Fs6-ubuntu)](https://docker.shin.company/s6-ubuntu) + ## Supported platforms This repository uses multi-platform images via Docker manifests. Currently, the supported architectures are: - linux/amd64 - linux/arm/v7 -- linux/arm64 +- linux/arm64/v8 - linux/ppc64le - linux/riscv64 - linux/s390x -You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/base-ubuntu/Dockerfile b/src/base-ubuntu/Dockerfile index 5e296b90..a686e26b 100644 --- a/src/base-ubuntu/Dockerfile +++ b/src/base-ubuntu/Dockerfile @@ -1,84 +1,100 @@ -# This file is the work of https://github.com/shinsenter/php +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE ################################################################################ -ARG BASE_IMAGE=ubuntu:latest -ARG S6_BASE_IMAGE=shinsenter/s6-overlay +ARG SCRATCH_IMAGE=shinsenter/scratch +ARG BASE_S6_IMAGE=shinsenter/s6-overlay +ARG BASE_OS_IMAGE=ubuntu:latest ARG S6_VERSION=latest ################################################################################ -FROM ${S6_BASE_IMAGE}:latest as source +# override scratch image +FROM ${SCRATCH_IMAGE} as scratch ################################################################################ -# prepares base image -FROM ${BASE_IMAGE} as base +# s6 source image +FROM ${BASE_S6_IMAGE}:${S6_VERSION} as s6 -# disable frontend -ENV DEBIAN_FRONTEND=noninteractive -ENV TERM=xterm +################################################################################ + +# base image +FROM ${BASE_OS_IMAGE} as base + +# sets defaults +ARG PUID=9999 +ARG PGID=9999 +ARG DEBIAN_FRONTEND=noninteractive +ARG BUILD_DEPS="apt-utils" + +################################################################################ # adds binaries ADD root/ / -# updates packages -RUN echo "πŸ€– Updating packages..." -RUN apt-update -RUN apt-install ca-certificates - -# sets GID and UID -ENV PUID=9999 -ENV PGID=9999 -ENV WEBHOME="/var/www/html" +# copies s6-overlay from source +COPY --from=s6 / / # adds user and group -RUN echo "πŸ€– Creating webuser and webgroup..." +RUN echo "πŸ€– Creating webuser and webgroup" RUN groupadd -r -g $PGID webgroup -RUN useradd -r -g $PGID -u $PUID -d $WEBHOME -s /usr/bin/bash --no-log-init webuser +RUN useradd -r -g $PGID -G root,www-data --no-log-init \ + -d /root -s /usr/bin/bash -u $PUID webuser +RUN wmd /root -R -# cleanup -RUN apt-cleanup +# updates packages +RUN echo "πŸ€– Updating packages" +RUN apt-update +RUN apt-install $BUILD_DEPS ca-certificates cron openssl +RUN disable cron +RUN ln -sf /etc/ssl/certs/ca-certificates.crt /usr/lib/ssl/cert.pem +RUN apt-upgrade -uq +RUN cleanup $BUILD_DEPS ################################################################################ # the main image -FROM scratch +FROM scratch +SHELL ["/bin/bash", "-c"] # copies from from build stage COPY --from=base / / -# copies s6-overlay from source -COPY --from=source / / -ENTRYPOINT ["/init"] +# sets the working directory +# WORKDIR /root -################################################################################ +# sets default command +CMD ["/bin/bash"] -# sets GID and UID -ENV PUID=9999 -ENV PGID=9999 -ENV WEBHOME="/var/www/html" - -# adds OS variables -ENV DEBIAN_FRONTEND=noninteractive -ENV LANG=C.UTF-8 -ENV LANGUAGE=C.UTF-8 -ENV LC_ALL=C -ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -ENV TERM=xterm +################################################################################ # S6 variables ARG S6_VERSION -ENV S6_VERSION=$S6_VERSION ENV S6_BEHAVIOUR_IF_STAGE2_FAILS=2 ENV S6_CMD_WAIT_FOR_SERVICES_MAXTIME=600000 -ENV S6_GLOBAL_PATH=/command:$PATH +ENV S6_KEEP_ENV=1 ENV S6_KILL_FINISH_MAXTIME=3000 ENV S6_KILL_GRACETIME=3000 +ENV S6_LOGGING=1 ENV S6_SERVICES_GRACETIME=3000 +ENV S6_VERSION=$S6_VERSION -################################################################################ +# sets GID and UID +ENV PGID=9999 +ENV PUID=9999 +ENV WEBHOME="/var/www/html" -LABEL category="os" -LABEL category="base" +# adds OS variables +ENV DEBUG_MODE=false +ENV ENABLE_CRONTAB=false +ENV HOME=/root +ENV LANG=C.UTF-8 +ENV LANGUAGE=C.UTF-8 +ENV LC_ALL=C +ENV PATH=/command:/bin:/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin:/usr/sbin +ENV SHELL=/bin/bash +ENV TERM=xterm ################################################################################ \ No newline at end of file diff --git a/src/base-ubuntu/README.md b/src/base-ubuntu/README.md index 55c57c75..ce703175 100644 --- a/src/base-ubuntu/README.md +++ b/src/base-ubuntu/README.md @@ -1,45 +1,77 @@ # shinsenter/s6-ubuntu -Ubuntu 20.04 (Focal) Docker base image with s6-overlay v3 and OpenSSL included. +πŸ“¦ Ubuntu + OpenSSL + s6-overlay v3 Docker base images. -https://hub.docker.com/r/shinsenter/s6-ubuntu +> πŸ”— https://docker.shin.company/s6-ubuntu -[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/s6-ubuntu)](https://hub.docker.com/r/shinsenter/s6-ubuntu) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/s6-ubuntu/latest?label=shinsenter%2Fs6-ubuntu)](https://hub.docker.com/r/shinsenter/s6-ubuntu/tags) +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/s6-ubuntu)](https://docker.shin.company/s6-ubuntu) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/s6-ubuntu/latest?label=shinsenter%2Fs6-ubuntu)](https://docker.shin.company/s6-ubuntu) * * * ## About this project -Ubuntu 20.04 (Focal) Docker base image with [s6-overlay v3](https://github.com/just-containers/s6-overlay/tree/v3) and [OpenSSL](https://github.com/openssl/openssl) included. +Latest stable [Ubuntu](https://ubuntu.com) docker base images with [s6-overlay v3](https://github.com/just-containers/s6-overlay/tree/v3) and [OpenSSL](https://github.com/openssl/openssl) included. -The [s6-overlay](https://github.com/just-containers/s6-overlay) was built specifically for the lifecycle of containers, giving you a more accurate way of bringing containers down and monitoring their health. +> The [s6-overlay](https://github.com/just-containers/s6-overlay) was built specifically for the lifecycle of containers, giving you a more accurate way of bringing containers down and monitoring their health. See a great explanation called ["The Docker Way?"](https://github.com/just-containers/s6-overlay#the-docker-way) by the s6-overlay team for an excellent explaination. -See a great explanation called ["The Docker Way?"](https://github.com/just-containers/s6-overlay#the-docker-way) by the s6-overlay team for an excellent explaination. +These images are actively maintained. + +## Container OS + +The following versions of Ubuntu are being actively updated: + +- [22.04](https://docker.shin.company/s6-ubuntu/tags?name=22.04) ([Jammy](https://docker.shin.company/s6-ubuntu/tags?name=jammy), [latest](https://docker.shin.company/s6-ubuntu/tags?name=latest)) +- [20.04](https://docker.shin.company/s6-ubuntu/tags?name=20.04) ([Focal](https://docker.shin.company/s6-ubuntu/tags?name=focal)) ## Usage ### Docker Pull command ```bash -docker pull shinsenter/s6-ubuntu +docker pull shinsenter/s6-ubuntu:latest ``` -### Docker Compose example +or -```yml -version: '3' -services: - my-container: - image: shinsenter/s6-ubuntu:latest - environment: - TZ: UTC +```bash +docker pull shinsenter/s6-ubuntu:jammy +``` + +or + +```bash +docker pull shinsenter/s6-ubuntu:22.04 +``` + +> View more image tags at [shinsenter/s6-ubuntu/tags](https://docker.shin.company/s6-ubuntu/tags). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/s6-ubuntu ``` -View more image tags at [shinsenter/s6-ubuntu/tags](https://hub.docker.com/r/shinsenter/s6-ubuntu/tags). +For example: -## Customize your own image +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/s6-ubuntu env +``` + +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. -Dockerfile example for building your own Docker image extending this image. +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). + +You can easily change container configurations by using pre-defined Docker's environment variables. ```Dockerfile FROM shinsenter/s6-ubuntu @@ -52,8 +84,37 @@ ENV PUID=9999 ENV PGID=9999 ENV WEBHOME="/var/www/html" -# sets the working directory -WORKDIR $WEBHOME +# set ENABLE_CRONTAB=true to enable crontab +ENV ENABLE_CRONTAB=false +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +```yml +version: '3' +services: + my-container: + image: shinsenter/s6-ubuntu:latest + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} +``` + +Then run below command to start containers. + +```bash +docker-compose up -d ``` ## Supported platforms @@ -62,9 +123,9 @@ Currently, the supported architectures are: - linux/amd64 - linux/arm/v7 -- linux/arm64 +- linux/arm64/v8 - linux/ppc64le - linux/riscv64 - linux/s390x -You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/base-ubuntu/root/etc/cont-init.d/000-update-webuser b/src/base-ubuntu/root/etc/cont-init.d/000-update-webuser index 5e291e46..a373151a 100755 --- a/src/base-ubuntu/root/etc/cont-init.d/000-update-webuser +++ b/src/base-ubuntu/root/etc/cont-init.d/000-update-webuser @@ -1,19 +1,24 @@ #!/command/with-contenv bash - PUID="${PUID:-9999}" PGID="${PGID:-9999}" TZ="${TZ:-UTC}" -WEBHOME="${WEBHOME:-/var/www/html}" +WEBHOME="$(webhome)" + +[ ! -z "$WEBHOME" ] && wmd $WEBHOME if [ ! -z "$TZ" ] && [ -e /usr/share/zoneinfo/$TZ ]; then ln -sf /usr/share/zoneinfo/$TZ /etc/localtime fi -if [[ $PUID != 9999 || $PGID != 9999 ]]; then +if [[ "$PUID" != "9999" || "$PGID" != "9999" ]]; then + echo "πŸ”₯ New PUID and PGID for $WEBHOME will be updated. πŸ”₯" /usr/sbin/groupmod -o -g $PGID webgroup /usr/sbin/usermod -o -u $PUID webuser + touch /tmp/owner-changed fi -if [ ! -z "$WEBHOME" ]; then - webuser-mkdir $WEBHOME +if [ -d /source/ ]; then + echo " πŸ—‚ Source folder detected. Moving files to $WEBHOME..." + move -bf /source/* $WEBHOME/ && rm -rf /source/ || true + touch /tmp/owner-changed fi \ No newline at end of file diff --git a/src/base-ubuntu/root/etc/cont-init.d/999-fix-permission b/src/base-ubuntu/root/etc/cont-init.d/999-fix-permission index 08772d02..1f6571b5 100755 --- a/src/base-ubuntu/root/etc/cont-init.d/999-fix-permission +++ b/src/base-ubuntu/root/etc/cont-init.d/999-fix-permission @@ -1,31 +1,42 @@ #!/command/with-contenv bash +COPY=/welcome.txt +LICENSE=/license.txt +EMAIL="${MAINTAINER:-shin@shin.company}" +NAME="${IMAGE_NAME:-shinsenter/s6-ubuntu}" +WEBHOME="$(webhome)" -WEBHOME="${WEBHOME:-/var/www/html}" +echo " -if [ "$FIX_WEBHOME_PERMISSION" == "true" ] || [ -e /tmp/cleanup ]; then - if [ ! -z "$WEBHOME" ]; then - echo - echo "πŸ—‚ Fixing permission for ${WEBHOME}..." - webuser-mkdir $WEBHOME recursive - fi - rm -f /tmp/cleanup -fi +$([ -f $COPY ] && cat $COPY | sed -u "s#%PATH%#$COPY#g") -if [ -f /welcome.txt ]; then - echo - cat /welcome.txt -fi +---------------------------------------- + Container : $NAME + Distro : $(bash -c '. /etc/os-release;echo ${PRETTY_NAME:-Unknown}') + Timezone : $(date +'%Z') (GMT$(date +'%z')) + UID / GID : $(id -u webuser) / $(id -g webuser) + Web Root : $WEBHOME +---------------------------------------- -echo " +$([ -f $LICENSE ] && cat $LICENSE | sed -u "s#%EMAIL%#$EMAIL#g") ------------------------------- - Timezone: $(date +'%Z %z') - User UID: $(id -u webuser) - User GID: $(id -g webuser) - Web Root: $WEBHOME ------------------------------- +" -To get support from the project owner, please contact: - admin@appseeds.net +if [ "$FIX_WEBHOME_PERMISSION" == "true" ] || [ -e /tmp/owner-changed ]; then + rm -f /tmp/owner-changed + if [ ! -z "$WEBHOME" ]; then + echo "πŸ—‚ Fixing permission for ${WEBHOME}" + wmd /root -R 2>/dev/null & + wmd $WEBHOME -R 2>/dev/null & + fi +fi -" \ No newline at end of file +if [ -d /startup ]; then + echo "πŸ—‚ Looking for startup scripts" + for script in /startup/* ; do + if [ -x $script ]; then + echo " πŸ“œ Started $script in the background." + bash -c "sleep 0.5; . $script | sed -u 's@^@${script}: @g'" & + fi + done + echo +fi \ No newline at end of file diff --git a/src/base-ubuntu/root/etc/services.d/900-crontab/run b/src/base-ubuntu/root/etc/services.d/900-crontab/run new file mode 100755 index 00000000..b223e9c3 --- /dev/null +++ b/src/base-ubuntu/root/etc/services.d/900-crontab/run @@ -0,0 +1,12 @@ +#!/command/with-contenv bash +if [ "$ENABLE_CRONTAB" == "true" ]; then + if [ -d /etc/cron.d ]; then + chown -R root:root /etc/cron.d + find /etc/cron.d -type f | xargs -I {} chmod 0644 {} + bash -c 'sleep 5;find /etc/cron.d -type f 2>/dev/null | xargs -I {} touch {} 2>/dev/null' & + fi + echo "βš™οΈ Starting crontab..." + MAILTO="" exec cron -flnL15 +else + exec s6-svc -Od . +fi \ No newline at end of file diff --git a/src/base-ubuntu/root/license.txt b/src/base-ubuntu/root/license.txt new file mode 100644 index 00000000..9e3d1cd0 --- /dev/null +++ b/src/base-ubuntu/root/license.txt @@ -0,0 +1,6 @@ +Docker Container Copyright (C) 2022 %EMAIL% +This program comes with ABSOLUTELY NO WARRANTY. +This is free software, and you are welcome +to redistribute it under certain conditions. + +To get support, please contact: %EMAIL% \ No newline at end of file diff --git a/src/base-ubuntu/root/root/.bashrc b/src/base-ubuntu/root/root/.bashrc index de47987b..2fb527b2 100644 --- a/src/base-ubuntu/root/root/.bashrc +++ b/src/base-ubuntu/root/root/.bashrc @@ -1,4 +1,4 @@ -# If not running interactively, don't do anything +# if not running interactively, don't do anything [ -z "$PS1" ] && return HISTCONTROL=ignoredups:ignorespace @@ -18,14 +18,14 @@ fi # set a fancy prompt (non-color, unless we know we "want" color) case "$TERM" in - xterm-color) color_prompt=yes;; + xterm-color) color_prompt=yes ;; esac if [ -n "$force_color_prompt" ]; then if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then - color_prompt=yes + color_prompt=yes else - color_prompt= + color_prompt= fi fi @@ -36,13 +36,10 @@ else fi unset color_prompt force_color_prompt -# If this is an xterm set the title to user@host:dir +# if this is an xterm set the title to user@host:dir case "$TERM" in -xterm*|rxvt*) - PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" - ;; -*) - ;; + xterm* | rxvt*) PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" ;; + *) ;; esac # enable color support of ls and also add handy aliases @@ -57,15 +54,21 @@ if [ -x /usr/bin/dircolors ]; then fi # some more ls aliases -alias ll='ls -alF' -alias la='ls -A' +alias clean='/usr/bin/cleanup' +alias home='cd "$(webhome)"' alias l='ls -CF' +alias la='ls -A' +alias ll='ls -alF' -# Alias definitions. +# alias definitions if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi if [ -f /etc/bash_completion ] && ! shopt -oq posix; then - . /etc/bash_completion + . /etc/bash_completion fi + +WEBHOME="$(webhome)" +[ ! -z "$WEBHOME" ] && wmd $WEBHOME +cd $WEBHOME \ No newline at end of file diff --git a/src/base-ubuntu/root/root/.profile b/src/base-ubuntu/root/root/.profile index b5c14cc4..7e74b3d0 100644 --- a/src/base-ubuntu/root/root/.profile +++ b/src/base-ubuntu/root/root/.profile @@ -3,5 +3,4 @@ if [ "$BASH" ]; then . ~/.bashrc fi fi - mesg n 2> /dev/null || true \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/add-ppa b/src/base-ubuntu/root/usr/bin/add-ppa deleted file mode 100755 index 11663064..00000000 --- a/src/base-ubuntu/root/usr/bin/add-ppa +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -SOURCE="$1" -TARGET="$2" -PUBKEY="$3" - -if [ ! -z "$SOURCE" ] && [ ! -z "$TARGET" ]; then - OS_VER=$(bash -c '. /etc/os-release 2>/dev/null;echo $VERSION_CODENAME') - echo "deb $SOURCE $OS_VER main" >$TARGET - - if [ ! -z "$PUBKEY" ]; then - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys "$PUBKEY" 2>/dev/null - fi -fi \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/apt-cleanup b/src/base-ubuntu/root/usr/bin/apt-cleanup index 7aa34068..81e877d4 100755 --- a/src/base-ubuntu/root/usr/bin/apt-cleanup +++ b/src/base-ubuntu/root/usr/bin/apt-cleanup @@ -1,10 +1,5 @@ #!/bin/bash -apt-get purge -y --auto-remove $@ 2>/dev/null -apt-get -y clean 2>/dev/null - -find /var/cache -type f -name '*-old' -delete 2>/dev/null -find /var/log -type f | xargs -I {} bash -c '>{}' 2>/dev/null -rm -rf /etc/*- \ - /var/lib/apt/lists/* \ - /usr/share/doc/* \ - /tmp/* /var/tmp/* \ No newline at end of file +export DEBIAN_FRONTEND=noninteractive +apt-get -yq autoremove --purge "$@" 2>/dev/null +apt-get -yq clean 2>/dev/null +rm -rf /var/lib/apt/lists/* /root/.gnupg 2>/dev/null \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/apt-deb b/src/base-ubuntu/root/usr/bin/apt-deb new file mode 100755 index 00000000..4b9b6c0b --- /dev/null +++ b/src/base-ubuntu/root/usr/bin/apt-deb @@ -0,0 +1,12 @@ +#!/bin/bash +DEBNAME="$1" +LISTURL="$2" +if [ ! -z "$LISTURL" ] && [ ! -z "$DEBNAME" ]; then + GPGKEY="$3" ; [ ! -z "$GPGKEY" ] && gnu-key $GPGKEY $GPGKEY + OUTKEY="/usr/share/keyrings/${GPGKEY}.gpg" + [ -f "$OUTKEY" ] && LISTURL="[signed-by=$OUTKEY] $LISTURL" + SOURCE="deb $LISTURL $(bash -c '. /etc/os-release;echo $VERSION_CODENAME') main" + echo -e "\n πŸ“¦ Added: $SOURCE" + echo $SOURCE >"/etc/apt/sources.list.d/${DEBNAME}.list" + exec apt-update +fi \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/apt-install b/src/base-ubuntu/root/usr/bin/apt-install index 044b31c9..630a2c50 100755 --- a/src/base-ubuntu/root/usr/bin/apt-install +++ b/src/base-ubuntu/root/usr/bin/apt-install @@ -1,5 +1,3 @@ #!/bin/bash -apt-get install $@ -y \ ---no-install-recommends \ ---no-install-suggests \ ---auto-remove \ No newline at end of file +export DEBIAN_FRONTEND=noninteractive +exec apt-get install -y --no-install-recommends --no-install-suggests "$@" \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/apt-oneshot b/src/base-ubuntu/root/usr/bin/apt-oneshot new file mode 100755 index 00000000..f096b0d2 --- /dev/null +++ b/src/base-ubuntu/root/usr/bin/apt-oneshot @@ -0,0 +1,4 @@ +#!/bin/bash +export DEBIAN_FRONTEND=noninteractive +apt-update && apt-install -qum "$@" +apt-cleanup \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/apt-update b/src/base-ubuntu/root/usr/bin/apt-update index 1993bae9..4e6a66a8 100755 --- a/src/base-ubuntu/root/usr/bin/apt-update +++ b/src/base-ubuntu/root/usr/bin/apt-update @@ -1,2 +1,3 @@ #!/bin/bash -apt-get update -y \ No newline at end of file +export DEBIAN_FRONTEND=noninteractive +exec apt-get update -y "$@" \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/apt-upgrade b/src/base-ubuntu/root/usr/bin/apt-upgrade new file mode 100755 index 00000000..b82a45eb --- /dev/null +++ b/src/base-ubuntu/root/usr/bin/apt-upgrade @@ -0,0 +1,3 @@ +#!/bin/bash +export DEBIAN_FRONTEND=noninteractive +exec apt-get upgrade -yq "$@" \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/cleanup b/src/base-ubuntu/root/usr/bin/cleanup new file mode 100755 index 00000000..26dd7b72 --- /dev/null +++ b/src/base-ubuntu/root/usr/bin/cleanup @@ -0,0 +1,12 @@ +#!/bin/bash +[ -x "$(command -v apt-cleanup)" ] && apt-cleanup "$@" || true +[ -x "$(command -v composer)" ] && composer clearcache || true +[ -x "$(command -v npm)" ] && npm cache clean --force || true +[ ! -x "$(command -v vim)" ] && rm -rf /usr/share/vim || true +find /etc/ -type f -name '*-' -or -name '.placeholder' -delete 2>/dev/null +find /var/ -type f -name '*-old' -delete 2>/dev/null +find /var/log -type f | xargs -I {} bash -c '>{}' 2>/dev/null +rm -rf \ + ~/.cache ~/.composer* ~/.git* ~/.gnupg ~/.log ~/.npm* \ + /var/cache/apk /var/cache/yum /var/lib/apt/lists/* \ + /source /tmp/* /var/tmp/* /usr/share/doc/* || true \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/dirty b/src/base-ubuntu/root/usr/bin/dirty deleted file mode 100755 index 50f084c6..00000000 --- a/src/base-ubuntu/root/usr/bin/dirty +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -echp $@ >/tmp/cleanup 2>/dev/null \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/disable b/src/base-ubuntu/root/usr/bin/disable new file mode 100755 index 00000000..b52ebf89 --- /dev/null +++ b/src/base-ubuntu/root/usr/bin/disable @@ -0,0 +1,3 @@ +#!/bin/bash +service $1 stop 2>/dev/null +update-rc.d $1 disable 2>/dev/null \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/gnu-key b/src/base-ubuntu/root/usr/bin/gnu-key new file mode 100755 index 00000000..0e49300e --- /dev/null +++ b/src/base-ubuntu/root/usr/bin/gnu-key @@ -0,0 +1,9 @@ +#!/bin/bash +GPGKEY="$1" +NAME="${2:-$GPGKEY}" +OUTKEY="/usr/share/keyrings/${NAME}.gpg" +if [ ! -z "$GPGKEY" ] && [ ! -f "$OUTKEY" ] && [ -x "$(command -v gpg)" ]; then + echo -e "\n πŸ”‘ Adding GNUPG KEY $GPGKEY to $OUTKEY" + gpg --keyserver keyserver.ubuntu.com --recv-keys "$GPGKEY" + gpg --output $OUTKEY --export "$GPGKEY" +fi \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/move b/src/base-ubuntu/root/usr/bin/move new file mode 100755 index 00000000..3dac2644 --- /dev/null +++ b/src/base-ubuntu/root/usr/bin/move @@ -0,0 +1,3 @@ +#!/bin/bash -e +shopt -s dotglob +exec mv "$@" \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/restart-svc b/src/base-ubuntu/root/usr/bin/restart-svc new file mode 100755 index 00000000..dc862114 --- /dev/null +++ b/src/base-ubuntu/root/usr/bin/restart-svc @@ -0,0 +1,12 @@ +#!/bin/bash +SVC_DIR=/var/run/s6/legacy-services/ +if [ -x "$(command -v s6-svc)" ] && [ -d $SVC_DIR ]; then + if [ -z "$@" ]; then + find $SVC_DIR -maxdepth 1 -mindepth 1 -type d \ + | xargs -I {} s6-svc -r {} 2>/dev/null + else + for svc in "$@"; do + s6-svc -r $SVC_DIR/$svc 2>/dev/null + done + fi +fi \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/wdo b/src/base-ubuntu/root/usr/bin/wdo new file mode 100755 index 00000000..79de0474 --- /dev/null +++ b/src/base-ubuntu/root/usr/bin/wdo @@ -0,0 +1,8 @@ +#!/bin/bash +export HOME=/root +cmd="${@/exec /}" +if [ -x "$(command -v sudo)" ]; then + exec sudo -u webuser -g webgroup -E -- $cmd +else + exec su -p webuser -g webgroup -c -- $cmd +fi \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/webhome b/src/base-ubuntu/root/usr/bin/webhome new file mode 100755 index 00000000..eac1d800 --- /dev/null +++ b/src/base-ubuntu/root/usr/bin/webhome @@ -0,0 +1,2 @@ +#!/bin/bash +echo "${WEBHOME:-/var/www/html}" \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/webuser-mkdir b/src/base-ubuntu/root/usr/bin/webuser-mkdir deleted file mode 100755 index 6a536d63..00000000 --- a/src/base-ubuntu/root/usr/bin/webuser-mkdir +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -DIR="$1" - -mkdir -p $DIR/ -if [ "$2" == "recursive" ]; then - chown -R webuser:webgroup $DIR/ -else - chown webuser:webgroup $DIR/ -fi -chmod +s $DIR/ \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/wldo b/src/base-ubuntu/root/usr/bin/wldo new file mode 100755 index 00000000..b37cf088 --- /dev/null +++ b/src/base-ubuntu/root/usr/bin/wldo @@ -0,0 +1,8 @@ +#!/bin/bash +export HOME=/root +cmd="${@/exec /}" +if [ -x "$(command -v sudo)" ]; then + exec sudo -u webuser -g webgroup -i -- $cmd +else + exec su - webuser -g webgroup -c -- $cmd +fi \ No newline at end of file diff --git a/src/base-ubuntu/root/usr/bin/wmd b/src/base-ubuntu/root/usr/bin/wmd new file mode 100755 index 00000000..a18894b1 --- /dev/null +++ b/src/base-ubuntu/root/usr/bin/wmd @@ -0,0 +1,6 @@ +#!/bin/bash +if [ ! -z "$1" ]; then + DIR="$1" + CHOWN="chown$([ "$2" == "recursive" ] || [ "$2" == "-R" ] && echo ' -R')" + mkdir -p $DIR && $CHOWN webuser:webgroup $DIR/ && chmod +s $DIR/ +fi \ No newline at end of file diff --git a/src/base-ubuntu/root/welcome.txt b/src/base-ubuntu/root/welcome.txt index 3885b94b..b8ea7b1f 100644 --- a/src/base-ubuntu/root/welcome.txt +++ b/src/base-ubuntu/root/welcome.txt @@ -9,7 +9,7 @@ \__ \ (_) |_____| |_| | |_) | |_| | | | | |_| |_| | |___/\___/ \__,_|_.__/ \__,_|_| |_|\__|\__,_| - Github: https://github.com/shinsenter/php/ - DockerHub: https://hub.docker.com/r/shinsenter/s6-ubuntu + Github: https://code.shin.company/php + DockerHub: https://docker.shin.company/s6-ubuntu - (To edit this welcome message, add your text to /welcome.txt) + (To edit this welcome message, add your text to %PATH%) diff --git a/src/base/Dockerfile b/src/base/Dockerfile new file mode 100644 index 00000000..66037524 --- /dev/null +++ b/src/base/Dockerfile @@ -0,0 +1,9 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +FROM scratch +COPY scratch/ / + +################################################################################ \ No newline at end of file diff --git a/src/base/README.md b/src/base/README.md new file mode 100644 index 00000000..6ae31068 --- /dev/null +++ b/src/base/README.md @@ -0,0 +1,54 @@ +# shinsenter/scratch + +πŸ—‚ A multi-arch scratch image that makes it possible to cross-build images from scratch. + +> πŸ”— https://docker.shin.company/scratch + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/scratch)](https://docker.shin.company/scratch) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/scratch/latest?label=shinsenter%2Fscratch)](https://docker.shin.company/scratch) + +* * * + +## About this project + +This image solves for is such a corner case that most people wouldn't run into it, so you can probably get away with `FROM scratch`. + +The problem arises when you are trying to build an image for another machine architecture, and have to use `FROM scratch` in your dockerfile, in which case the resulting image will be tagged as being for the build machine's architecture instead of the target architecture (even though Qemu was used). + +These images are actively maintained. + +## Usage + +Using `FROM shinsenter/scratch` creates a trusted multi-arch image tag from scratch. + +```Dockerfile +FROM shinsenter/scratch + +# copy files from other source +COPY ... +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Supported platforms + +This repository uses multi-platform images via Docker manifests. Currently, the supported architectures are: + +- linux/386 +- linux/amd64 +- linux/amd64/v2 +- linux/amd64/v3 +- linux/amd64/v4 +- linux/arm/v6 +- linux/arm/v7 +- linux/arm64/v8 +- linux/mips64 +- linux/mips64le +- linux/ppc64le +- linux/riscv64 +- linux/s390x + +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/php/cli/Dockerfile b/src/php/cli/Dockerfile index e10cc6fb..c9212720 100644 --- a/src/php/cli/Dockerfile +++ b/src/php/cli/Dockerfile @@ -1,60 +1,69 @@ -# This file is the work of https://github.com/shinsenter/php +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE ################################################################################ ARG BASE_IMAGE=shinsenter/s6-ubuntu:latest ################################################################################ -# prepares base image +# base image FROM ${BASE_IMAGE} -ARG PHP_VERSION=8.1 +ARG PHP_BUILD_DEPS="gnupg2 apt-utils" ARG PHP_PPA_KEY="4F4EA0AAE5267A6C" ARG PHP_PPA_URL="http://ppa.launchpad.net/ondrej/php/ubuntu" -ARG PHP_SOURCES="/etc/apt/sources.list.d/ondrej-php.list" -ARG PHP_BUILD_DEP="gnupg less sudo unzip" +ARG PHP_MODULES="/usr/src/php${PHP_VERSION}.txt" +ARG PHP_VERSION="8.1" -# adds variables for PHP and Composer ENV PHP_VERSION=${PHP_VERSION} -ADD php${PHP_VERSION}.txt /usr/src/php${PHP_VERSION}.txt +ADD php${PHP_VERSION}.txt $PHP_MODULES + +################################################################################ + +# adds config files +ADD root/ / # installs PHP and Composer -RUN echo "Installing PHP ${PHP_VERSION}..." \ - && apt-update && apt-install ${PHP_BUILD_DEP} \ - \ - # adds ondrej repos for PHP - && add-ppa $PHP_PPA_URL $PHP_SOURCES $PHP_PPA_KEY \ - \ - # installs php +RUN echo "Installing PHP ${PHP_VERSION}" \ && apt-update \ - && apt-install $(cat /usr/src/php${PHP_VERSION}.txt) \ + && apt-install $PHP_BUILD_DEPS less sudo unzip \ + && apt-deb ppa-php $PHP_PPA_URL $PHP_PPA_KEY \ + && phpaddmod $(cat $PHP_MODULES) \ && swap-dir /etc/php/${PHP_VERSION}/cli /etc/php/cli \ \ + # makes symlinks + && ln -fs /usr/bin/php /usr/local/bin/php \ + && ln -sf /etc/php/cli /usr/local/etc/php \ + && ln -sf /usr/bin/phpaddmod /usr/sbin/docker-php-ext-install \ + && ln -sf /usr/bin/phpenmod /usr/sbin/docker-php-ext-enable \ + && ln -sf /usr/bin/phpdelmod /usr/sbin/docker-php-ext-remove \ + && ln -sf /usr/bin/phpdismod /usr/sbin/docker-php-ext-disable \ + \ + # installs composer + && php -r "copy('https://getcomposer.org/installer', '/tmp/composer-setup.php');" \ + && php /tmp/composer-setup.php --install-dir=/usr/bin --filename=composer \ + && chmod +xr /usr/bin/composer \ + \ # cleanup - && apt-get upgrade -y \ - && apt-cleanup + && apt-upgrade -uq \ + && cleanup $PHP_BUILD_DEPS -# adds composer -COPY --from=composer:latest /usr/bin/composer /usr/bin/composer +# sets the working directory +# WORKDIR $WEBHOME -# creates folder for composer -RUN webuser-mkdir /composer 2>/dev/null - -################################################################################ - -# adds config files -ADD root/ / - -# sets default command -CMD ["php", "-a"] +# sets default entrypoint and command +ENTRYPOINT [] +CMD ["/usr/bin/php", "-a"] ################################################################################ # adds composer settings -ENV COMPOSER_HOME=/composer ENV COMPOSER_ALLOW_SUPERUSER=1 +ENV COMPOSER_HOME=/composer ENV COMPOSER_MAX_PARALLEL_HTTP=32 -ENV PATH /composer/vendor/bin:$PATH +ENV PATH=/composer/vendor/bin:$PATH ENV PHP_CONF_DIR=/etc/php/cli/conf.d +ENV PHP_INI_DIR=/etc/php/cli ################################################################################ \ No newline at end of file diff --git a/src/php/cli/README.md b/src/php/cli/README.md index f379da9b..c07de431 100644 --- a/src/php/cli/README.md +++ b/src/php/cli/README.md @@ -1,8 +1,12 @@ # shinsenter/php -🧭 Production-ready Docker images for PHP, support PHP CLI and many types of PHP web applications. +πŸ“¦ (PHP) Production-ready PHP-CLI Docker images for your PHP applications. -See: https://hub.docker.com/r/shinsenter/php +> πŸ”— https://docker.shin.company/php + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/php)](https://docker.shin.company/php) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/php/latest?label=shinsenter%2Fphp)](https://docker.shin.company/php/tags) [![Publish Images (shinsenter/php)](https://code.shin.company/php/actions/workflows/build-v2.yml/badge.svg?branch=main)](https://code.shin.company/php/actions/workflows/build-v2.yml) + +[![shinsenter/php](https://repository-images.githubusercontent.com/458053748/24e848e1-c0fc-4893-b2b9-f7dbfad263f3)](https://docker.shin.company/php) ## Supported platforms @@ -10,7 +14,7 @@ Currently, the supported architectures are: - linux/amd64 - linux/arm/v7 -- linux/arm64 +- linux/arm64/v8 - linux/ppc64le -You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/php/cli/php7.3.txt b/src/php/cli/php7.3.txt new file mode 100644 index 00000000..5e1cc1ad --- /dev/null +++ b/src/php/cli/php7.3.txt @@ -0,0 +1,19 @@ +apcu +bcmath +cli +common +curl +gd +gmp +igbinary +intl +json +mbstring +memcached +mysql +redis +soap +sqlite3 +tidy +xml +zip \ No newline at end of file diff --git a/src/php/cli/php7.4.txt b/src/php/cli/php7.4.txt index 98141f90..5e1cc1ad 100644 --- a/src/php/cli/php7.4.txt +++ b/src/php/cli/php7.4.txt @@ -1,17 +1,19 @@ -php7.4-apcu -php7.4-bcmath -php7.4-cli -php7.4-common -php7.4-curl -php7.4-gd -php7.4-gmp -php7.4-igbinary -php7.4-intl -php7.4-json -php7.4-mbstring -php7.4-mysql -php7.4-redis -php7.4-soap -php7.4-sqlite3 -php7.4-xml -php7.4-zip \ No newline at end of file +apcu +bcmath +cli +common +curl +gd +gmp +igbinary +intl +json +mbstring +memcached +mysql +redis +soap +sqlite3 +tidy +xml +zip \ No newline at end of file diff --git a/src/php/cli/php8.0.txt b/src/php/cli/php8.0.txt index dc28eecf..c00eec5b 100644 --- a/src/php/cli/php8.0.txt +++ b/src/php/cli/php8.0.txt @@ -1,16 +1,18 @@ -php8.0-apcu -php8.0-bcmath -php8.0-cli -php8.0-common -php8.0-curl -php8.0-gd -php8.0-gmp -php8.0-igbinary -php8.0-intl -php8.0-mbstring -php8.0-mysql -php8.0-redis -php8.0-soap -php8.0-sqlite3 -php8.0-xml -php8.0-zip \ No newline at end of file +apcu +bcmath +cli +common +curl +gd +gmp +igbinary +intl +mbstring +memcached +mysql +redis +soap +sqlite3 +tidy +xml +zip \ No newline at end of file diff --git a/src/php/cli/php8.1.txt b/src/php/cli/php8.1.txt index 4b21768a..c00eec5b 100644 --- a/src/php/cli/php8.1.txt +++ b/src/php/cli/php8.1.txt @@ -1,16 +1,18 @@ -php8.1-apcu -php8.1-bcmath -php8.1-cli -php8.1-common -php8.1-curl -php8.1-gd -php8.1-gmp -php8.1-igbinary -php8.1-intl -php8.1-mbstring -php8.1-mysql -php8.1-redis -php8.1-soap -php8.1-sqlite3 -php8.1-xml -php8.1-zip \ No newline at end of file +apcu +bcmath +cli +common +curl +gd +gmp +igbinary +intl +mbstring +memcached +mysql +redis +soap +sqlite3 +tidy +xml +zip \ No newline at end of file diff --git a/src/php/cli/php8.2.txt b/src/php/cli/php8.2.txt index f3ce0535..c00eec5b 100644 --- a/src/php/cli/php8.2.txt +++ b/src/php/cli/php8.2.txt @@ -1,16 +1,18 @@ -php8.2-apcu -php8.2-bcmath -php8.2-cli -php8.2-common -php8.2-curl -php8.2-gd -php8.2-gmp -php8.2-igbinary -php8.2-intl -php8.2-mbstring -php8.2-mysql -php8.2-redis -php8.2-soap -php8.2-sqlite3 -php8.2-xml -php8.2-zip \ No newline at end of file +apcu +bcmath +cli +common +curl +gd +gmp +igbinary +intl +mbstring +memcached +mysql +redis +soap +sqlite3 +tidy +xml +zip \ No newline at end of file diff --git a/src/php/cli/php9.0.txt b/src/php/cli/php9.0.txt index c85536e2..c00eec5b 100644 --- a/src/php/cli/php9.0.txt +++ b/src/php/cli/php9.0.txt @@ -1,16 +1,18 @@ -php9.0-apcu -php9.0-bcmath -php9.0-cli -php9.0-common -php9.0-curl -php9.0-gd -php9.0-gmp -php9.0-igbinary -php9.0-intl -php9.0-mbstring -php9.0-mysql -php9.0-redis -php9.0-soap -php9.0-sqlite3 -php9.0-xml -php9.0-zip \ No newline at end of file +apcu +bcmath +cli +common +curl +gd +gmp +igbinary +intl +mbstring +memcached +mysql +redis +soap +sqlite3 +tidy +xml +zip \ No newline at end of file diff --git a/src/php/cli/root/etc/cont-init.d/100-generate-ssl b/src/php/cli/root/etc/cont-init.d/100-generate-ssl new file mode 100755 index 00000000..fefc0638 --- /dev/null +++ b/src/php/cli/root/etc/cont-init.d/100-generate-ssl @@ -0,0 +1,12 @@ +#!/command/with-contenv bash +CERT_DIR=/etc/ssl/web +if [ ! -f $CERT_DIR/server.key ]; then + echo; echo "πŸ” Generating a self-signed SSL certificate" + wmd $CERT_DIR + openssl req -x509 \ + -subj "/C=VN/ST=Vietnam/L=Vietnam/O=SHIN Company/CN=localhost" \ + -nodes -newkey rsa:2048 -keyout $CERT_DIR/server.key \ + -out $CERT_DIR/server.crt -days 365 + cp -p $CERT_DIR/server.crt /usr/local/share/ca-certificates/ + update-ca-certificates +fi \ No newline at end of file diff --git a/src/php/cli/root/startup/900-composer b/src/php/cli/root/startup/900-composer new file mode 100755 index 00000000..fd383f67 --- /dev/null +++ b/src/php/cli/root/startup/900-composer @@ -0,0 +1,13 @@ +#!/command/with-contenv bash +WEBHOME="$(webhome)" +COMPOSER_HOME="${COMPOSER_HOME:-/composer}" + +wmd $COMPOSER_HOME +[ -f "${COMPOSER_HOME}/keys.dev.pub" ] || wdo php -r "copy('https://composer.github.io/snapshots.pub','${COMPOSER_HOME}/keys.dev.pub');" +[ -f "${COMPOSER_HOME}/keys.tags.pub" ] || wdo php -r "copy('https://composer.github.io/releases.pub','${COMPOSER_HOME}/keys.tags.pub');" +chmod 0644 $COMPOSER_HOME/*.pub 2>/dev/null + +if [ -f $WEBHOME/composer.json ] && [ ! -d $WEBHOME/vendor/ ]; then + echo; echo "πŸ€– Installing packages from $WEBHOME/composer.json" + wdo composer-install -d $WEBHOME/ +fi \ No newline at end of file diff --git a/src/php/cli/root/usr/bin/composer-create b/src/php/cli/root/usr/bin/composer-create new file mode 100755 index 00000000..d1aeb810 --- /dev/null +++ b/src/php/cli/root/usr/bin/composer-create @@ -0,0 +1,10 @@ +#!/bin/bash +echo; echo " ⏬ Running composer create-project $@" +exec composer create-project --ansi \ +--no-cache \ +--no-interaction \ +--no-progress \ +--no-secure-http \ +--prefer-dist \ +$COMPOSER_CREATE_OPTIONS \ +"$@" \ No newline at end of file diff --git a/src/php/cli/root/usr/bin/composer-install b/src/php/cli/root/usr/bin/composer-install new file mode 100755 index 00000000..0e90cd9c --- /dev/null +++ b/src/php/cli/root/usr/bin/composer-install @@ -0,0 +1,11 @@ +#!/bin/bash +echo; echo " ⏬ Running composer install $@" +exec composer install --ansi \ +--no-cache \ +--no-dev \ +--no-interaction \ +--no-progress \ +--optimize-autoloader \ +--prefer-dist \ +$COMPOSER_INSTALL_OPTIONS \ +"$@" \ No newline at end of file diff --git a/src/php/cli/root/usr/bin/composer-require b/src/php/cli/root/usr/bin/composer-require new file mode 100755 index 00000000..6dc53525 --- /dev/null +++ b/src/php/cli/root/usr/bin/composer-require @@ -0,0 +1,11 @@ +#!/bin/bash +echo; echo " ⏬ Running composer require $@" +exec composer require --ansi \ +--no-cache \ +--no-interaction \ +--no-progress \ +--optimize-autoloader \ +--prefer-dist \ +--sort-packages \ +$COMPOSER_REQUIRE_OPTIONS \ +"$@" \ No newline at end of file diff --git a/src/php/cli/root/usr/bin/composer-wait b/src/php/cli/root/usr/bin/composer-wait new file mode 100755 index 00000000..ac9b5c5c --- /dev/null +++ b/src/php/cli/root/usr/bin/composer-wait @@ -0,0 +1,3 @@ +#!/bin/bash +AUTOLOAD="$(webhome)/vendor/autoload.php" +while [ ! -f "$AUTOLOAD" ]; do sleep 1; done \ No newline at end of file diff --git a/src/php/cli/root/usr/bin/phpaddmod b/src/php/cli/root/usr/bin/phpaddmod new file mode 100755 index 00000000..8240756c --- /dev/null +++ b/src/php/cli/root/usr/bin/phpaddmod @@ -0,0 +1,3 @@ +#!/bin/bash +echo; echo " ⏬ PHP${PHP_VERSION}: Installing $(echo "$@" | sed "s/ *-\+[^ ]\+//g" | sed "s/[^ ]\+/php${PHP_VERSION}-&/g")" +apt-oneshot $(echo "$@" | sed "s/[^ ]\+/php${PHP_VERSION}-&/g" | sed "s/php${PHP_VERSION}-\(-\+\)/\1/g") \ No newline at end of file diff --git a/src/php/cli/root/usr/bin/phpdelmod b/src/php/cli/root/usr/bin/phpdelmod new file mode 100755 index 00000000..51efda79 --- /dev/null +++ b/src/php/cli/root/usr/bin/phpdelmod @@ -0,0 +1,3 @@ +#!/bin/bash +echo; echo " ⏬ PHP${PHP_VERSION}: Removing $(echo "$@" | sed "s/ *-\+[^ ]\+//g" | sed "s/[^ ]\+/php${PHP_VERSION}-&/g")" +apt-cleanup $(echo "$@" | sed "s/[^ ]\+/php${PHP_VERSION}-&/g" | sed "s/php${PHP_VERSION}-\(-\+\)/\1/g") \ No newline at end of file diff --git a/src/php/cli/root/welcome.txt b/src/php/cli/root/welcome.txt index eec7b83e..e30a22a0 100644 --- a/src/php/cli/root/welcome.txt +++ b/src/php/cli/root/welcome.txt @@ -5,7 +5,7 @@ |___/_| |_|_|_| |_|___/\___|_| |_|\__\___|_|/_/ | .__/|_| |_| .__/ |_| |_| - Github: https://github.com/shinsenter/php/ - Docker Hub: https://hub.docker.com/r/shinsenter/php/ + Github: https://code.shin.company/php + DockerHub: https://docker.shin.company/php - (To edit this welcome message, add your text to /welcome.txt) + (To edit this welcome message, add your text to %PATH%) diff --git a/src/php/fpm/Dockerfile b/src/php/fpm/Dockerfile index 4b1cbb76..0cb15da5 100644 --- a/src/php/fpm/Dockerfile +++ b/src/php/fpm/Dockerfile @@ -1,4 +1,6 @@ -# This file is the work of https://github.com/shinsenter/php +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE ################################################################################ ARG BASE_IMAGE=shinsenter/php @@ -6,42 +8,50 @@ ARG PHP_VERSION=8.1 ################################################################################ -# base image and platform +# base image FROM ${BASE_IMAGE}:${PHP_VERSION}-cli # adds PHP configs ENV PHP_POOL_NAME=www +################################################################################ + # installs php-fpm RUN apt-update \ - && apt-install msmtp msmtp-mta \ - && apt-install php${PHP_VERSION}-fpm \ - && service php${PHP_VERSION}-fpm stop && update-rc.d php${PHP_VERSION}-fpm disable \ + && apt-install php${PHP_VERSION}-fpm msmtp msmtp-mta \ + && disable php${PHP_VERSION}-fpm \ && swap-dir /etc/php/${PHP_VERSION}/fpm /etc/php/fpm \ && sed -i -e 's/\[www\]/\[$\{PHP_POOL_NAME\}]/g' /etc/php/fpm/pool.d/www.conf \ + && ln -sf /etc/php/fpm /usr/local/etc/php-fpm \ && ln -sf /usr/sbin/php-fpm${PHP_VERSION} /usr/sbin/php-fpm \ \ - # makes log files - && webuser-mkdir /var/log/php-fpm \ - && ln -sf /dev/stdout /var/log/php-fpm/access.log \ - && ln -sf /dev/stderr /var/log/php-fpm/error.log \ - \ # cleanup - && apt-cleanup + && rm -rf /var/log/php-fpm \ + && apt-upgrade -uq \ + && cleanup -################################################################################ +# opcache preload +RUN if [ "$(php -r 'echo PHP_VERSION_ID;')" -ge "70400" ]; then \ + echo '' >>/etc/php/fpm/pool.d/x-override-php-defaults.conf; \ + echo 'php_value[opcache.preload] = ${PHP_OPCACHE_PRELOAD}' >>/etc/php/fpm/pool.d/x-override-php-defaults.conf; \ + echo 'php_value[opcache.preload_user] = ${PHP_OPCACHE_PRELOAD_USER}' >>/etc/php/fpm/pool.d/x-override-php-defaults.conf; \ +fi # adds config files ADD root/ / -# resets the entrypoint -ENTRYPOINT ["/init"] +# sets the working directory +# WORKDIR $WEBHOME + +# exposes port EXPOSE 9000 +# sets default entrypoint +ENTRYPOINT ["/init"] + ################################################################################ # adds MSMTP settings -ENV DEBUG_MODE=false ENV MSMTP_RELAY_SERVER_HOSTNAME=mailhog ENV MSMTP_RELAY_SERVER_PORT=1025 @@ -62,12 +72,13 @@ ENV PHP_PM_MIN_SPARE_SERVERS=7 ENV PHP_PM_START_SERVERS=7 # adds other Opcache settings -ENV PHP_OPCACHE_INTERNED_STRINGS_BUFFER=8 -ENV PHP_OPCACHE_MAX_ACCELERATED_FILES=1048793 -ENV PHP_OPCACHE_MEMORY_CONSUMPTION=128 +ENV PHP_OPCACHE_INTERNED_STRINGS_BUFFER=64 +ENV PHP_OPCACHE_MAX_ACCELERATED_FILES=130987 +ENV PHP_OPCACHE_MAX_WASTED_PERCENTAGE=15 +ENV PHP_OPCACHE_MEMORY_CONSUMPTION=256 ENV PHP_OPCACHE_PRELOAD_USER=webuser ENV PHP_OPCACHE_PRELOAD= -ENV PHP_OPCACHE_REVALIDATE_FREQ=2 +ENV PHP_OPCACHE_REVALIDATE_FREQ=5 ENV PHP_OPCACHE_REVALIDATE_PATH=0 ENV PHP_OPCACHE_SAVE_COMMENTS=1 ENV PHP_OPCACHE_VALIDATE_TIMESTAMPS=1 diff --git a/src/php/fpm/README.md b/src/php/fpm/README.md index f379da9b..8b468c5a 100644 --- a/src/php/fpm/README.md +++ b/src/php/fpm/README.md @@ -1,8 +1,12 @@ # shinsenter/php -🧭 Production-ready Docker images for PHP, support PHP CLI and many types of PHP web applications. +πŸ“¦ (PHP) Production-ready PHP-FPM Docker images for your PHP applications. -See: https://hub.docker.com/r/shinsenter/php +> πŸ”— https://docker.shin.company/php + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/php)](https://docker.shin.company/php) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/php/latest?label=shinsenter%2Fphp)](https://docker.shin.company/php/tags) [![Publish Images (shinsenter/php)](https://code.shin.company/php/actions/workflows/build-v2.yml/badge.svg?branch=main)](https://code.shin.company/php/actions/workflows/build-v2.yml) + +[![shinsenter/php](https://repository-images.githubusercontent.com/458053748/24e848e1-c0fc-4893-b2b9-f7dbfad263f3)](https://docker.shin.company/php) ## Supported platforms @@ -10,7 +14,7 @@ Currently, the supported architectures are: - linux/amd64 - linux/arm/v7 -- linux/arm64 +- linux/arm64/v8 - linux/ppc64le -You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/php/fpm/root/etc/cont-init.d/200-generate-ssl b/src/php/fpm/root/etc/cont-init.d/200-generate-ssl deleted file mode 100755 index 7db97bdc..00000000 --- a/src/php/fpm/root/etc/cont-init.d/200-generate-ssl +++ /dev/null @@ -1,9 +0,0 @@ -#!/command/with-contenv bash - -if [ ! -f /etc/ssl/web/server.key ]; then - echo "πŸ” Generating a self-signed SSL certificate..." - webuser-mkdir /etc/ssl/web/ - openssl req -x509 -subj "/C=VN/ST=Vietnam/L=Vietnam/O=SHIN Company/CN=localhost" \ - -nodes -newkey rsa:2048 -keyout /etc/ssl/web/server.key \ - -out /etc/ssl/web/server.crt -days 365 -fi diff --git a/src/php/fpm/root/etc/cont-init.d/200-msmtp b/src/php/fpm/root/etc/cont-init.d/200-msmtp new file mode 100755 index 00000000..6e31ec49 --- /dev/null +++ b/src/php/fpm/root/etc/cont-init.d/200-msmtp @@ -0,0 +1,6 @@ +#!/command/with-contenv bash +cat > /etc/msmtprc < /etc/msmtprc < +# License: https://code.shin.company/php/blob/main/LICENSE ################################################################################ ARG BASE_IMAGE=shinsenter/php @@ -6,34 +8,29 @@ ARG PHP_VERSION=8.1 ################################################################################ -# base image and platform +# base image FROM ${BASE_IMAGE}:${PHP_VERSION}-fpm +ARG APACHE_BUILD_DEPS="gnupg2 apt-utils" ARG APACHE_PPA_KEY="4F4EA0AAE5267A6C" ARG APACHE_PPA_URL="http://ppa.launchpadcontent.net/ondrej/apache2/ubuntu" -ARG APACHE_SOURCES="/etc/apt/sources.list.d/ondrej-apache.list" - ARG APACHE_RUN_GROUP="webgroup" ARG APACHE_RUN_USER="webuser" -ENV WEBHOME="/var/www/html" -ENV APACHE_DOCUMENT_ROOT="" -RUN echo "Installing Apache..." \ - \ - # adds ondrej repos for Apache2 - && add-ppa $APACHE_PPA_URL $APACHE_SOURCES $APACHE_PPA_KEY \ - \ - # installs apache, msmtp +################################################################################ + +# installs apache +RUN echo "Installing Apache" \ && apt-update \ - && apt-install apache2 \ - && service apache2 stop && update-rc.d apache2 disable \ + && apt-install $APACHE_BUILD_DEPS \ + && apt-deb ppa-apache ${APACHE_PPA_URL} ${APACHE_PPA_KEY} \ + && apt-install apache2 && disable apache2 \ && echo "ServerName localhost" >>/etc/apache2/apache2.conf \ && sed -i 's/LogFormat "%h %l %u %t \\\"%r\\\" %>s %O \\\"/LogFormat "%a %l %u %t \\\"%r\\\" %>s %O \\\"/' /etc/apache2/apache2.conf \ && echo >>/etc/apache2/envvars \ && echo "export DOCUMENT_ROOT=\"\${WEBHOME}\${APACHE_DOCUMENT_ROOT}\"" >>/etc/apache2/envvars \ && echo "export APACHE_RUN_USER=${APACHE_RUN_USER}" >>/etc/apache2/envvars \ && echo "export APACHE_RUN_GROUP=${APACHE_RUN_GROUP}" >>/etc/apache2/envvars \ - && rm -f ${WEBHOME}/*.html \ \ # modifies Apache modules && a2dismod \ @@ -42,32 +39,29 @@ RUN echo "Installing Apache..." \ actions autoindex brotli cache deflate expires headers http2 \ mpm_event proxy proxy_fcgi remoteip rewrite setenvif ssl unique_id \ \ - # makes log files - && webuser-mkdir /var/log/apache2 \ - && ln -sf /dev/stdout /var/log/apache2/access.log \ - && ln -sf /dev/stdout /var/log/apache2/other_vhosts_access.log \ - && ln -sf /dev/stderr /var/log/apache2/error.log \ - \ # cleanup - && rm -f $APACHE_SOURCES \ - && apt-cleanup - -################################################################################ + && rm -rf /var/log/apache2 ${WEBHOME}/*.html \ + && apt-upgrade -uq \ + && cleanup $APACHE_BUILD_DEPS # adds config files ADD root/ / # sets the working directory -WORKDIR $WEBHOME +# WORKDIR $WEBHOME # exposes ports EXPOSE 80 EXPOSE 443 EXPOSE 443/udp +# sets default entrypoint +ENTRYPOINT ["/init"] + ################################################################################ # sets env variables +ENV APACHE_DOCUMENT_ROOT="" ENV APACHE_MAX_CONNECTIONS_PER_CHILD=0 ENV APACHE_MAX_REQUEST_WORKERS=150 ENV APACHE_MAX_SPARE_THREADS=75 @@ -76,4 +70,6 @@ ENV APACHE_START_SERVERS=2 ENV APACHE_THREAD_LIMIT=64 ENV APACHE_THREADS_PER_CHILD=25 -################################################################################ \ No newline at end of file +################################################################################ + +LABEL traefik.enable=true \ No newline at end of file diff --git a/src/servers/fpm-apache/README.md b/src/servers/fpm-apache/README.md index 3673667a..fb4d06f9 100644 --- a/src/servers/fpm-apache/README.md +++ b/src/servers/fpm-apache/README.md @@ -1,51 +1,146 @@ # shinsenter/phpfpm-apache -🧭 Production-ready Docker images for PHP applications, powered by Apache2 web server. +🌏 (PHP) Production-ready Ubuntu + PHP-FPM + Apache2 Docker images for PHP web applications. -https://hub.docker.com/r/shinsenter/phpfpm-apache +> πŸ”— https://docker.shin.company/phpfpm-apache -[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/phpfpm-apache)](https://hub.docker.com/r/shinsenter/phpfpm-apache) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/phpfpm-apache/latest?label=shinsenter%2Fphpfpm-apache)](https://hub.docker.com/r/shinsenter/phpfpm-apache/tags) +> πŸš€ `shinsenter/phpfpm-apache` is also available in [smaller minified version](https://docker.shin.company/phpfpm-apache/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/phpfpm-apache)](https://docker.shin.company/phpfpm-apache) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/phpfpm-apache/latest?label=shinsenter%2Fphpfpm-apache)](https://docker.shin.company/phpfpm-apache) * * * ## About this project -Production-ready Docker images for PHP applications, powered by [Apache2 web server](https://httpd.apache.org). +🌏 (PHP) Production-ready Ubuntu + PHP-FPM + [Apache2](https://httpd.apache.org) Docker images for PHP web applications. + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). + +> There are many guide about configuring Apache2 with PHP-FPM, but many of them are incomplete or contain security issues. More information can be found at their [official website](https://cwiki.apache.org/confluence/display/httpd/PHP-FPM). -Built on top of [shinsenter/php](https://hub.docker.com/r/shinsenter/php) Docker images. +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. ## Usage ### Docker Pull command ```bash -docker pull shinsenter/phpfpm-apache +docker pull shinsenter/phpfpm-apache:latest ``` -### Docker Compose example +or -```yml -version: '3' -services: - my-container: - image: shinsenter/phpfpm-apache:latest - volumes: - - ./my-website:/var/www/html - environment: - TZ: UTC - ports: - - "80:80" - - "443:443" +```bash +docker pull shinsenter/phpfpm-apache:php${PHP_VERSION} ``` -View more image tags at [shinsenter/phpfpm-apache/tags](https://hub.docker.com/r/shinsenter/phpfpm-apache/tags). +or + +```bash +docker pull shinsenter/phpfpm-apache:php${PHP_VERSION}-tidy +``` + +> View more image tags at [shinsenter/phpfpm-apache/tags](https://docker.shin.company/phpfpm-apache/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. + +```Dockerfile +ENV WEBHOME="/var/www/html" +``` -## Customize your own image +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. -Dockerfile example for building your own Docker image extending this image. +> Sometimes you may wish to change the default document directory of Apache, for example if the `index.php` is placed in a `public` directory within the `$WEBHOME` path, you also can change it using an environment variable called `$APACHE_DOCUMENT_ROOT`. ```Dockerfile -FROM shinsenter/phpfpm-apache +ENV APACHE_DOCUMENT_ROOT="/public" +``` + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod +``` + +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/phpfpm-apache +``` + +For example: + +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/phpfpm-apache composer dump-autoload +``` + +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). + +```Dockerfile +ARG PHP_VERSION=8.1 +FROM shinsenter/phpfpm-apache:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== # Control your timezone ENV TZ="UTC" @@ -64,9 +159,6 @@ ENV APACHE_DOCUMENT_ROOT="" # Set to "true" to fix permission for whole $WEBHOME ENV FIX_WEBHOME_PERMISSION="false" -# sets the working directory -WORKDIR $WEBHOME - # ========================================================== # Sets the limit on the number of connections @@ -94,8 +186,66 @@ ENV APACHE_THREADS_PER_CHILD="25" # ========================================================== -# Please check https://hub.docker.com/r/shinsenter/php -# for more details of PHP environment variables. +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/phpfpm-apache:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + ports: + - "80:80" + - "443:443" + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: my_database + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. + +```bash +docker-compose up -d ``` ## Supported platforms @@ -104,7 +254,7 @@ Currently, the supported architectures are: - linux/amd64 - linux/arm/v7 -- linux/arm64 +- linux/arm64/v8 - linux/ppc64le -You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/servers/fpm-apache/root/etc/apache2/conf-available/security.conf b/src/servers/fpm-apache/root/etc/apache2/conf-available/security.conf index 6d84b5d6..37c92e30 100644 --- a/src/servers/fpm-apache/root/etc/apache2/conf-available/security.conf +++ b/src/servers/fpm-apache/root/etc/apache2/conf-available/security.conf @@ -39,12 +39,17 @@ TraceEnable Off # Prevent Apache from serving Gitlab files - + + Require all denied + + +# Prevent Apache from serving composer.* files + Require all denied # Disable XML-RPC on all wordpress sites Require all denied -# allow from xxx.xxx.xxx.xxx + # allow from xxx.xxx.xxx.xxx \ No newline at end of file diff --git a/src/servers/fpm-apache/root/etc/apache2/mods-available/deflate.conf b/src/servers/fpm-apache/root/etc/apache2/mods-available/deflate.conf new file mode 100644 index 00000000..b07b9dbd --- /dev/null +++ b/src/servers/fpm-apache/root/etc/apache2/mods-available/deflate.conf @@ -0,0 +1,43 @@ + + + AddOutputFilterByType DEFLATE \ + "application/atom+xml" \ + "application/javascript" \ + "application/json" \ + "application/ld+json" \ + "application/manifest+json" \ + "application/octet-stream" \ + "application/rss+xml" \ + "application/vnd.geo+json" \ + "application/vnd.ms-fontobject" \ + "application/x-font-opentype" \ + "application/x-font-truetype" \ + "application/x-font-ttf" \ + "application/x-javascript" \ + "application/x-web-app-manifest+json" \ + "application/xhtml+xml" \ + "application/xml" \ + "font/eot" \ + "font/opentype" \ + "font/otf" \ + "font/truetype" \ + "font/ttf" \ + "font/woff" \ + "font/woff2" \ + "image/bmp" \ + "image/svg+xml" \ + "image/vnd.microsoft.icon" \ + "image/x-icon" \ + "image/x-win-bitmap" \ + "text/cache-manifest" \ + "text/css" \ + "text/javascript" \ + "text/plain" \ + "text/vcard" \ + "text/vnd.rim.location.xloc" \ + "text/vtt" \ + "text/x-component" \ + "text/x-cross-domain-policy" \ + "text/xml" + + \ No newline at end of file diff --git a/src/servers/fpm-apache/root/etc/apache2/sites-available/000-default.conf b/src/servers/fpm-apache/root/etc/apache2/sites-available/000-default.conf index 157e25f9..9bd3e1a9 100644 --- a/src/servers/fpm-apache/root/etc/apache2/sites-available/000-default.conf +++ b/src/servers/fpm-apache/root/etc/apache2/sites-available/000-default.conf @@ -23,7 +23,6 @@ # For any files that match PHP, pass it to PHP-FPM for processing - # 2.4.10+ can proxy to unix socket ProxyFCGIBackendType GENERIC SetHandler "proxy:unix:/var/run/php/php-fpm.sock|fcgi://localhost/" @@ -33,8 +32,8 @@ # Configure Log Settings LogFormat "%l %u %t %v %a \"%r\" %>s %b" comonvhost - ErrorLog /dev/stderr - TransferLog /dev/stdout + ErrorLog /var/log/apache2/error.log + TransferLog /var/log/apache2/access.log LogLevel error @@ -64,7 +63,6 @@ # For any files that match PHP, pass it to PHP-FPM for processing - # 2.4.10+ can proxy to unix socket ProxyFCGIBackendType GENERIC SetHandler "proxy:unix:/var/run/php/php-fpm.sock|fcgi://localhost/" @@ -74,8 +72,8 @@ # Configure Log Settings LogFormat "%l %u %t %v %a \"%r\" %>s %b" comonvhost - ErrorLog /dev/stderr - TransferLog /dev/stdout + ErrorLog /var/log/apache2/error.log + TransferLog /var/log/apache2/access.log LogLevel error # SSL Settings diff --git a/src/servers/fpm-apache/root/etc/cont-init.d/900-apache2 b/src/servers/fpm-apache/root/etc/cont-init.d/900-apache2 new file mode 100755 index 00000000..9dc59098 --- /dev/null +++ b/src/servers/fpm-apache/root/etc/cont-init.d/900-apache2 @@ -0,0 +1,26 @@ +#!/command/with-contenv bash +WEBROOT="$(webhome)${APACHE_DOCUMENT_ROOT}" + +wmd $WEBROOT +if [ ! -z "$(ls -1 /web/ | grep 'index\.\(ht?ml\|php\)')" ] && [ -z "$(ls -1 $WEBROOT/ | grep 'index\.\(ht?ml\|php\)')" ]; then + echo; echo "πŸ“„ Copying temporary index page to ${WEBROOT}" + wdo cp -prf /web/index.* $WEBROOT/ +fi + +if [ ! -d /var/log/apache2 ]; then + wmd /var/log/apache2 + wdo ln -sf /proc/1/fd/1 /var/log/apache2/access.log + wdo ln -sf /proc/1/fd/1 /var/log/apache2/other_vhosts_access.log + wdo ln -sf /proc/1/fd/2 /var/log/apache2/error.log +fi + +echo +/usr/sbin/apache2ctl -v +/usr/sbin/apache2ctl configtest + +if [ "$DEBUG_MODE" == "true" ]; then + sed -i 's/^LogLevel.*/LogLevel debug/' /etc/apache2/apache2.conf + echo "πŸ”₯ APACHE is in DEBUG MODE πŸ”₯" +fi + +echo \ No newline at end of file diff --git a/src/servers/fpm-apache/root/etc/cont-init.d/900-debug-apache2 b/src/servers/fpm-apache/root/etc/cont-init.d/900-debug-apache2 deleted file mode 100755 index 98f5a2f9..00000000 --- a/src/servers/fpm-apache/root/etc/cont-init.d/900-debug-apache2 +++ /dev/null @@ -1,6 +0,0 @@ -#!/command/with-contenv bash - -if [[ $DEBUG_MODE && $DEBUG_MODE == true ]]; then - sed -i 's/^LogLevel.*/LogLevel debug/' /etc/apache2/apache2.conf - echo "πŸ”₯ APACHE is in DEBUG MODE πŸ”₯" -fi \ No newline at end of file diff --git a/src/servers/fpm-apache/root/etc/php/fpm/pool.d/y-override-phpfpm-defaults.conf b/src/servers/fpm-apache/root/etc/php/fpm/pool.d/y-override-phpfpm-defaults.conf index 7a7aaa69..f41e47ca 100644 --- a/src/servers/fpm-apache/root/etc/php/fpm/pool.d/y-override-phpfpm-defaults.conf +++ b/src/servers/fpm-apache/root/etc/php/fpm/pool.d/y-override-phpfpm-defaults.conf @@ -1,5 +1,4 @@ [${PHP_POOL_NAME}] -; Listen on socket, not the network listen = /var/run/php/php-fpm.sock listen.owner = webuser listen.group = webgroup \ No newline at end of file diff --git a/src/servers/fpm-apache/root/etc/services.d/100-apache2/run b/src/servers/fpm-apache/root/etc/services.d/100-apache2/run deleted file mode 100755 index 3a48ab5e..00000000 --- a/src/servers/fpm-apache/root/etc/services.d/100-apache2/run +++ /dev/null @@ -1,14 +0,0 @@ -#!/command/with-contenv bash - -WEBROOT="${WEBHOME:-/var/www/html}${APACHE_DOCUMENT_ROOT}" - -if [ ! -z "$(ls -1 /web/ | grep 'index\.\(ht?ml\|php\)')" ] && [ -z "$(ls -1 $WEBROOT/ | grep 'index\.\(ht?ml\|php\)')" ]; then - cp -prf /web/index.* $WEBROOT/ -fi - -echo -/usr/sbin/apache2ctl -v -/usr/sbin/apache2ctl configtest - -echo -/usr/sbin/apache2ctl -DFOREGROUND \ No newline at end of file diff --git a/src/servers/fpm-apache/root/etc/services.d/200-apache2/run b/src/servers/fpm-apache/root/etc/services.d/200-apache2/run new file mode 100755 index 00000000..c5b54019 --- /dev/null +++ b/src/servers/fpm-apache/root/etc/services.d/200-apache2/run @@ -0,0 +1,2 @@ +#!/command/with-contenv bash +exec apache2ctl -DFOREGROUND \ No newline at end of file diff --git a/src/servers/fpm-apache/root/web/index.php b/src/servers/fpm-apache/root/web/index.php index f760ef3e..a9217ee6 100644 --- a/src/servers/fpm-apache/root/web/index.php +++ b/src/servers/fpm-apache/root/web/index.php @@ -9,7 +9,7 @@

Hello world!

-

Hi there! You are using shinsenter/php:fpm-apache docker image.

+

Hi there! You are using shinsenter/php:fpm-apache Docker image.


diff --git a/src/servers/fpm-nginx/Dockerfile b/src/servers/fpm-nginx/Dockerfile index f4d37db6..7822e542 100644 --- a/src/servers/fpm-nginx/Dockerfile +++ b/src/servers/fpm-nginx/Dockerfile @@ -1,4 +1,6 @@ -# This file is the work of https://github.com/shinsenter/php +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE ################################################################################ ARG BASE_IMAGE=shinsenter/php @@ -6,54 +8,47 @@ ARG PHP_VERSION=8.1 ################################################################################ -# base image and platform +# base image FROM ${BASE_IMAGE}:${PHP_VERSION}-fpm +ARG NGINX_BUILD_DEPS="gnupg2 apt-utils" ARG NGINX_PPA_KEY="4F4EA0AAE5267A6C" ARG NGINX_PPA_URL="http://ppa.launchpadcontent.net/ondrej/nginx-mainline/ubuntu" -ARG NGINX_SOURCES="/etc/apt/sources.list.d/ondrej-nginx.list" -ENV WEBHOME="/var/www/html" -ENV NGINX_DOCUMENT_ROOT="" +################################################################################ -RUN echo "Installing Nginx..." \ - \ - # adds ondrej repos for Nginx - && add-ppa $NGINX_PPA_URL $NGINX_SOURCES $NGINX_PPA_KEY \ - \ - # installs nginx, msmtp +# installs nginx +RUN echo "Installing Nginx" \ && apt-update \ - && apt-install nginx \ - && service nginx stop && update-rc.d nginx disable \ - && rm -f ${WEBHOME}/*.html \ - \ - # makes log files - && webuser-mkdir /var/log/nginx \ - && ln -sf /dev/stdout /var/log/nginx/access.log \ - && ln -sf /dev/stderr /var/log/nginx/error.log \ + && apt-install $NGINX_BUILD_DEPS \ + && apt-deb ppa-nginx $NGINX_PPA_URL $NGINX_PPA_KEY \ + && apt-install nginx && disable nginx \ + && sed -i '/woff2/d' /etc/nginx/mime.types \ \ # cleanup - && rm -f $NGINX_SOURCES \ - && apt-cleanup - -################################################################################ + && rm -rf /var/log/nginx ${WEBHOME}/*.html \ + && apt-upgrade -uq \ + && cleanup $NGINX_BUILD_DEPS # adds config files ADD root/ / # sets the working directory -WORKDIR $WEBHOME +# WORKDIR $WEBHOME # exposes ports EXPOSE 80 EXPOSE 443 EXPOSE 443/udp +# sets default entrypoint +ENTRYPOINT ["/init"] + ################################################################################ # sets env variables -ENV DEBUG_MODE=false -ENV MSMTP_RELAY_SERVER_HOSTNAME=mailhog -ENV MSMTP_RELAY_SERVER_PORT=1025 +ENV NGINX_DOCUMENT_ROOT="" + +################################################################################ -################################################################################ \ No newline at end of file +LABEL traefik.enable=true \ No newline at end of file diff --git a/src/servers/fpm-nginx/README.md b/src/servers/fpm-nginx/README.md index 33bac651..e753918c 100644 --- a/src/servers/fpm-nginx/README.md +++ b/src/servers/fpm-nginx/README.md @@ -1,51 +1,146 @@ # shinsenter/phpfpm-nginx -🧭 Production-ready Docker images for PHP applications, powered by Nginx web server. +🌏 (PHP) Production-ready Ubuntu + PHP-FPM + Nginx Docker images for PHP web applications. -https://hub.docker.com/r/shinsenter/phpfpm-nginx +> πŸ”— https://docker.shin.company/phpfpm-nginx -[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/phpfpm-nginx)](https://hub.docker.com/r/shinsenter/phpfpm-nginx) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/phpfpm-nginx/latest?label=shinsenter%2Fphpfpm-nginx)](https://hub.docker.com/r/shinsenter/phpfpm-nginx/tags) +> πŸš€ `shinsenter/phpfpm-nginx` is also available in [smaller minified version](https://docker.shin.company/phpfpm-nginx/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/phpfpm-nginx)](https://docker.shin.company/phpfpm-nginx) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/phpfpm-nginx/latest?label=shinsenter%2Fphpfpm-nginx)](https://docker.shin.company/phpfpm-nginx) * * * ## About this project -Production-ready Docker images for PHP applications, powered by [Nginx web server](https://nginx.org/). +🌏 (PHP) Production-ready Ubuntu + PHP-FPM + [Nginx](https://nginx.org/) Docker images for PHP web applications. + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). + +> There are many guide about configuring NGINX with PHP-FPM, but many of them are incomplete or contain security issues. More information can be found at their [official website](https://www.nginx.com/resources/wiki/start/topics/examples/phpfcgi). -Built on top of [shinsenter/php](https://hub.docker.com/r/shinsenter/php) Docker images. +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. ## Usage ### Docker Pull command ```bash -docker pull shinsenter/phpfpm-nginx +docker pull shinsenter/phpfpm-nginx:latest ``` -### Docker Compose example +or -```yml -version: '3' -services: - my-container: - image: shinsenter/phpfpm-nginx:latest - volumes: - - ./my-website:/var/www/html - environment: - TZ: UTC - ports: - - "80:80" - - "443:443" +```bash +docker pull shinsenter/phpfpm-nginx:php${PHP_VERSION} ``` -View more image tags at [shinsenter/phpfpm-nginx/tags](https://hub.docker.com/r/shinsenter/phpfpm-nginx/tags). +or + +```bash +docker pull shinsenter/phpfpm-nginx:php${PHP_VERSION}-tidy +``` + +> View more image tags at [shinsenter/phpfpm-nginx/tags](https://docker.shin.company/phpfpm-nginx/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. + +```Dockerfile +ENV WEBHOME="/var/www/html" +``` -## Customize your own image +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. -Dockerfile example for building your own Docker image extending this image. +> Sometimes you may wish to change the default document directory of Nginx, for example if the `index.php` is placed in a `public` directory within the `$WEBHOME` path, you also can change it using an environment variable called `$NGINX_DOCUMENT_ROOT`. ```Dockerfile -FROM shinsenter/phpfpm-nginx +ENV NGINX_DOCUMENT_ROOT="/public" +``` + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod +``` + +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/phpfpm-nginx +``` + +For example: + +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/phpfpm-nginx composer dump-autoload +``` + +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). + +```Dockerfile +ARG PHP_VERSION=8.1 +FROM shinsenter/phpfpm-nginx:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== # Control your timezone ENV TZ="UTC" @@ -64,13 +159,68 @@ ENV NGINX_DOCUMENT_ROOT="" # Set to "true" to fix permission for whole $WEBHOME ENV FIX_WEBHOME_PERMISSION="false" -# sets the working directory -WORKDIR $WEBHOME - # ========================================================== -# Please check https://hub.docker.com/r/shinsenter/php -# for more details of PHP environment variables. +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/phpfpm-nginx:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + ports: + - "80:80" + - "443:443" + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: my_database + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. + +```bash +docker-compose up -d ``` ## Supported platforms @@ -79,7 +229,7 @@ Currently, the supported architectures are: - linux/amd64 - linux/arm/v7 -- linux/arm64 +- linux/arm64/v8 - linux/ppc64le -You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/servers/fpm-nginx/root/etc/cont-init.d/900-debug-nginx b/src/servers/fpm-nginx/root/etc/cont-init.d/900-debug-nginx deleted file mode 100755 index 90f04bc1..00000000 --- a/src/servers/fpm-nginx/root/etc/cont-init.d/900-debug-nginx +++ /dev/null @@ -1,7 +0,0 @@ -#!/command/with-contenv bash - -if [[ $DEBUG_MODE && $DEBUG_MODE == true ]]; then - # Set NGINX and PHP-FPM to debug mode - sed -i 's/^\terror_log.*/\terror_log \/proc\/self\/fd\/2 debug;/' /etc/nginx/nginx.conf - echo "πŸ”₯ NGINX is in DEBUG MODE πŸ”₯" -fi \ No newline at end of file diff --git a/src/servers/fpm-nginx/root/etc/services.d/100-nginx/run b/src/servers/fpm-nginx/root/etc/cont-init.d/900-nginx similarity index 54% rename from src/servers/fpm-nginx/root/etc/services.d/100-nginx/run rename to src/servers/fpm-nginx/root/etc/cont-init.d/900-nginx index 419541e3..62e33631 100755 --- a/src/servers/fpm-nginx/root/etc/services.d/100-nginx/run +++ b/src/servers/fpm-nginx/root/etc/cont-init.d/900-nginx @@ -1,6 +1,5 @@ #!/command/with-contenv bash - -WEBROOT="${WEBHOME:-/var/www/html}${NGINX_DOCUMENT_ROOT}" +WEBROOT="$(webhome)${NGINX_DOCUMENT_ROOT}" if [ ! -z "$PHP_POST_MAX_SIZE" ]; then echo "client_max_body_size ${PHP_POST_MAX_SIZE};" >/etc/nginx/extra.d/body-size.conf @@ -13,13 +12,25 @@ fi find /etc/nginx/sites-available -type f | \ xargs -I {} sed -i "s#root \/var\/www\/html;#root ${WEBROOT};#g" {} +wmd $WEBROOT if [ ! -z "$(ls -1 /web/ | grep 'index\.\(ht?ml\|php\)')" ] && [ -z "$(ls -1 $WEBROOT/ | grep 'index\.\(ht?ml\|php\)')" ]; then - cp -prf /web/index.* $WEBROOT/ + echo; echo "πŸ“„ Copying temporary index page to ${WEBROOT}" + wdo cp -prf /web/index.* $WEBROOT/ +fi + +if [ ! -d /var/log/nginx ]; then + wmd /var/log/nginx + wdo ln -sf /proc/1/fd/1 /var/log/nginx/access.log + wdo ln -sf /proc/1/fd/2 /var/log/nginx/error.log fi echo /usr/sbin/nginx -v /usr/sbin/nginx -t -echo -/usr/sbin/nginx \ No newline at end of file +if [ "$DEBUG_MODE" == "true" ]; then + sed -i 's/^\terror_log.*/\terror_log \/proc\/self\/fd\/2 debug;/' /etc/nginx/nginx.conf + echo "πŸ”₯ NGINX is in DEBUG MODE πŸ”₯" +fi + +echo \ No newline at end of file diff --git a/src/servers/fpm-nginx/root/etc/nginx/extra.d/performance.conf b/src/servers/fpm-nginx/root/etc/nginx/extra.d/performance.conf index 929e4eaf..5b0788b5 100644 --- a/src/servers/fpm-nginx/root/etc/nginx/extra.d/performance.conf +++ b/src/servers/fpm-nginx/root/etc/nginx/extra.d/performance.conf @@ -10,6 +10,25 @@ location = /robots.txt { access_log off; } +# html +location ~* \.(?:manifest|appcache|html?|xml|json)$ { + add_header Cache-Control "max-age=0"; + try_files $uri /index.php?$query_string; +} + +# rss +location ~* \.(?:rss|atom)$ { + add_header Cache-Control "max-age=3600"; + try_files $uri /index.php?$query_string; +} + +# assets +location ~* \.(?:css(\.map)?|js(\.map)?)$ { + expires 7d; + access_log off; + try_files $uri /index.php?$query_string; +} + # media location ~* \.(jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ { expires max; @@ -23,13 +42,6 @@ location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ { access_log off; } -# assets -location ~* \.(?:css(\.map)?|js(\.map)?)$ { - expires 7d; - access_log off; - try_files $uri /index.php?$query_string; -} - # gzip gunzip on; @@ -40,31 +52,42 @@ gzip_proxied any; gzip_comp_level 6; gzip_min_length 1024; gzip_types - application/atom+xml - application/javascript - application/json - application/octet-stream - application/rss+xml - application/vnd.ms-fontobject - application/x-font-opentype - application/x-font-truetype - application/x-font-ttf - application/x-javascript - application/xhtml+xml - application/xml - font/eot - font/opentype - font/otf - font/truetype - font/ttf - font/woff - font/woff2 - image/svg+xml - image/vnd.microsoft.icon - image/x-icon - image/x-win-bitmap - text/css - text/javascript - text/plain - text/xml - ; \ No newline at end of file + application/atom+xml + application/javascript + application/json + application/ld+json + application/manifest+json + application/octet-stream + application/rss+xml + application/vnd.geo+json + application/vnd.ms-fontobject + application/x-font-opentype + application/x-font-truetype + application/x-font-ttf + application/x-javascript + application/x-web-app-manifest+json + application/xhtml+xml + application/xml + font/eot + font/opentype + font/otf + font/truetype + font/ttf + font/woff + font/woff2 + image/bmp + image/svg+xml + image/vnd.microsoft.icon + image/x-icon + image/x-win-bitmap + text/cache-manifest + text/css + text/javascript + text/plain + text/vcard + text/vnd.rim.location.xloc + text/vtt + text/x-component + text/x-cross-domain-policy + text/xml + ; \ No newline at end of file diff --git a/src/servers/fpm-nginx/root/etc/nginx/extra.d/security.conf b/src/servers/fpm-nginx/root/etc/nginx/extra.d/security.conf index e48aa5b8..142854b3 100644 --- a/src/servers/fpm-nginx/root/etc/nginx/extra.d/security.conf +++ b/src/servers/fpm-nginx/root/etc/nginx/extra.d/security.conf @@ -1,4 +1,9 @@ # Block access to dot files location ~ /\.(?!well-known) { deny all; +} + +# Block access to composer.* files +location ~ /composer\.(json|lock) { + deny all; } \ No newline at end of file diff --git a/src/servers/fpm-nginx/root/etc/nginx/nginx.conf b/src/servers/fpm-nginx/root/etc/nginx/nginx.conf index 4a402e47..b1e701aa 100644 --- a/src/servers/fpm-nginx/root/etc/nginx/nginx.conf +++ b/src/servers/fpm-nginx/root/etc/nginx/nginx.conf @@ -1,7 +1,6 @@ # Generated by nginxconfig.io # https://www.serverion.com/nginx-config/#?0.domain=_&0.path=%2Fvar%2Fwww%2Fhtml&0.redirect=false&0.force_https=false&0.cert_type=custom&0.ssl_certificate=%2Fetc%2Fssl%2Fweb%2Fserver.crt&0.ssl_certificate_key=%2Fetc%2Fssl%2Fweb%2Fserver.key&0.wordpress&0.proxy_path=%2Fping&0.proxy_pass=unix:%2Fvar%2Frun%2Fphp%2Fphp-fpm.sock&0.index=index.html&content_security_policy=default-src%20'self'%20http:%20https:%20data:%20blob:%20'unsafe-inline';%20frame-ancestors%20'self';&php_server=%2Fvar%2Frun%2Fphp%2Fphp7.3-fpm.sock&expires_media=max&expires_svg=max&expires_fonts=max&user=webuser%20webgroup&client_max_body_size=2048&symlink=false -daemon off; pcre_jit on; worker_processes auto; worker_rlimit_nofile 100000; diff --git a/src/servers/fpm-nginx/root/etc/php/fpm/pool.d/y-override-phpfpm-defaults.conf b/src/servers/fpm-nginx/root/etc/php/fpm/pool.d/y-override-phpfpm-defaults.conf index ee11fda1..f41e47ca 100644 --- a/src/servers/fpm-nginx/root/etc/php/fpm/pool.d/y-override-phpfpm-defaults.conf +++ b/src/servers/fpm-nginx/root/etc/php/fpm/pool.d/y-override-phpfpm-defaults.conf @@ -1,8 +1,4 @@ [${PHP_POOL_NAME}] -; Listen on socket, not the network listen = /var/run/php/php-fpm.sock listen.owner = webuser -listen.group = webgroup - -; Sendmail: Direct local emails to use msmtp -php_value[sendmail_path] = /usr/bin/msmtp -C /etc/msmtprc -t --read-envelope-from \ No newline at end of file +listen.group = webgroup \ No newline at end of file diff --git a/src/servers/fpm-nginx/root/etc/services.d/200-nginx/run b/src/servers/fpm-nginx/root/etc/services.d/200-nginx/run new file mode 100755 index 00000000..2c248edd --- /dev/null +++ b/src/servers/fpm-nginx/root/etc/services.d/200-nginx/run @@ -0,0 +1,2 @@ +#!/command/with-contenv bash +exec nginx -g 'daemon off;' \ No newline at end of file diff --git a/src/servers/fpm-nginx/root/web/index.php b/src/servers/fpm-nginx/root/web/index.php index 1214b7df..79b6ffb9 100644 --- a/src/servers/fpm-nginx/root/web/index.php +++ b/src/servers/fpm-nginx/root/web/index.php @@ -9,7 +9,7 @@

Hello world!

-

Hi there! You are using shinsenter/php:fpm-nginx docker image.

+

Hi there! You are using shinsenter/php:fpm-nginx Docker image.


diff --git a/src/webapps/cakephp4/Dockerfile b/src/webapps/cakephp4/Dockerfile new file mode 100644 index 00000000..a1e7c0ac --- /dev/null +++ b/src/webapps/cakephp4/Dockerfile @@ -0,0 +1,26 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +ARG BASE_IMAGE=shinsenter/phpfpm-apache +ARG IMAGE_SUFFIX="-tidy" +ARG PHP_VERSION=8.1 + +################################################################################ + +# base image +FROM ${BASE_IMAGE}:php${PHP_VERSION}${IMAGE_SUFFIX} + +# sets web server root path +ENV APACHE_DOCUMENT_ROOT="/webroot" + +################################################################################ + +# adds config files +ADD root/ / + +# sets the working directory +# WORKDIR $WEBHOME + +################################################################################ \ No newline at end of file diff --git a/src/webapps/cakephp4/README.md b/src/webapps/cakephp4/README.md new file mode 100644 index 00000000..cc4b00b1 --- /dev/null +++ b/src/webapps/cakephp4/README.md @@ -0,0 +1,226 @@ +# shinsenter/cakephp4 + +πŸ”° (PHP) CakePHP 4 Docker images for development and production. + +> πŸ”— https://docker.shin.company/cakephp4 + +> πŸš€ `shinsenter/cakephp4` is also available in [smaller minified version](https://docker.shin.company/cakephp4/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/cakephp4)](https://docker.shin.company/cakephp4) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/cakephp4/latest?label=shinsenter%2Fcakephp4)](https://docker.shin.company/cakephp4) + +* * * + +## About this project + +πŸ”° (PHP) CakePHP 4 Docker images for development and production. These images are actively maintained. + +Creating application using the CakePHP 4 framework with ease. + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). + +> CakePHP is a rapid development framework for PHP which uses commonly known design patterns like Associative Data Mapping, Front Controller, and MVC. More information can be found at their [official website](https://cakephp.org). + +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. + +## Usage + +### Docker Pull command + +```bash +docker pull shinsenter/cakephp4:latest +``` + +or + +```bash +docker pull shinsenter/cakephp4:php${PHP_VERSION} +``` + +or + +```bash +docker pull shinsenter/cakephp4:php${PHP_VERSION}-tidy +``` + +> View more image tags at [shinsenter/cakephp4/tags](https://docker.shin.company/cakephp4/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. + +```Dockerfile +ENV WEBHOME="/var/www/html" +``` + +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. + +> Sometimes you may wish to change the default document root (away from `/var/www/html`), please consider changing the `$WEBHOME` value. + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod +``` + +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/cakephp4 +``` + +For example: + +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/cakephp4 composer dump-autoload +``` + +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). + +```Dockerfile +ARG PHP_VERSION=8.1 +FROM shinsenter/cakephp4:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== + +# Control your timezone +ENV TZ="UTC" + +# sets GID and UID +ENV PUID=9999 +ENV PGID=9999 + +# sets web server root path +ENV WEBHOME="/var/www/html" + +# ========================================================== + +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/cakephp4:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + ports: + - "80:80" + - "443:443" + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: my_database + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. + +```bash +docker-compose up -d +``` + +## Supported platforms + +Currently, the supported architectures are: + +- linux/amd64 +- linux/arm/v7 +- linux/arm64/v8 +- linux/ppc64le + +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/webapps/cakephp4/root/startup/500-init-cakephp4 b/src/webapps/cakephp4/root/startup/500-init-cakephp4 new file mode 100755 index 00000000..14d3bf59 --- /dev/null +++ b/src/webapps/cakephp4/root/startup/500-init-cakephp4 @@ -0,0 +1,11 @@ +#!/command/with-contenv bash +CAKE4_PROJECT="${CAKE4_PROJECT:-cakephp/app}" +CAKE4_ROOT="$(webhome)" +CAKE4_CHECK="$CAKE4_ROOT/bin/cake" + +if [ ! -f "$CAKE4_CHECK" ]; then + echo; echo "πŸ€– Installing $CAKE4_PROJECT from scratch" + rm -rf $CAKE4_ROOT/webroot $CAKE4_ROOT/index.* + wdo composer-create -d $CAKE4_ROOT/ $CAKE4_PROJECT $CAKE4_ROOT/ + wmd $CAKE4_ROOT -R +fi \ No newline at end of file diff --git a/src/webapps/codeigniter4/Dockerfile b/src/webapps/codeigniter4/Dockerfile index 54ea71b6..883e0e12 100644 --- a/src/webapps/codeigniter4/Dockerfile +++ b/src/webapps/codeigniter4/Dockerfile @@ -1,22 +1,26 @@ -# This file is the work of https://github.com/shinsenter/php +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE ################################################################################ ARG BASE_IMAGE=shinsenter/phpfpm-apache +ARG IMAGE_SUFFIX="-tidy" ARG PHP_VERSION=8.1 ################################################################################ -# base image and platform -FROM ${BASE_IMAGE}:php${PHP_VERSION} - -# adds config files -ADD root/ / +# base image +FROM ${BASE_IMAGE}:php${PHP_VERSION}${IMAGE_SUFFIX} # sets web server root path -ENV WEBHOME="/var/www/html" ENV APACHE_DOCUMENT_ROOT="/public" +################################################################################ + +# adds config files +ADD root/ / + # sets the working directory -WORKDIR $WEBHOME +# WORKDIR $WEBHOME ################################################################################ \ No newline at end of file diff --git a/src/webapps/codeigniter4/README.md b/src/webapps/codeigniter4/README.md index ec6ba23d..64fa2869 100644 --- a/src/webapps/codeigniter4/README.md +++ b/src/webapps/codeigniter4/README.md @@ -1,51 +1,144 @@ # shinsenter/codeigniter4 -Start creating beautiful CodeIgniter 4 websites with ease. Powered by shinsenter/php. +πŸ”° (PHP) CodeIgniter 4 Docker images for development and production. -https://hub.docker.com/r/shinsenter/codeigniter4 +> πŸ”— https://docker.shin.company/codeigniter4 -[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/codeigniter4)](https://hub.docker.com/r/shinsenter/codeigniter4) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/codeigniter4/latest?label=shinsenter%2Fcodeigniter4)](https://hub.docker.com/r/shinsenter/codeigniter4/tags) +> πŸš€ `shinsenter/codeigniter4` is also available in [smaller minified version](https://docker.shin.company/codeigniter4/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/codeigniter4)](https://docker.shin.company/codeigniter4) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/codeigniter4/latest?label=shinsenter%2Fcodeigniter4)](https://docker.shin.company/codeigniter4) * * * ## About this project -Start creating beautiful CodeIgniter 4 websites with ease. +πŸ”° (PHP) CodeIgniter 4 Docker images for development and production. These images are actively maintained. + +Creating application using the CodeIgniter 4 framework with ease. + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). -Powered by [shinsenter/php](https://hub.docker.com/r/shinsenter/php). +> CodeIgniter is a PHP full-stack web framework that is light, fast, flexible and secure. More information can be found at their [official website](http://codeigniter.com). + +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. ## Usage ### Docker Pull command ```bash -docker pull shinsenter/codeigniter4 +docker pull shinsenter/codeigniter4:latest ``` -### Docker Compose example +or -```yml -version: '3' -services: - my-container: - image: shinsenter/codeigniter4:latest - volumes: - - ./my-website:/var/www/html - environment: - TZ: UTC - ports: - - "80:80" - - "443:443" +```bash +docker pull shinsenter/codeigniter4:php${PHP_VERSION} +``` + +or + +```bash +docker pull shinsenter/codeigniter4:php${PHP_VERSION}-tidy +``` + +> View more image tags at [shinsenter/codeigniter4/tags](https://docker.shin.company/codeigniter4/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. + +```Dockerfile +ENV WEBHOME="/var/www/html" +``` + +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. + +> Sometimes you may wish to change the default document root (away from `/var/www/html`), please consider changing the `$WEBHOME` value. + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod ``` -View more image tags at [shinsenter/codeigniter4/tags](https://hub.docker.com/r/shinsenter/codeigniter4/tags). +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` -## Customize your own image +### Composer command -Dockerfile example for building your own Docker image extending this image. +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/codeigniter4 +``` + +For example: + +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/codeigniter4 composer dump-autoload +``` + +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). ```Dockerfile -FROM shinsenter/codeigniter4 +ARG PHP_VERSION=8.1 +FROM shinsenter/codeigniter4:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== # Control your timezone ENV TZ="UTC" @@ -57,16 +150,68 @@ ENV PGID=9999 # sets web server root path ENV WEBHOME="/var/www/html" -# sets the working directory -WORKDIR $WEBHOME - # ========================================================== -# Please check https://hub.docker.com/r/shinsenter/php -# for more details of PHP environment variables. +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/codeigniter4:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + ports: + - "80:80" + - "443:443" + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: my_database + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. -# Please check https://hub.docker.com/r/shinsenter/phpfpm-apache -# for more details of Apache environment variables. +```bash +docker-compose up -d ``` ## Supported platforms @@ -75,7 +220,7 @@ Currently, the supported architectures are: - linux/amd64 - linux/arm/v7 -- linux/arm64 +- linux/arm64/v8 - linux/ppc64le -You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/webapps/codeigniter4/root/etc/cont-init.d/500-boot-codeigniter4 b/src/webapps/codeigniter4/root/etc/cont-init.d/500-boot-codeigniter4 deleted file mode 100755 index 39069568..00000000 --- a/src/webapps/codeigniter4/root/etc/cont-init.d/500-boot-codeigniter4 +++ /dev/null @@ -1,19 +0,0 @@ -#!/command/with-contenv bash - -CI4_ROOT="${WEBHOME:-/var/www/html}" -CI4_CHECK="$CI4_ROOT/vendor/codeigniter4" - -webuser-mkdir "$CI4_ROOT" - -if [ ! -d "$CI4_CHECK" ]; then - rm -rf $CI4_ROOT/public $CI4_ROOT/index.* - - echo "πŸ€– Installing CodeIgniter 4 from scratch..." - dirty - composer create-project \ - codeigniter4/appstarter $CI4_ROOT/ \ - --ansi \ - --no-cache \ - --no-dev \ - --no-interaction -fi \ No newline at end of file diff --git a/src/webapps/codeigniter4/root/startup/500-init-codeigniter4 b/src/webapps/codeigniter4/root/startup/500-init-codeigniter4 new file mode 100755 index 00000000..b8545173 --- /dev/null +++ b/src/webapps/codeigniter4/root/startup/500-init-codeigniter4 @@ -0,0 +1,11 @@ +#!/command/with-contenv bash +CI4_PROJECT="${CI4_PROJECT:-codeigniter4/appstarter}" +CI4_ROOT="$(webhome)" +CI4_CHECK="$CI4_ROOT/vendor/codeigniter4" + +if [ ! -d "$CI4_CHECK" ]; then + echo; echo "πŸ€– Installing $CI4_PROJECT from scratch" + rm -rf $CI4_ROOT/public $CI4_ROOT/index.* + wdo composer-create -d $CI4_ROOT/ $CI4_PROJECT $CI4_ROOT/ + wmd $CI4_ROOT -R +fi \ No newline at end of file diff --git a/src/webapps/crater/Dockerfile b/src/webapps/crater/Dockerfile new file mode 100644 index 00000000..a1fd9230 --- /dev/null +++ b/src/webapps/crater/Dockerfile @@ -0,0 +1,38 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +ARG BASE_IMAGE=shinsenter/phpfpm-nginx +ARG IMAGE_SUFFIX="-tidy" +ARG PHP_VERSION=8.1 + +################################################################################ + +# base image +FROM ${BASE_IMAGE}:php${PHP_VERSION}${IMAGE_SUFFIX} + +# sets web server root path +ENV NGINX_DOCUMENT_ROOT="/public" + +################################################################################ + +# adds config files +ADD root/ / + +# sets the working directory +# WORKDIR $WEBHOME + +################################################################################ + +# set more env variables +ENV ENABLE_CRONTAB=true +ENV CRATER_AUTO_MIGRATION=false +ENV CRATER_AUTO_OPTIMIZE=true +ENV CRATER_LINK_STORAGE=true +ENV CRATER_QUEUE_OPTIONS= +ENV CRATER_QUEUE_ENABLED=false +ENV CRATER_SCHEDULE_OPTIONS= +ENV CRATER_SCHEDULE_ENABLED=true + +################################################################################ \ No newline at end of file diff --git a/src/webapps/crater/README.md b/src/webapps/crater/README.md new file mode 100644 index 00000000..9f8e7b26 --- /dev/null +++ b/src/webapps/crater/README.md @@ -0,0 +1,259 @@ +# shinsenter/crater + +πŸ”° (PHP) Crater Docker images for development and production. + +> πŸ”— https://docker.shin.company/crater + +> πŸš€ `shinsenter/crater` is also available in [smaller minified version](https://docker.shin.company/crater/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/crater)](https://docker.shin.company/crater) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/crater/latest?label=shinsenter%2Fcrater)](https://docker.shin.company/crater) + +* * * + +## About this project + +πŸ”° (PHP) Crater Docker images for development and production. These images are actively maintained. + +Creating application using the Crater framework with ease. + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). + +> Crater is an open-source web & mobile app that helps you track expenses, payments & create professional invoices & estimates. More information can be found at their [official website](https://docs.craterapp.com). + +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. + + +## Usage + +### Docker Pull command + +```bash +docker pull shinsenter/crater:latest +``` + +or + +```bash +docker pull shinsenter/crater:php${PHP_VERSION} +``` + +or + +```bash +docker pull shinsenter/crater:php${PHP_VERSION}-tidy +``` + +> View more image tags at [shinsenter/crater/tags](https://docker.shin.company/crater/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. + +```Dockerfile +ENV WEBHOME="/var/www/html" +``` + +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. + +> Sometimes you may wish to change the default document root (away from `/var/www/html`), please consider changing the `$WEBHOME` value. + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod +``` + +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/crater +``` + +For example: + +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/crater composer dump-autoload +``` + +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). + +```Dockerfile +ARG PHP_VERSION=8.1 +FROM shinsenter/crater:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== + +# Control your timezone +ENV TZ="UTC" + +# sets GID and UID +ENV PUID=9999 +ENV PGID=9999 + +# sets web server root path +ENV WEBHOME="/var/www/html" + +# ========================================================== + +# Optimize and cache all config, views, routes +ENV CRATER_AUTO_OPTIMIZE=true + +# Create symlinks to the storage folder +ENV CRATER_LINK_STORAGE=true + +# Run Crater migrations (for development purposese) +ENV CRATER_AUTO_MIGRATION=false + +# Auto start artisan queue:work when container is up +ENV CRATER_QUEUE_ENABLED=false + +# Extra arguments for artisan queue:work +# Example: ENV CRATER_QUEUE_OPTIONS="--timeout=10 --tries=3 redis" +ENV CRATER_QUEUE_OPTIONS= + +# Auto start artisan schedule:work when container is up +ENV CRATER_SCHEDULE_ENABLED=true + +# Extra arguments for artisan schedule:work +ENV CRATER_SCHEDULE_OPTIONS= + +# ========================================================== + +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/crater:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + REDIS_HOST: redis + DB_HOST: mysql + DB_DATABASE: crater + DB_USERNAME: root + DB_PASSWORD: mydb_p@ssw0rd + # CRATER_QUEUE_ENABLED: true + # CRATER_QUEUE_OPTIONS: --timeout=60 --tries=3 redis + # CRATER_SCHEDULE_ENABLED: true + ports: + - "80:80" + - "443:443" + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: crater + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. + +```bash +docker-compose up -d +``` + +## Supported platforms + +Currently, the supported architectures are: + +- linux/amd64 +- linux/arm/v7 +- linux/arm64/v8 +- linux/ppc64le + +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/webapps/crater/root/etc/cont-init.d/300-schedule b/src/webapps/crater/root/etc/cont-init.d/300-schedule new file mode 100755 index 00000000..ef9641c6 --- /dev/null +++ b/src/webapps/crater/root/etc/cont-init.d/300-schedule @@ -0,0 +1,4 @@ +#!/command/with-contenv bash +if [ "$CRATER_SCHEDULE_ENABLED" != "true" ]; then + rm -rf /etc/cron.d/*-schedule +fi \ No newline at end of file diff --git a/src/webapps/crater/root/etc/cron.d/crater-schedule b/src/webapps/crater/root/etc/cron.d/crater-schedule new file mode 100644 index 00000000..8e6d575a --- /dev/null +++ b/src/webapps/crater/root/etc/cron.d/crater-schedule @@ -0,0 +1,3 @@ +MAILTO="" +SHELL=/bin/bash +* * * * * webuser /usr/bin/artisan schedule:run $CRATER_SCHEDULE_OPTIONS >/proc/1/fd/1 2>/proc/1/fd/2 diff --git a/src/webapps/crater/root/etc/services.d/300-queue/run b/src/webapps/crater/root/etc/services.d/300-queue/run new file mode 100755 index 00000000..7182f3bd --- /dev/null +++ b/src/webapps/crater/root/etc/services.d/300-queue/run @@ -0,0 +1,8 @@ +#!/command/with-contenv bash +if [ "$CRATER_QUEUE_ENABLED" == "true" ]; then + composer-wait + echo; echo "πŸ€– Starting Crater queue:work $CRATER_QUEUE_OPTIONS" + exec wdo artisan queue:work $CRATER_QUEUE_OPTIONS +else + exec s6-svc -Od . +fi \ No newline at end of file diff --git a/src/webapps/crater/root/startup/500-init-crater b/src/webapps/crater/root/startup/500-init-crater new file mode 100755 index 00000000..6e4b1956 --- /dev/null +++ b/src/webapps/crater/root/startup/500-init-crater @@ -0,0 +1,44 @@ +#!/command/with-contenv bash +CRATER_PROJECT="${CRATER_PROJECT:-bytefury/crater}" +CRATER_ROOT="$(webhome)" +CRATER_ARTISAN="$CRATER_ROOT/artisan" + +if [ ! -f "$CRATER_ARTISAN" ]; then + echo; echo "πŸ€– Installing $CRATER_PROJECT from scratch" + rm -rf $CRATER_ROOT/public $CRATER_ROOT/index.* + wdo composer-create -d $CRATER_ROOT/ $CRATER_PROJECT $CRATER_ROOT/ 2>&1 + sed -i '/Barryvdh/d' $CRATER_ROOT/config/app.php + if [ "$(php -r 'echo PHP_VERSION_ID;')" -lt "70400" ]; then + wdo composer-require -d $CRATER_ROOT/ spatie/laravel-medialibrary + fi + wdo composer-install -d $CRATER_ROOT/ + wmd $CRATER_ROOT -R +fi + +if [ -f "$CRATER_ARTISAN" ]; then + composer-wait + las() { echo; wdo php $CRATER_ARTISAN --ansi "$@" 2>/dev/null; } + + if [ ! -f "$CRATER_ROOT/.env" ] && [ ! -f "$CRATER_ROOT/.env.${APP_ENV}" ]; then + wdo cp -rpf "$CRATER_ROOT/.env.example" "$CRATER_ROOT/.env" + las key:generate + fi + + if [ "$CRATER_AUTO_OPTIMIZE" == "true" ]; then + las optimize:clear + las optimize + las vendor:publish --all + wmd $CRATER_ROOT/bootstrap/cache -R + wmd $CRATER_ROOT/storage -R + fi + + if [ "$CRATER_LINK_STORAGE" == "true" ]; then + las storage:link + wmd $CRATER_ROOT/storage/app/public -R + wmd $CRATER_ROOT/public -R + fi + + if [ "$CRATER_AUTO_MIGRATION" == "true" ]; then + las migrate:refresh --seed --force + fi +fi \ No newline at end of file diff --git a/src/webapps/crater/root/usr/bin/artisan b/src/webapps/crater/root/usr/bin/artisan new file mode 100755 index 00000000..555b3bbc --- /dev/null +++ b/src/webapps/crater/root/usr/bin/artisan @@ -0,0 +1,7 @@ +#!/bin/bash +CRATER_ROOT="$(webhome)" +CRATER_ARTISAN="$CRATER_ROOT/artisan" +if [ -f "$CRATER_ARTISAN" ]; then + cd $CRATER_ROOT + exec php $CRATER_ARTISAN --ansi "$@" +fi \ No newline at end of file diff --git a/src/webapps/flarum/Dockerfile b/src/webapps/flarum/Dockerfile new file mode 100644 index 00000000..883e0e12 --- /dev/null +++ b/src/webapps/flarum/Dockerfile @@ -0,0 +1,26 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +ARG BASE_IMAGE=shinsenter/phpfpm-apache +ARG IMAGE_SUFFIX="-tidy" +ARG PHP_VERSION=8.1 + +################################################################################ + +# base image +FROM ${BASE_IMAGE}:php${PHP_VERSION}${IMAGE_SUFFIX} + +# sets web server root path +ENV APACHE_DOCUMENT_ROOT="/public" + +################################################################################ + +# adds config files +ADD root/ / + +# sets the working directory +# WORKDIR $WEBHOME + +################################################################################ \ No newline at end of file diff --git a/src/webapps/flarum/README.md b/src/webapps/flarum/README.md new file mode 100644 index 00000000..a1f85cbc --- /dev/null +++ b/src/webapps/flarum/README.md @@ -0,0 +1,226 @@ +# shinsenter/flarum + +πŸ”° (PHP) Flarum Docker images for development and production. + +> πŸ”— https://docker.shin.company/flarum + +> πŸš€ `shinsenter/flarum` is also available in [smaller minified version](https://docker.shin.company/flarum/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/flarum)](https://docker.shin.company/flarum) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/flarum/latest?label=shinsenter%2Fflarum)](https://docker.shin.company/flarum) + +* * * + +## About this project + +πŸ”° (PHP) Flarum Docker images for development and production. These images are actively maintained. + +Creating discussion platform using the Flarum framework with ease. + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). + +> Flarum is a delightfully simple discussion platform for your website. It's fast and easy to use, with all the features you need to run a successful community. More information can be found at their [official website](https://flarum.org). + +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. + +## Usage + +### Docker Pull command + +```bash +docker pull shinsenter/flarum:latest +``` + +or + +```bash +docker pull shinsenter/flarum:php${PHP_VERSION} +``` + +or + +```bash +docker pull shinsenter/flarum:php${PHP_VERSION}-tidy +``` + +> View more image tags at [shinsenter/flarum/tags](https://docker.shin.company/flarum/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. + +```Dockerfile +ENV WEBHOME="/var/www/html" +``` + +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. + +> Sometimes you may wish to change the default document root (away from `/var/www/html`), please consider changing the `$WEBHOME` value. + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod +``` + +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/flarum +``` + +For example: + +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/flarum composer dump-autoload +``` + +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). + +```Dockerfile +ARG PHP_VERSION=8.1 +FROM shinsenter/flarum:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== + +# Control your timezone +ENV TZ="UTC" + +# sets GID and UID +ENV PUID=9999 +ENV PGID=9999 + +# sets web server root path +ENV WEBHOME="/var/www/html" + +# ========================================================== + +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/flarum:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + ports: + - "80:80" + - "443:443" + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: my_database + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. + +```bash +docker-compose up -d +``` + +## Supported platforms + +Currently, the supported architectures are: + +- linux/amd64 +- linux/arm/v7 +- linux/arm64/v8 +- linux/ppc64le + +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/webapps/flarum/root/startup/500-init-flarum b/src/webapps/flarum/root/startup/500-init-flarum new file mode 100755 index 00000000..c165a5a1 --- /dev/null +++ b/src/webapps/flarum/root/startup/500-init-flarum @@ -0,0 +1,11 @@ +#!/command/with-contenv bash +FLARUM_PROJECT="${FLARUM_PROJECT:-flarum/flarum}" +FLARUM_ROOT="$(webhome)" +FLARUM_CHECK="$FLARUM_ROOT/flarum" + +if [ ! -f "$FLARUM_CHECK" ]; then + echo; echo "πŸ€– Installing $FLARUM_PROJECT from scratch" + rm -rf $FLARUM_ROOT/public $FLARUM_ROOT/index.* + wdo composer-create -d $FLARUM_ROOT/ $FLARUM_PROJECT $FLARUM_ROOT/ + wmd $FLARUM_ROOT -R +fi \ No newline at end of file diff --git a/src/webapps/fuelphp/Dockerfile b/src/webapps/fuelphp/Dockerfile new file mode 100644 index 00000000..883e0e12 --- /dev/null +++ b/src/webapps/fuelphp/Dockerfile @@ -0,0 +1,26 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +ARG BASE_IMAGE=shinsenter/phpfpm-apache +ARG IMAGE_SUFFIX="-tidy" +ARG PHP_VERSION=8.1 + +################################################################################ + +# base image +FROM ${BASE_IMAGE}:php${PHP_VERSION}${IMAGE_SUFFIX} + +# sets web server root path +ENV APACHE_DOCUMENT_ROOT="/public" + +################################################################################ + +# adds config files +ADD root/ / + +# sets the working directory +# WORKDIR $WEBHOME + +################################################################################ \ No newline at end of file diff --git a/src/webapps/fuelphp/README.md b/src/webapps/fuelphp/README.md new file mode 100644 index 00000000..b8aad980 --- /dev/null +++ b/src/webapps/fuelphp/README.md @@ -0,0 +1,226 @@ +# shinsenter/fuelphp + +πŸ”° (PHP) FuelPHP Docker images for development and production. + +> πŸ”— https://docker.shin.company/fuelphp + +> πŸš€ `shinsenter/fuelphp` is also available in [smaller minified version](https://docker.shin.company/fuelphp/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/fuelphp)](https://docker.shin.company/fuelphp) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/fuelphp/latest?label=shinsenter%2Ffuelphp)](https://docker.shin.company/fuelphp) + +* * * + +## About this project + +πŸ”° (PHP) FuelPHP Docker images for development and production. These images are actively maintained. + +Creating application using the FuelPHP framework with ease. + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). + +> FuelPHP is a fast, simple and flexible PHP 5.4+ framework, born from the best ideas of other frameworks, with a fresh start! More information can be found at their [official website](https://fuelphp.com). + +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. + +## Usage + +### Docker Pull command + +```bash +docker pull shinsenter/fuelphp:latest +``` + +or + +```bash +docker pull shinsenter/fuelphp:php${PHP_VERSION} +``` + +or + +```bash +docker pull shinsenter/fuelphp:php${PHP_VERSION}-tidy +``` + +> View more image tags at [shinsenter/fuelphp/tags](https://docker.shin.company/fuelphp/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. + +```Dockerfile +ENV WEBHOME="/var/www/html" +``` + +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. + +> Sometimes you may wish to change the default document root (away from `/var/www/html`), please consider changing the `$WEBHOME` value. + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod +``` + +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/fuelphp +``` + +For example: + +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/fuelphp composer dump-autoload +``` + +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). + +```Dockerfile +ARG PHP_VERSION=8.1 +FROM shinsenter/fuelphp:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== + +# Control your timezone +ENV TZ="UTC" + +# sets GID and UID +ENV PUID=9999 +ENV PGID=9999 + +# sets web server root path +ENV WEBHOME="/var/www/html" + +# ========================================================== + +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/fuelphp:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + ports: + - "80:80" + - "443:443" + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: my_database + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. + +```bash +docker-compose up -d +``` + +## Supported platforms + +Currently, the supported architectures are: + +- linux/amd64 +- linux/arm/v7 +- linux/arm64/v8 +- linux/ppc64le + +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/webapps/fuelphp/root/startup/500-init-fuelphp b/src/webapps/fuelphp/root/startup/500-init-fuelphp new file mode 100755 index 00000000..9b775c95 --- /dev/null +++ b/src/webapps/fuelphp/root/startup/500-init-fuelphp @@ -0,0 +1,11 @@ +#!/command/with-contenv bash +FUEL_PROJECT="${FUEL_PROJECT:-fuel/fuel}" +FUEL_ROOT="$(webhome)" +FUEL_CHECK="$FUEL_ROOT/fuel/app" + +if [ ! -d "$FUEL_CHECK" ]; then + echo; echo "πŸ€– Installing $FUEL_PROJECT from scratch" + rm -rf $FUEL_ROOT/public $FUEL_ROOT/index.* + wdo composer-create -d $FUEL_ROOT/ $FUEL_PROJECT $FUEL_ROOT/ + wmd $FUEL_ROOT -R +fi \ No newline at end of file diff --git a/src/webapps/grav/Dockerfile b/src/webapps/grav/Dockerfile new file mode 100644 index 00000000..0de697a6 --- /dev/null +++ b/src/webapps/grav/Dockerfile @@ -0,0 +1,26 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +ARG BASE_IMAGE=shinsenter/phpfpm-apache +ARG IMAGE_SUFFIX="-tidy" +ARG PHP_VERSION=8.1 + +################################################################################ + +# base image +FROM ${BASE_IMAGE}:php${PHP_VERSION}${IMAGE_SUFFIX} + +# sets web server root path +ENV APACHE_DOCUMENT_ROOT="" + +################################################################################ + +# adds config files +ADD root/ / + +# sets the working directory +# WORKDIR $WEBHOME + +################################################################################ \ No newline at end of file diff --git a/src/webapps/grav/README.md b/src/webapps/grav/README.md new file mode 100644 index 00000000..0401d52d --- /dev/null +++ b/src/webapps/grav/README.md @@ -0,0 +1,226 @@ +# shinsenter/grav + +πŸ”° (PHP) Grav CMS Docker images for development and production. + +> πŸ”— https://docker.shin.company/grav + +> πŸš€ `shinsenter/grav` is also available in [smaller minified version](https://docker.shin.company/grav/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/grav)](https://docker.shin.company/grav) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/grav/latest?label=shinsenter%2Fgrav)](https://docker.shin.company/grav) + +* * * + +## About this project + +πŸ”° (PHP) Grav CMS Docker images for development and production. These images are actively maintained. + +Creating website using the Grav CMS framework with ease. + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). + +> Grav is a modern open source flat-file CMS. More information can be found at their [official website](https://getgrav.org). + +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. + +## Usage + +### Docker Pull command + +```bash +docker pull shinsenter/grav:latest +``` + +or + +```bash +docker pull shinsenter/grav:php${PHP_VERSION} +``` + +or + +```bash +docker pull shinsenter/grav:php${PHP_VERSION}-tidy +``` + +> View more image tags at [shinsenter/grav/tags](https://docker.shin.company/grav/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. + +```Dockerfile +ENV WEBHOME="/var/www/html" +``` + +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. + +> Sometimes you may wish to change the default document root (away from `/var/www/html`), please consider changing the `$WEBHOME` value. + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod +``` + +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/grav +``` + +For example: + +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/grav composer dump-autoload +``` + +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). + +```Dockerfile +ARG PHP_VERSION=8.1 +FROM shinsenter/grav:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== + +# Control your timezone +ENV TZ="UTC" + +# sets GID and UID +ENV PUID=9999 +ENV PGID=9999 + +# sets web server root path +ENV WEBHOME="/var/www/html" + +# ========================================================== + +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/grav:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + ports: + - "80:80" + - "443:443" + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: my_database + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. + +```bash +docker-compose up -d +``` + +## Supported platforms + +Currently, the supported architectures are: + +- linux/amd64 +- linux/arm/v7 +- linux/arm64/v8 +- linux/ppc64le + +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/webapps/grav/root/startup/500-init-grav b/src/webapps/grav/root/startup/500-init-grav new file mode 100755 index 00000000..da289135 --- /dev/null +++ b/src/webapps/grav/root/startup/500-init-grav @@ -0,0 +1,14 @@ +#!/command/with-contenv bash +GRAV_PROJECT="${GRAV_PROJECT:-getgrav/grav}" +GRAV_ROOT="$(webhome)" +GRAV_CHECK="$GRAV_ROOT/bin/grav" + +if [ ! -f "$GRAV_CHECK" ]; then + echo; echo "πŸ€– Installing $GRAV_PROJECT from scratch" + rm -rf $GRAV_ROOT/web $GRAV_ROOT/index.* + [ -x "$(command -v git)" ] || apt-oneshot git + git config --global --add safe.directory $GRAV_ROOT + wdo composer-create -d $GRAV_ROOT/ $GRAV_PROJECT $GRAV_ROOT/ + $GRAV_CHECK install $GRAV_ROOT/ 2>/dev/null + wmd $GRAV_ROOT -R +fi \ No newline at end of file diff --git a/src/webapps/grav/root/usr/bin/grav b/src/webapps/grav/root/usr/bin/grav new file mode 100755 index 00000000..d91ee28f --- /dev/null +++ b/src/webapps/grav/root/usr/bin/grav @@ -0,0 +1,7 @@ +#!/bin/bash +GRAV_ROOT="$(webhome)" +GRAV_BIN="$GRAV_ROOT/bin/grav" +if [ -f "$GRAV_BIN" ]; then + cd $GRAV_ROOT + exec $GRAV_BIN "$@" +fi \ No newline at end of file diff --git a/src/webapps/hyperf/Dockerfile b/src/webapps/hyperf/Dockerfile new file mode 100644 index 00000000..db77109f --- /dev/null +++ b/src/webapps/hyperf/Dockerfile @@ -0,0 +1,30 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +ARG BASE_IMAGE=shinsenter/phpfpm-nginx +ARG IMAGE_SUFFIX="-tidy" +ARG PHP_VERSION=8.1 + +################################################################################ + +# base image +FROM ${BASE_IMAGE}:php${PHP_VERSION}${IMAGE_SUFFIX} + +# sets web server root path +ENV NGINX_DOCUMENT_ROOT="" + +################################################################################ + +# adds config files +ADD root/ / + +# installs PHP modules +RUN phpaddmod protobuf swoole --ignore-missing \ + && echo 'swoole.use_shortname = Off' >>"/etc/php/${PHP_VERSION}/mods-available/swoole.ini" + +# sets the working directory +# WORKDIR $WEBHOME + +################################################################################ \ No newline at end of file diff --git a/src/webapps/hyperf/README.md b/src/webapps/hyperf/README.md new file mode 100644 index 00000000..1d9db0a3 --- /dev/null +++ b/src/webapps/hyperf/README.md @@ -0,0 +1,226 @@ +# shinsenter/hyperf + +πŸ”° (PHP) Hyperf Docker images for development and production. + +> πŸ”— https://docker.shin.company/hyperf + +> πŸš€ `shinsenter/hyperf` is also available in [smaller minified version](https://docker.shin.company/hyperf/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/hyperf)](https://docker.shin.company/hyperf) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/hyperf/latest?label=shinsenter%2Flaravel)](https://docker.shin.company/hyperf) + +* * * + +## About this project + +πŸ”° (PHP) Hyperf Docker images for development and production. These images are actively maintained. + +Creating application using the Hyperf framework with ease. + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). + +> Hyperf is an extremely performant and flexible PHP CLI framework. More information can be found at their [official website](https://www.hyperf.io). + +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. + +## Usage + +### Docker Pull command + +```bash +docker pull shinsenter/hyperf:latest +``` + +or + +```bash +docker pull shinsenter/hyperf:php${PHP_VERSION} +``` + +or + +```bash +docker pull shinsenter/hyperf:php${PHP_VERSION}-tidy +``` + +> View more image tags at [shinsenter/hyperf/tags](https://docker.shin.company/hyperf/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. + +```Dockerfile +ENV WEBHOME="/var/www/html" +``` + +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. + +> Sometimes you may wish to change the default document root (away from `/var/www/html`), please consider changing the `$WEBHOME` value. + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod +``` + +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/hyperf +``` + +For example: + +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/hyperf composer dump-autoload +``` + +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). + +```Dockerfile +ARG PHP_VERSION=8.1 +FROM shinsenter/hyperf:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== + +# Control your timezone +ENV TZ="UTC" + +# sets GID and UID +ENV PUID=9999 +ENV PGID=9999 + +# sets web server root path +ENV WEBHOME="/var/www/html" + +# ========================================================== + +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/hyperf:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + ports: + - "80:80" + - "443:443" + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: my_database + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. + +```bash +docker-compose up -d +``` + +## Supported platforms + +Currently, the supported architectures are: + +- linux/amd64 +- linux/arm/v7 +- linux/arm64/v8 +- linux/ppc64le + +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/webapps/hyperf/root/etc/nginx/sites-available/default b/src/webapps/hyperf/root/etc/nginx/sites-available/default new file mode 100644 index 00000000..cf156c96 --- /dev/null +++ b/src/webapps/hyperf/root/etc/nginx/sites-available/default @@ -0,0 +1,30 @@ +server { + listen 80 default_server; + listen [::]:80 default_server; + listen 443 ssl http2; + listen [::]:443 ssl http2; + + server_name _; + root /var/www/html; + + # SSL + ssl_certificate /etc/ssl/web/server.crt; + ssl_certificate_key /etc/ssl/web/server.key; + + # additional config + include extra.d/*.conf; + + # health check + location /ping { + access_log off; + include snippets/fastcgi-php.conf; + fastcgi_read_timeout 5s; + fastcgi_pass unix:/var/run/php/php-fpm.sock; + } + + # forward requests + location / { + proxy_pass http://127.0.0.1:9501; + include proxy_params; + } +} \ No newline at end of file diff --git a/src/webapps/hyperf/root/etc/services.d/300-hyperf/run b/src/webapps/hyperf/root/etc/services.d/300-hyperf/run new file mode 100755 index 00000000..71416499 --- /dev/null +++ b/src/webapps/hyperf/root/etc/services.d/300-hyperf/run @@ -0,0 +1,4 @@ +#!/command/with-contenv bash +composer-wait +echo; echo "πŸ€– Starting Hyperf Server" +exec wdo hyperf start \ No newline at end of file diff --git a/src/webapps/hyperf/root/startup/500-init-hyperf b/src/webapps/hyperf/root/startup/500-init-hyperf new file mode 100755 index 00000000..a6a2798d --- /dev/null +++ b/src/webapps/hyperf/root/startup/500-init-hyperf @@ -0,0 +1,15 @@ +#!/command/with-contenv bash +HYPERF_PROJECT="${HYPERF_PROJECT:-hyperf/hyperf-skeleton}" +HYPERF_ROOT="$(webhome)" +HYPERF_BIN="$HYPERF_ROOT/bin/hyperf.php" + +if [ ! -f "$HYPERF_BIN" ]; then + echo; echo "πŸ€– Installing $HYPERF_PROJECT from scratch" + rm -rf $HYPERF_ROOT/public $HYPERF_ROOT/index.* + wdo composer-create -d $HYPERF_ROOT/ $HYPERF_PROJECT $HYPERF_ROOT/ + if [ "$(php -r 'echo PHP_VERSION_ID;')" -lt "70400" ]; then + composer-require -d $HYPERF_ROOT/ hyperf/signal symfony/serializer + restart-svc 300-hyperf + fi + wmd $HYPERF_ROOT -R +fi \ No newline at end of file diff --git a/src/webapps/hyperf/root/usr/bin/hyperf b/src/webapps/hyperf/root/usr/bin/hyperf new file mode 100755 index 00000000..09c616f7 --- /dev/null +++ b/src/webapps/hyperf/root/usr/bin/hyperf @@ -0,0 +1,7 @@ +#!/bin/bash +HYPERF_ROOT="$(webhome)" +HYPERF_BIN="$HYPERF_ROOT/bin/hyperf.php" +if [ -f "$HYPERF_BIN" ]; then + cd $HYPERF_ROOT + exec php $HYPERF_BIN "$@" +fi \ No newline at end of file diff --git a/src/webapps/kirby/Dockerfile b/src/webapps/kirby/Dockerfile new file mode 100644 index 00000000..0de697a6 --- /dev/null +++ b/src/webapps/kirby/Dockerfile @@ -0,0 +1,26 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +ARG BASE_IMAGE=shinsenter/phpfpm-apache +ARG IMAGE_SUFFIX="-tidy" +ARG PHP_VERSION=8.1 + +################################################################################ + +# base image +FROM ${BASE_IMAGE}:php${PHP_VERSION}${IMAGE_SUFFIX} + +# sets web server root path +ENV APACHE_DOCUMENT_ROOT="" + +################################################################################ + +# adds config files +ADD root/ / + +# sets the working directory +# WORKDIR $WEBHOME + +################################################################################ \ No newline at end of file diff --git a/src/webapps/kirby/README.md b/src/webapps/kirby/README.md new file mode 100644 index 00000000..d86bb126 --- /dev/null +++ b/src/webapps/kirby/README.md @@ -0,0 +1,226 @@ +# shinsenter/kirby + +πŸ”° (PHP) Kirby CMS Docker images for development and production. + +> πŸ”— https://docker.shin.company/kirby + +> πŸš€ `shinsenter/kirby` is also available in [smaller minified version](https://docker.shin.company/kirby/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/kirby)](https://docker.shin.company/kirby) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/kirby/latest?label=shinsenter%2Fkirby)](https://docker.shin.company/kirby) + +* * * + +## About this project + +πŸ”° (PHP) Kirby CMS Docker images for development and production. These images are actively maintained. + +Creating website using the Kirby CMS framework with ease. + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). + +> Kirby is a CMS that adapts to any project, loved by developers and editors alike. More information can be found at their [official website](https://getkirby.com). + +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. + +## Usage + +### Docker Pull command + +```bash +docker pull shinsenter/kirby:latest +``` + +or + +```bash +docker pull shinsenter/kirby:php${PHP_VERSION} +``` + +or + +```bash +docker pull shinsenter/kirby:php${PHP_VERSION}-tidy +``` + +> View more image tags at [shinsenter/kirby/tags](https://docker.shin.company/kirby/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. + +```Dockerfile +ENV WEBHOME="/var/www/html" +``` + +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. + +> Sometimes you may wish to change the default document root (away from `/var/www/html`), please consider changing the `$WEBHOME` value. + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod +``` + +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/kirby +``` + +For example: + +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/kirby composer dump-autoload +``` + +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). + +```Dockerfile +ARG PHP_VERSION=8.1 +FROM shinsenter/kirby:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== + +# Control your timezone +ENV TZ="UTC" + +# sets GID and UID +ENV PUID=9999 +ENV PGID=9999 + +# sets web server root path +ENV WEBHOME="/var/www/html" + +# ========================================================== + +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/kirby:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + ports: + - "80:80" + - "443:443" + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: my_database + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. + +```bash +docker-compose up -d +``` + +## Supported platforms + +Currently, the supported architectures are: + +- linux/amd64 +- linux/arm/v7 +- linux/arm64/v8 +- linux/ppc64le + +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/webapps/kirby/root/startup/500-init-kirby b/src/webapps/kirby/root/startup/500-init-kirby new file mode 100755 index 00000000..4a2462ad --- /dev/null +++ b/src/webapps/kirby/root/startup/500-init-kirby @@ -0,0 +1,11 @@ +#!/command/with-contenv bash +KIRBY_PROJECT="${KIRBY_PROJECT:-getkirby/starterkit}" +KIRBY_ROOT="$(webhome)" +KIRBY_CHECK="$KIRBY_ROOT/kirby" + +if [ ! -d "$KIRBY_CHECK" ]; then + echo; echo "πŸ€– Installing $KIRBY_PROJECT from scratch" + rm -rf $KIRBY_ROOT/web $KIRBY_ROOT/index.* + wdo composer-create -d $KIRBY_ROOT/ $KIRBY_PROJECT $KIRBY_ROOT/ + wmd $KIRBY_ROOT -R +fi \ No newline at end of file diff --git a/src/webapps/laminas/Dockerfile b/src/webapps/laminas/Dockerfile new file mode 100644 index 00000000..883e0e12 --- /dev/null +++ b/src/webapps/laminas/Dockerfile @@ -0,0 +1,26 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +ARG BASE_IMAGE=shinsenter/phpfpm-apache +ARG IMAGE_SUFFIX="-tidy" +ARG PHP_VERSION=8.1 + +################################################################################ + +# base image +FROM ${BASE_IMAGE}:php${PHP_VERSION}${IMAGE_SUFFIX} + +# sets web server root path +ENV APACHE_DOCUMENT_ROOT="/public" + +################################################################################ + +# adds config files +ADD root/ / + +# sets the working directory +# WORKDIR $WEBHOME + +################################################################################ \ No newline at end of file diff --git a/src/webapps/laminas/README.md b/src/webapps/laminas/README.md new file mode 100644 index 00000000..a2b79895 --- /dev/null +++ b/src/webapps/laminas/README.md @@ -0,0 +1,226 @@ +# shinsenter/laminas + +πŸ”° (PHP) Laminas Docker images for development and production. + +> πŸ”— https://docker.shin.company/laminas + +> πŸš€ `shinsenter/laminas` is also available in [smaller minified version](https://docker.shin.company/laminas/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/laminas)](https://docker.shin.company/laminas) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/laminas/latest?label=shinsenter%2Flaminas)](https://docker.shin.company/laminas) + +* * * + +## About this project + +πŸ”° (PHP) Laminas Docker images for development and production. These images are actively maintained. + +Creating application using the Laminas framework with ease. + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). + +> Laminas is a community-supported, open source continuation of Zend Framework. More information can be found at their [official website](https://getlaminas.org). + +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. + +## Usage + +### Docker Pull command + +```bash +docker pull shinsenter/laminas:latest +``` + +or + +```bash +docker pull shinsenter/laminas:php${PHP_VERSION} +``` + +or + +```bash +docker pull shinsenter/laminas:php${PHP_VERSION}-tidy +``` + +> View more image tags at [shinsenter/laminas/tags](https://docker.shin.company/laminas/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. + +```Dockerfile +ENV WEBHOME="/var/www/html" +``` + +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. + +> Sometimes you may wish to change the default document root (away from `/var/www/html`), please consider changing the `$WEBHOME` value. + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod +``` + +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/laminas +``` + +For example: + +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/laminas composer dump-autoload +``` + +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). + +```Dockerfile +ARG PHP_VERSION=8.1 +FROM shinsenter/laminas:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== + +# Control your timezone +ENV TZ="UTC" + +# sets GID and UID +ENV PUID=9999 +ENV PGID=9999 + +# sets web server root path +ENV WEBHOME="/var/www/html" + +# ========================================================== + +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/laminas:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + ports: + - "80:80" + - "443:443" + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: my_database + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. + +```bash +docker-compose up -d +``` + +## Supported platforms + +Currently, the supported architectures are: + +- linux/amd64 +- linux/arm/v7 +- linux/arm64/v8 +- linux/ppc64le + +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/webapps/laminas/root/startup/500-init-laminas b/src/webapps/laminas/root/startup/500-init-laminas new file mode 100755 index 00000000..1958c783 --- /dev/null +++ b/src/webapps/laminas/root/startup/500-init-laminas @@ -0,0 +1,11 @@ +#!/command/with-contenv bash +ZEND_PROJECT="${ZEND_PROJECT:-laminas/laminas-mvc-skeleton}" +ZEND_ROOT="$(webhome)" +ZEND_CHECK="$ZEND_ROOT/module/Application" + +if [ ! -d "$ZEND_CHECK" ]; then + echo; echo "πŸ€– Installing $ZEND_PROJECT from scratch" + rm -rf $ZEND_ROOT/public $ZEND_ROOT/index.* + wdo composer-create -s dev -d $ZEND_ROOT/ $ZEND_PROJECT $ZEND_ROOT/ + wmd $ZEND_ROOT -R +fi \ No newline at end of file diff --git a/src/webapps/laravel/Dockerfile b/src/webapps/laravel/Dockerfile index 2057fbf5..2a8de402 100644 --- a/src/webapps/laravel/Dockerfile +++ b/src/webapps/laravel/Dockerfile @@ -1,33 +1,38 @@ -# This file is the work of https://github.com/shinsenter/php +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE ################################################################################ ARG BASE_IMAGE=shinsenter/phpfpm-nginx +ARG IMAGE_SUFFIX="-tidy" ARG PHP_VERSION=8.1 ################################################################################ -# base image and platform -FROM ${BASE_IMAGE}:php${PHP_VERSION} +# base image +FROM ${BASE_IMAGE}:php${PHP_VERSION}${IMAGE_SUFFIX} -# installs php-swoole -RUN apt-update && apt-install php${PHP_VERSION}-swoole \ - && apt-cleanup +# sets web server root path +ENV NGINX_DOCUMENT_ROOT="/public" + +################################################################################ # adds config files ADD root/ / -# sets web server root path -ENV WEBHOME="/var/www/html" -ENV NGINX_DOCUMENT_ROOT="/public" - # sets the working directory -WORKDIR $WEBHOME +# WORKDIR $WEBHOME ################################################################################ # set more env variables +ENV ENABLE_CRONTAB=true +ENV LARAVEL_AUTO_MIGRATION=false ENV LARAVEL_AUTO_OPTIMIZE=true ENV LARAVEL_LINK_STORAGE=true -ENV LARAVEL_AUTO_MIGRATION=false +ENV LARAVEL_QUEUE_OPTIONS= +ENV LARAVEL_QUEUE_ENABLED=false +ENV LARAVEL_SCHEDULE_OPTIONS= +ENV LARAVEL_SCHEDULE_ENABLED=false ################################################################################ \ No newline at end of file diff --git a/src/webapps/laravel/README.md b/src/webapps/laravel/README.md index 4f771680..61ef9eb4 100644 --- a/src/webapps/laravel/README.md +++ b/src/webapps/laravel/README.md @@ -1,51 +1,145 @@ # shinsenter/laravel -Start creating beautiful Laravel websites with ease. Powered by shinsenter/php. +πŸ”° (PHP) Laravel Docker images for development and production. -https://hub.docker.com/r/shinsenter/laravel +> πŸ”— https://docker.shin.company/laravel -[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/laravel)](https://hub.docker.com/r/shinsenter/laravel) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/laravel/latest?label=shinsenter%2Flaravel)](https://hub.docker.com/r/shinsenter/laravel/tags) +> πŸš€ `shinsenter/laravel` is also available in [smaller minified version](https://docker.shin.company/laravel/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/laravel)](https://docker.shin.company/laravel) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/laravel/latest?label=shinsenter%2Flaravel)](https://docker.shin.company/laravel) * * * ## About this project -Start creating beautiful Laravel websites with ease. +πŸ”° (PHP) Laravel Docker images for development and production. These images are actively maintained. + +Creating application using the Laravel framework with ease. + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). + +> Laravel is a web application framework with expressive, elegant syntax. Laravel takes the pain out of development by easing common tasks used in many web projects. More information can be found at their [official website](https://laravel.com). + +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. -Powered by [shinsenter/php](https://hub.docker.com/r/shinsenter/php). ## Usage ### Docker Pull command ```bash -docker pull shinsenter/laravel +docker pull shinsenter/laravel:latest ``` -### Docker Compose example +or -```yml -version: '3' -services: - my-container: - image: shinsenter/laravel:latest - volumes: - - ./my-website:/var/www/html - environment: - TZ: UTC - ports: - - "80:80" - - "443:443" +```bash +docker pull shinsenter/laravel:php${PHP_VERSION} +``` + +or + +```bash +docker pull shinsenter/laravel:php${PHP_VERSION}-tidy +``` + +> View more image tags at [shinsenter/laravel/tags](https://docker.shin.company/laravel/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. + +```Dockerfile +ENV WEBHOME="/var/www/html" +``` + +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. + +> Sometimes you may wish to change the default document root (away from `/var/www/html`), please consider changing the `$WEBHOME` value. + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod +``` + +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/laravel ``` -View more image tags at [shinsenter/laravel/tags](https://hub.docker.com/r/shinsenter/laravel/tags). +For example: -## Customize your own image +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/laravel composer dump-autoload +``` -Dockerfile example for building your own Docker image extending this image. +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). ```Dockerfile -FROM shinsenter/laravel +ARG PHP_VERSION=8.1 +FROM shinsenter/laravel:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== # Control your timezone ENV TZ="UTC" @@ -57,11 +151,13 @@ ENV PGID=9999 # sets web server root path ENV WEBHOME="/var/www/html" -# sets the working directory -WORKDIR $WEBHOME - # ========================================================== +# The project name to be pulled by "composer create-project" +# Default: ENV LARAVEL_PROJECT="laravel/laravel" +# Example: ENV LARAVEL_PROJECT="phanan/koel" +ENV LARAVEL_PROJECT="laravel/laravel" + # Optimize and cache all config, views, routes ENV LARAVEL_AUTO_OPTIMIZE=true @@ -71,13 +167,89 @@ ENV LARAVEL_LINK_STORAGE=true # Run Laravel migrations (for development purposese) ENV LARAVEL_AUTO_MIGRATION=false +# Auto start artisan queue:work when container is up +ENV LARAVEL_QUEUE_ENABLED=false + +# Extra arguments for artisan queue:work +# Example: ENV LARAVEL_QUEUE_OPTIONS="--timeout=10 --tries=3 redis" +ENV LARAVEL_QUEUE_OPTIONS= + +# Auto start artisan schedule:work when container is up +ENV LARAVEL_SCHEDULE_ENABLED=false + +# Extra arguments for artisan schedule:work +ENV LARAVEL_SCHEDULE_OPTIONS= + # ========================================================== -# Please check https://hub.docker.com/r/shinsenter/php -# for more details of PHP environment variables. +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` -# Please check https://hub.docker.com/r/shinsenter/phpfpm-nginx -# for more details of Nginx environment variables. +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/laravel:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + REDIS_HOST: redis + DB_HOST: mysql + DB_DATABASE: laravel + DB_USERNAME: root + DB_PASSWORD: mydb_p@ssw0rd + # LARAVEL_QUEUE_ENABLED: true + # LARAVEL_QUEUE_OPTIONS: --timeout=60 --tries=3 redis + # LARAVEL_SCHEDULE_ENABLED: true + ports: + - "80:80" + - "443:443" + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: laravel + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. + +```bash +docker-compose up -d ``` ## Supported platforms @@ -86,7 +258,7 @@ Currently, the supported architectures are: - linux/amd64 - linux/arm/v7 -- linux/arm64 +- linux/arm64/v8 - linux/ppc64le -You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/webapps/laravel/root/etc/cont-init.d/300-schedule b/src/webapps/laravel/root/etc/cont-init.d/300-schedule new file mode 100755 index 00000000..778d0ea4 --- /dev/null +++ b/src/webapps/laravel/root/etc/cont-init.d/300-schedule @@ -0,0 +1,4 @@ +#!/command/with-contenv bash +if [ "$LARAVEL_SCHEDULE_ENABLED" != "true" ]; then + rm -rf /etc/cron.d/*-schedule +fi \ No newline at end of file diff --git a/src/webapps/laravel/root/etc/cont-init.d/500-boot-laravel b/src/webapps/laravel/root/etc/cont-init.d/500-boot-laravel deleted file mode 100755 index d4e7718e..00000000 --- a/src/webapps/laravel/root/etc/cont-init.d/500-boot-laravel +++ /dev/null @@ -1,41 +0,0 @@ -#!/command/with-contenv bash - -LARAVEL_ROOT="${WEBHOME:-/var/www/html}" -LARAVEL_ARTISAN="$LARAVEL_ROOT/artisan" - -webuser-mkdir $LARAVEL_ROOT - -if [ ! -f "$LARAVEL_ARTISAN" ]; then - rm -rf $LARAVEL_ROOT/public $LARAVEL_ROOT/index.* - - echo "πŸ€– Installing Laravel from scratch..." - dirty - composer create-project \ - laravel/laravel $LARAVEL_ROOT/ \ - --ansi \ - --no-cache \ - --no-dev \ - --no-interaction -fi - -silent_artisan () { - php $LARAVEL_ARTISAN --ansi $@ 2>/dev/null -} - -if [ -f "$LARAVEL_ARTISAN" ]; then - if [ "$LARAVEL_AUTO_OPTIMIZE" == "true" ]; then - dirty - silent_artisan optimize:clear - silent_artisan optimize - fi - - if [ "$LARAVEL_LINK_STORAGE" == "true" ]; then - dirty - silent_artisan storage:link - fi - - if [ "$LARAVEL_AUTO_MIGRATION" == "true" ]; then - dirty - silent_artisan migrate:refresh --seed --force - fi -fi diff --git a/src/webapps/laravel/root/etc/cron.d/laravel-schedule b/src/webapps/laravel/root/etc/cron.d/laravel-schedule new file mode 100644 index 00000000..7d39d444 --- /dev/null +++ b/src/webapps/laravel/root/etc/cron.d/laravel-schedule @@ -0,0 +1,3 @@ +MAILTO="" +SHELL=/bin/bash +* * * * * webuser /usr/bin/artisan schedule:run $LARAVEL_SCHEDULE_OPTIONS >/proc/1/fd/1 2>/proc/1/fd/2 diff --git a/src/webapps/laravel/root/etc/services.d/300-queue/run b/src/webapps/laravel/root/etc/services.d/300-queue/run new file mode 100755 index 00000000..119cc327 --- /dev/null +++ b/src/webapps/laravel/root/etc/services.d/300-queue/run @@ -0,0 +1,8 @@ +#!/command/with-contenv bash +if [ "$LARAVEL_QUEUE_ENABLED" == "true" ]; then + composer-wait + echo; echo "πŸ€– Starting Laravel queue:work $LARAVEL_QUEUE_OPTIONS" + exec wdo artisan queue:work $LARAVEL_QUEUE_OPTIONS +else + exec s6-svc -Od . +fi \ No newline at end of file diff --git a/src/webapps/laravel/root/startup/500-init-laravel b/src/webapps/laravel/root/startup/500-init-laravel new file mode 100755 index 00000000..b10cdac5 --- /dev/null +++ b/src/webapps/laravel/root/startup/500-init-laravel @@ -0,0 +1,39 @@ +#!/command/with-contenv bash +LARAVEL_PROJECT="${LARAVEL_PROJECT:-laravel/laravel}" +LARAVEL_ROOT="$(webhome)" +LARAVEL_ARTISAN="$LARAVEL_ROOT/artisan" + +if [ ! -f "$LARAVEL_ARTISAN" ]; then + echo; echo "πŸ€– Installing $LARAVEL_PROJECT from scratch" + rm -rf $LARAVEL_ROOT/public $LARAVEL_ROOT/index.* + wdo composer-create -d $LARAVEL_ROOT/ $LARAVEL_PROJECT $LARAVEL_ROOT/ + wmd $LARAVEL_ROOT -R +fi + +if [ -f "$LARAVEL_ARTISAN" ]; then + composer-wait + las() { echo; wdo php $LARAVEL_ARTISAN --ansi "$@" 2>/dev/null; } + + if [ ! -f "$LARAVEL_ROOT/.env" ] && [ ! -f "$LARAVEL_ROOT/.env.${APP_ENV}" ]; then + wdo cp -rpf "$LARAVEL_ROOT/.env.example" "$LARAVEL_ROOT/.env" + las key:generate + fi + + if [ "$LARAVEL_AUTO_OPTIMIZE" == "true" ]; then + las optimize:clear + las optimize + las vendor:publish --all + wmd $LARAVEL_ROOT/bootstrap/cache -R + wmd $LARAVEL_ROOT/storage -R + fi + + if [ "$LARAVEL_LINK_STORAGE" == "true" ]; then + las storage:link + wmd $LARAVEL_ROOT/storage/app/public -R + wmd $LARAVEL_ROOT/public -R + fi + + if [ "$LARAVEL_AUTO_MIGRATION" == "true" ]; then + las migrate:refresh --seed --force + fi +fi \ No newline at end of file diff --git a/src/webapps/laravel/root/usr/bin/artisan b/src/webapps/laravel/root/usr/bin/artisan index 99bb5317..462f6114 100755 --- a/src/webapps/laravel/root/usr/bin/artisan +++ b/src/webapps/laravel/root/usr/bin/artisan @@ -1,8 +1,7 @@ #!/bin/bash - -LARAVEL_ROOT="${WEBHOME:-/var/www/html}" +LARAVEL_ROOT="$(webhome)" LARAVEL_ARTISAN="$LARAVEL_ROOT/artisan" - if [ -f "$LARAVEL_ARTISAN" ]; then - sudo -u webuser -i -- /usr/bin/php $LARAVEL_ARTISAN $@ + cd $LARAVEL_ROOT + exec php $LARAVEL_ARTISAN --ansi "$@" fi \ No newline at end of file diff --git a/src/webapps/phpmyadmin/Dockerfile b/src/webapps/phpmyadmin/Dockerfile index 1d12a2ed..c6660b3e 100644 --- a/src/webapps/phpmyadmin/Dockerfile +++ b/src/webapps/phpmyadmin/Dockerfile @@ -1,23 +1,27 @@ -# This file is the work of https://github.com/shinsenter/php +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE ################################################################################ ARG BASE_IMAGE=shinsenter/phpfpm-nginx +ARG IMAGE_SUFFIX="-tidy" ARG PHP_VERSION=8.1 ################################################################################ -# base image and platform -FROM ${BASE_IMAGE}:php${PHP_VERSION} - -# adds config files -ADD root/ / +# base image +FROM ${BASE_IMAGE}:php${PHP_VERSION}${IMAGE_SUFFIX} # sets web server root path -ENV WEBHOME="/var/www/html" ENV NGINX_DOCUMENT_ROOT="" +################################################################################ + +# adds config files +ADD root/ / + # sets the working directory -WORKDIR $WEBHOME +# WORKDIR $WEBHOME ################################################################################ @@ -30,22 +34,34 @@ ENV PHP_UPLOAD_MAX_FILE_SIZE=2G # phpmyadmin settings ENV PMA_ARBITRARY=1 ENV PMA_HOST=mysql -# ENV PMA_HOSTS= -# ENV PMA_VERBOSE= -# ENV PMA_VERBOSES= -# ENV PMA_PORT= -# ENV PMA_PORTS= -# ENV PMA_SOCKET= -# ENV PMA_SOCKETS= -# ENV PMA_USER= -# ENV PMA_PASSWORD= # ENV PMA_ABSOLUTE_URI= +# ENV PMA_ARBITRARY= +# ENV PMA_BLOWFISH_SECRET= # ENV PMA_CONTROLHOST= +# ENV PMA_CONTROLPASS= # ENV PMA_CONTROLPORT= -# ENV PMA_PMADB= # ENV PMA_CONTROLUSER= -# ENV PMA_CONTROLPASS= +# ENV PMA_DEFAULTLANG= +# ENV PMA_HOST= +# ENV PMA_HOSTS= +# ENV PMA_MAXROWS= +# ENV PMA_PASSWORD= +# ENV PMA_PMADB= +# ENV PMA_PORT= +# ENV PMA_PORTS= +# ENV PMA_PROPERTIESNUMCOLUMNS= +# ENV PMA_PROTECTBINARY= # ENV PMA_QUERYHISTORYDB= # ENV PMA_QUERYHISTORYMAX= +# ENV PMA_ROWACTIONTYPE= +# ENV PMA_SENDERRORREPORTS= +# ENV PMA_SHOWALL= +# ENV PMA_SOCKET= +# ENV PMA_SOCKETS= +# ENV PMA_URLQUERYENCRYPTION= +# ENV PMA_URLQUERYENCRYPTIONSECRETKEY= +# ENV PMA_USER= +# ENV PMA_VERBOSE= +# ENV PMA_VERBOSES= ################################################################################ \ No newline at end of file diff --git a/src/webapps/phpmyadmin/README.md b/src/webapps/phpmyadmin/README.md index 14efc080..8beca224 100644 --- a/src/webapps/phpmyadmin/README.md +++ b/src/webapps/phpmyadmin/README.md @@ -1,51 +1,144 @@ # shinsenter/phpmyadmin -The World's smallest Ubuntu-based Docker image for phpMyAdmin. Powered by shinsenter/php. +πŸ”° (PHP) phpMyAdmin Docker images for development and production. -https://hub.docker.com/r/shinsenter/phpmyadmin +> πŸ”— https://docker.shin.company/phpmyadmin -[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/phpmyadmin)](https://hub.docker.com/r/shinsenter/phpmyadmin) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/phpmyadmin/latest?label=shinsenter%2Fphpmyadmin)](https://hub.docker.com/r/shinsenter/phpmyadmin/tags) +> πŸš€ `shinsenter/phpmyadmin` is also available in [smaller minified version](https://docker.shin.company/phpmyadmin/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/phpmyadmin)](https://docker.shin.company/phpmyadmin) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/phpmyadmin/latest?label=shinsenter%2Fphpmyadmin)](https://docker.shin.company/phpmyadmin) * * * ## About this project +πŸ”° (PHP) phpMyAdmin Docker images for development and production. These images are actively maintained. + The World's smallest Ubuntu-based Docker image for phpMyAdmin. -Powered by [shinsenter/php](https://hub.docker.com/r/shinsenter/php). +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). + +> phpMyAdmin is intended to handle the administration of MySQL over the web. More information can be found at their [official website](https://www.phpmyadmin.net). + +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. ## Usage ### Docker Pull command ```bash -docker pull shinsenter/phpmyadmin +docker pull shinsenter/phpmyadmin:latest ``` -### Docker Compose example +or -```yml -version: '3' -services: - my-container: - image: shinsenter/phpmyadmin:latest - volumes: - - ./my-website:/var/www/html - environment: - TZ: UTC - ports: - - "80:80" - - "443:443" +```bash +docker pull shinsenter/phpmyadmin:php${PHP_VERSION} +``` + +or + +```bash +docker pull shinsenter/phpmyadmin:php${PHP_VERSION}-tidy +``` + +> View more image tags at [shinsenter/phpmyadmin/tags](https://docker.shin.company/phpmyadmin/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. + +```Dockerfile +ENV WEBHOME="/var/www/html" +``` + +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. + +> Sometimes you may wish to change the default document root (away from `/var/www/html`), please consider changing the `$WEBHOME` value. + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod +``` + +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/phpmyadmin +``` + +For example: + +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/phpmyadmin composer dump-autoload ``` -View more image tags at [shinsenter/phpmyadmin/tags](https://hub.docker.com/r/shinsenter/phpmyadmin/tags). +## Customize Docker image -## Customize your own image +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. -Dockerfile example for building your own Docker image extending this image. +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). ```Dockerfile -FROM shinsenter/phpmyadmin +ARG PHP_VERSION=8.0 +FROM shinsenter/phpmyadmin:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== # Control your timezone ENV TZ="UTC" @@ -57,32 +150,38 @@ ENV PGID=9999 # sets web server root path ENV WEBHOME="/var/www/html" -# sets the working directory -WORKDIR $WEBHOME - # ========================================================== ENV PMA_HOST=mysql -ENV PMA_USER= -ENV PMA_PASSWORD= - -# ENV PMA_ARBITRARY=1 -# ENV PMA_HOSTS= -# ENV PMA_VERBOSE= -# ENV PMA_VERBOSES= +# ENV PMA_USER= +# ENV PMA_PASSWORD= # ENV PMA_PORT= -# ENV PMA_PORTS= +# ENV PMA_PMADB= # ENV PMA_SOCKET= -# ENV PMA_SOCKETS= +# ENV PMA_VERBOSE= # ENV PMA_ABSOLUTE_URI= +# ENV PMA_ARBITRARY= +# ENV PMA_BLOWFISH_SECRET= # ENV PMA_CONTROLHOST= +# ENV PMA_CONTROLPASS= # ENV PMA_CONTROLPORT= -# ENV PMA_PMADB= # ENV PMA_CONTROLUSER= -# ENV PMA_CONTROLPASS= +# ENV PMA_DEFAULTLANG= +# ENV PMA_HOSTS= +# ENV PMA_PORTS= +# ENV PMA_SOCKETS= +# ENV PMA_VERBOSES= +# ENV PMA_MAXROWS= +# ENV PMA_PROPERTIESNUMCOLUMNS= +# ENV PMA_PROTECTBINARY= # ENV PMA_QUERYHISTORYDB= # ENV PMA_QUERYHISTORYMAX= +# ENV PMA_ROWACTIONTYPE= +# ENV PMA_SENDERRORREPORTS= +# ENV PMA_SHOWALL= +# ENV PMA_URLQUERYENCRYPTION= +# ENV PMA_URLQUERYENCRYPTIONSECRETKEY= # ========================================================== @@ -92,11 +191,64 @@ ENV PHP_MEMORY_LIMIT=512M ENV PHP_POST_MAX_SIZE=2G ENV PHP_UPLOAD_MAX_FILE_SIZE=2G -# Please check https://hub.docker.com/r/shinsenter/php -# for more details of PHP environment variables. +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` -# Please check https://hub.docker.com/r/shinsenter/phpfpm-nginx -# for more details of Nginx environment variables. +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/phpmyadmin:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + PMA_HOST: mysql + PMA_USER: root + PMA_PASSWORD: mydb_p@ssw0rd + ports: + - "80:80" + - "443:443" + links: + - mysql + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: my_database + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" +``` + +Then run below command to start containers. + +```bash +docker-compose up -d ``` ## Supported platforms @@ -105,7 +257,7 @@ Currently, the supported architectures are: - linux/amd64 - linux/arm/v7 -- linux/arm64 +- linux/arm64/v8 - linux/ppc64le -You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/webapps/phpmyadmin/root/etc/cont-init.d/500-boot-phpmyadmin b/src/webapps/phpmyadmin/root/etc/cont-init.d/500-boot-phpmyadmin deleted file mode 100755 index 3b14c4e1..00000000 --- a/src/webapps/phpmyadmin/root/etc/cont-init.d/500-boot-phpmyadmin +++ /dev/null @@ -1,46 +0,0 @@ -#!/command/with-contenv bash - -PMA_ROOT="${WEBHOME:-/var/www/html}" -PMA_CONFIG="$PMA_ROOT/user-config" - -if [ ! -d "$PMA_ROOT/user-config" ]; then - rm -f $PMA_ROOT/index.* - - echo "πŸ€– Installing PHPMyAdmin from scratch..." - dirty - composer create-project \ - phpmyadmin/phpmyadmin $PMA_ROOT \ - --ansi \ - --no-cache \ - --no-dev \ - --no-interaction \ - --no-plugins \ - --no-scripts \ - --no-install \ - --repository-url='https://www.phpmyadmin.net/packages.json' - - rm -rf \ - $PMA_ROOT/babel.config.json \ - $PMA_ROOT/CONTRIBUTING.md \ - $PMA_ROOT/doc/html/_sources/ \ - $PMA_ROOT/examples/ \ - $PMA_ROOT/js/src/ \ - $PMA_ROOT/README.md \ - $PMA_ROOT/RELEASE-DATE-* \ - $PMA_ROOT/setup/ \ - $PMA_ROOT/templates/test/ \ - $PMA_ROOT/composer.lock \ - $PMA_ROOT/vendor - - webuser-mkdir $PMA_ROOT/tmp/upload - webuser-mkdir $PMA_ROOT/tmp/save - webuser-mkdir $PMA_CONFIG - - if [ ! -f "$PMA_CONFIG/config.inc.php" ]; then - cp -p /etc/phpmyadmin/config.inc.php $PMA_CONFIG/config.inc.php - chmod 0600 $PMA_CONFIG/* - fi - - sed -i "s@define('CONFIG_DIR'.*@define('CONFIG_DIR', '${PMA_CONFIG}/');@" \ - $PMA_ROOT/libraries/vendor_config.php -fi \ No newline at end of file diff --git a/src/webapps/phpmyadmin/root/etc/phpmyadmin/config.inc.php b/src/webapps/phpmyadmin/root/etc/phpmyadmin/config.inc.php index e8f12fcc..8beb39b2 100644 --- a/src/webapps/phpmyadmin/root/etc/phpmyadmin/config.inc.php +++ b/src/webapps/phpmyadmin/root/etc/phpmyadmin/config.inc.php @@ -1,30 +1,41 @@ '${PMA_CONFIG}',@" \ + $PMA_ROOT/libraries/vendor_config.php + fi +fi \ No newline at end of file diff --git a/src/webapps/slim/Dockerfile b/src/webapps/slim/Dockerfile new file mode 100644 index 00000000..883e0e12 --- /dev/null +++ b/src/webapps/slim/Dockerfile @@ -0,0 +1,26 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +ARG BASE_IMAGE=shinsenter/phpfpm-apache +ARG IMAGE_SUFFIX="-tidy" +ARG PHP_VERSION=8.1 + +################################################################################ + +# base image +FROM ${BASE_IMAGE}:php${PHP_VERSION}${IMAGE_SUFFIX} + +# sets web server root path +ENV APACHE_DOCUMENT_ROOT="/public" + +################################################################################ + +# adds config files +ADD root/ / + +# sets the working directory +# WORKDIR $WEBHOME + +################################################################################ \ No newline at end of file diff --git a/src/webapps/slim/README.md b/src/webapps/slim/README.md new file mode 100644 index 00000000..e9c9fbf3 --- /dev/null +++ b/src/webapps/slim/README.md @@ -0,0 +1,226 @@ +# shinsenter/slim + +πŸ”° (PHP) Slim framework Docker images for development and production. + +> πŸ”— https://docker.shin.company/slim + +> πŸš€ `shinsenter/slim` is also available in [smaller minified version](https://docker.shin.company/slim/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/slim)](https://docker.shin.company/slim) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/slim/latest?label=shinsenter%2Fslim)](https://docker.shin.company/slim) + +* * * + +## About this project + +πŸ”° (PHP) Slim framework Docker images for development and production. These images are actively maintained. + +Creating application using the Slim framework with ease. + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). + +> Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs. More information can be found at their [official website](https://www.slimframework.com). + +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. + +## Usage + +### Docker Pull command + +```bash +docker pull shinsenter/slim:latest +``` + +or + +```bash +docker pull shinsenter/slim:php${PHP_VERSION} +``` + +or + +```bash +docker pull shinsenter/slim:php${PHP_VERSION}-tidy +``` + +> View more image tags at [shinsenter/slim/tags](https://docker.shin.company/slim/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. + +```Dockerfile +ENV WEBHOME="/var/www/html" +``` + +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. + +> Sometimes you may wish to change the default document root (away from `/var/www/html`), please consider changing the `$WEBHOME` value. + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod +``` + +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/slim +``` + +For example: + +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/slim composer dump-autoload +``` + +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). + +```Dockerfile +ARG PHP_VERSION=8.1 +FROM shinsenter/slim:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== + +# Control your timezone +ENV TZ="UTC" + +# sets GID and UID +ENV PUID=9999 +ENV PGID=9999 + +# sets web server root path +ENV WEBHOME="/var/www/html" + +# ========================================================== + +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/slim:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + ports: + - "80:80" + - "443:443" + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: my_database + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. + +```bash +docker-compose up -d +``` + +## Supported platforms + +Currently, the supported architectures are: + +- linux/amd64 +- linux/arm/v7 +- linux/arm64/v8 +- linux/ppc64le + +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/webapps/slim/root/startup/500-init-slim b/src/webapps/slim/root/startup/500-init-slim new file mode 100755 index 00000000..69de577a --- /dev/null +++ b/src/webapps/slim/root/startup/500-init-slim @@ -0,0 +1,11 @@ +#!/command/with-contenv bash +SLIM_PROJECT="${SLIM_PROJECT:-slim/slim-skeleton}" +SLIM_ROOT="$(webhome)" +SLIM_CHECK="$SLIM_ROOT/src/Application" + +if [ ! -d "$SLIM_CHECK" ]; then + echo; echo "πŸ€– Installing $SLIM_PROJECT from scratch" + rm -rf $SLIM_ROOT/public $SLIM_ROOT/index.* + wdo composer-create -d $SLIM_ROOT/ $SLIM_PROJECT $SLIM_ROOT/ + wmd $SLIM_ROOT -R +fi \ No newline at end of file diff --git a/src/webapps/statamic/Dockerfile b/src/webapps/statamic/Dockerfile new file mode 100644 index 00000000..12509c53 --- /dev/null +++ b/src/webapps/statamic/Dockerfile @@ -0,0 +1,38 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +ARG BASE_IMAGE=shinsenter/phpfpm-nginx +ARG IMAGE_SUFFIX="-tidy" +ARG PHP_VERSION=8.1 + +################################################################################ + +# base image +FROM ${BASE_IMAGE}:php${PHP_VERSION}${IMAGE_SUFFIX} + +# sets web server root path +ENV NGINX_DOCUMENT_ROOT="/public" + +################################################################################ + +# adds config files +ADD root/ / + +# sets the working directory +# WORKDIR $WEBHOME + +################################################################################ + +# set more env variables +ENV ENABLE_CRONTAB=true +ENV STATAMIC_AUTO_MIGRATION=false +ENV STATAMIC_AUTO_OPTIMIZE=true +ENV STATAMIC_LINK_STORAGE=true +ENV STATAMIC_QUEUE_OPTIONS= +ENV STATAMIC_QUEUE_ENABLED=false +ENV STATAMIC_SCHEDULE_OPTIONS= +ENV STATAMIC_SCHEDULE_ENABLED=false + +################################################################################ \ No newline at end of file diff --git a/src/webapps/statamic/README.md b/src/webapps/statamic/README.md new file mode 100644 index 00000000..39c868c9 --- /dev/null +++ b/src/webapps/statamic/README.md @@ -0,0 +1,259 @@ +# shinsenter/statamic + +πŸ”° (PHP) Statamic Docker images for development and production. + +> πŸ”— https://docker.shin.company/statamic + +> πŸš€ `shinsenter/statamic` is also available in [smaller minified version](https://docker.shin.company/statamic/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/statamic)](https://docker.shin.company/statamic) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/statamic/latest?label=shinsenter%2Fstatamic)](https://docker.shin.company/statamic) + +* * * + +## About this project + +πŸ”° (PHP) Statamic Docker images for development and production. These images are actively maintained. + +Creating application using the Statamic framework with ease. + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). + +> Statamic is an open source, flat-first, Laravel + Git powered CMS designed for building easy to manage websites. More information can be found at their [official website](https://statamic.dev). + +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. + + +## Usage + +### Docker Pull command + +```bash +docker pull shinsenter/statamic:latest +``` + +or + +```bash +docker pull shinsenter/statamic:php${PHP_VERSION} +``` + +or + +```bash +docker pull shinsenter/statamic:php${PHP_VERSION}-tidy +``` + +> View more image tags at [shinsenter/statamic/tags](https://docker.shin.company/statamic/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. + +```Dockerfile +ENV WEBHOME="/var/www/html" +``` + +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. + +> Sometimes you may wish to change the default document root (away from `/var/www/html`), please consider changing the `$WEBHOME` value. + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod +``` + +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/statamic +``` + +For example: + +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/statamic composer dump-autoload +``` + +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). + +```Dockerfile +ARG PHP_VERSION=8.1 +FROM shinsenter/statamic:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== + +# Control your timezone +ENV TZ="UTC" + +# sets GID and UID +ENV PUID=9999 +ENV PGID=9999 + +# sets web server root path +ENV WEBHOME="/var/www/html" + +# ========================================================== + +# Optimize and cache all config, views, routes +ENV STATAMIC_AUTO_OPTIMIZE=true + +# Create symlinks to the storage folder +ENV STATAMIC_LINK_STORAGE=true + +# Run Statamic migrations (for development purposese) +ENV STATAMIC_AUTO_MIGRATION=false + +# Auto start artisan queue:work when container is up +ENV STATAMIC_QUEUE_ENABLED=false + +# Extra arguments for artisan queue:work +# Example: ENV STATAMIC_QUEUE_OPTIONS="--timeout=10 --tries=3 redis" +ENV STATAMIC_QUEUE_OPTIONS= + +# Auto start artisan schedule:work when container is up +ENV STATAMIC_SCHEDULE_ENABLED=false + +# Extra arguments for artisan schedule:work +ENV STATAMIC_SCHEDULE_OPTIONS= + +# ========================================================== + +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/statamic:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + REDIS_HOST: redis + DB_HOST: mysql + DB_DATABASE: statamic + DB_USERNAME: root + DB_PASSWORD: mydb_p@ssw0rd + # STATAMIC_QUEUE_ENABLED: true + # STATAMIC_QUEUE_OPTIONS: --timeout=60 --tries=3 redis + # STATAMIC_SCHEDULE_ENABLED: true + ports: + - "80:80" + - "443:443" + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: statamic + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. + +```bash +docker-compose up -d +``` + +## Supported platforms + +Currently, the supported architectures are: + +- linux/amd64 +- linux/arm/v7 +- linux/arm64/v8 +- linux/ppc64le + +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/webapps/statamic/root/etc/cont-init.d/300-schedule b/src/webapps/statamic/root/etc/cont-init.d/300-schedule new file mode 100755 index 00000000..0a039a10 --- /dev/null +++ b/src/webapps/statamic/root/etc/cont-init.d/300-schedule @@ -0,0 +1,4 @@ +#!/command/with-contenv bash +if [ "$STATAMIC_SCHEDULE_ENABLED" != "true" ]; then + rm -rf /etc/cron.d/*-schedule +fi \ No newline at end of file diff --git a/src/webapps/statamic/root/etc/cron.d/statamic-schedule b/src/webapps/statamic/root/etc/cron.d/statamic-schedule new file mode 100644 index 00000000..eab8da97 --- /dev/null +++ b/src/webapps/statamic/root/etc/cron.d/statamic-schedule @@ -0,0 +1,3 @@ +MAILTO="" +SHELL=/bin/bash +* * * * * webuser /usr/bin/artisan schedule:run $STATAMIC_SCHEDULE_OPTIONS >/proc/1/fd/1 2>/proc/1/fd/2 diff --git a/src/webapps/statamic/root/etc/services.d/300-queue/run b/src/webapps/statamic/root/etc/services.d/300-queue/run new file mode 100755 index 00000000..14a91341 --- /dev/null +++ b/src/webapps/statamic/root/etc/services.d/300-queue/run @@ -0,0 +1,8 @@ +#!/command/with-contenv bash +if [ "$STATAMIC_QUEUE_ENABLED" == "true" ]; then + composer-wait + echo; echo "πŸ€– Starting Statamic queue:work $STATAMIC_QUEUE_OPTIONS" + exec wdo artisan queue:work $STATAMIC_QUEUE_OPTIONS +else + exec s6-svc -Od . +fi \ No newline at end of file diff --git a/src/webapps/statamic/root/startup/500-init-statamic b/src/webapps/statamic/root/startup/500-init-statamic new file mode 100755 index 00000000..22489e7e --- /dev/null +++ b/src/webapps/statamic/root/startup/500-init-statamic @@ -0,0 +1,41 @@ +#!/command/with-contenv bash +STATAMIC_PROJECT="${STATAMIC_PROJECT:-statamic/statamic}" +STATAMIC_ROOT="$(webhome)" +STATAMIC_BINARY="$STATAMIC_ROOT/please" +STATAMIC_ARTISAN="$STATAMIC_ROOT/artisan" + +if [ ! -f "$STATAMIC_BINARY" ]; then + echo; echo "πŸ€– Installing $STATAMIC_PROJECT from scratch" + rm -rf $STATAMIC_ROOT/public $STATAMIC_ROOT/index.* + wdo composer-create -d $STATAMIC_ROOT/ $STATAMIC_PROJECT $STATAMIC_ROOT/ + wdo please install + wmd $STATAMIC_ROOT -R +fi + +if [ -f "$STATAMIC_ARTISAN" ]; then + composer-wait + las() { echo; wdo php $STATAMIC_ARTISAN --ansi "$@" 2>/dev/null; } + + if [ ! -f "$STATAMIC_ROOT/.env" ] && [ ! -f "$STATAMIC_ROOT/.env.${APP_ENV}" ]; then + wdo cp -rpf "$STATAMIC_ROOT/.env.example" "$STATAMIC_ROOT/.env" + las key:generate + fi + + if [ "$STATAMIC_AUTO_OPTIMIZE" == "true" ]; then + las optimize:clear + las optimize + las vendor:publish --all + wmd $STATAMIC_ROOT/bootstrap/cache -R + wmd $STATAMIC_ROOT/storage -R + fi + + if [ "$STATAMIC_LINK_STORAGE" == "true" ]; then + las storage:link + wmd $STATAMIC_ROOT/storage/app/public -R + wmd $STATAMIC_ROOT/public -R + fi + + if [ "$STATAMIC_AUTO_MIGRATION" == "true" ]; then + las migrate:refresh --seed --force + fi +fi \ No newline at end of file diff --git a/src/webapps/statamic/root/usr/bin/artisan b/src/webapps/statamic/root/usr/bin/artisan new file mode 100755 index 00000000..191a48ad --- /dev/null +++ b/src/webapps/statamic/root/usr/bin/artisan @@ -0,0 +1,7 @@ +#!/bin/bash +STATAMIC_ROOT="$(webhome)" +STATAMIC_ARTISAN="$STATAMIC_ROOT/artisan" +if [ -f "$STATAMIC_ARTISAN" ]; then + cd $STATAMIC_ROOT + exec php $STATAMIC_ARTISAN --ansi "$@" +fi \ No newline at end of file diff --git a/src/webapps/statamic/root/usr/bin/please b/src/webapps/statamic/root/usr/bin/please new file mode 100755 index 00000000..f7db302e --- /dev/null +++ b/src/webapps/statamic/root/usr/bin/please @@ -0,0 +1,7 @@ +#!/bin/bash +STATAMIC_ROOT="$(webhome)" +STATAMIC_BINARY="$STATAMIC_ROOT/please" +if [ -f "$STATAMIC_BINARY" ]; then + cd $STATAMIC_ROOT + exec php $STATAMIC_BINARY --ansi "$@" +fi \ No newline at end of file diff --git a/src/webapps/symfony/Dockerfile b/src/webapps/symfony/Dockerfile index 5f16a1f3..e8cd7f27 100644 --- a/src/webapps/symfony/Dockerfile +++ b/src/webapps/symfony/Dockerfile @@ -1,23 +1,27 @@ -# This file is the work of https://github.com/shinsenter/php +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE ################################################################################ ARG BASE_IMAGE=shinsenter/phpfpm-nginx +ARG IMAGE_SUFFIX="-tidy" ARG PHP_VERSION=8.1 ################################################################################ -# base image and platform -FROM ${BASE_IMAGE}:php${PHP_VERSION} - -# adds config files -ADD root/ / +# base image +FROM ${BASE_IMAGE}:php${PHP_VERSION}${IMAGE_SUFFIX} # sets web server root path -ENV WEBHOME="/var/www/html" ENV NGINX_DOCUMENT_ROOT="/public" +################################################################################ + +# adds config files +ADD root/ / + # sets the working directory -WORKDIR $WEBHOME +# WORKDIR $WEBHOME ################################################################################ diff --git a/src/webapps/symfony/README.md b/src/webapps/symfony/README.md index b0b92f2c..78daf4e8 100644 --- a/src/webapps/symfony/README.md +++ b/src/webapps/symfony/README.md @@ -1,51 +1,144 @@ # shinsenter/symfony -Start creating beautiful Symfony websites with ease. Powered by shinsenter/php. +πŸ”° (PHP) Symfony Docker images for development and production. -https://hub.docker.com/r/shinsenter/symfony +> πŸ”— https://docker.shin.company/symfony -[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/symfony)](https://hub.docker.com/r/shinsenter/symfony) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/symfony/latest?label=shinsenter%2Fsymfony)](https://hub.docker.com/r/shinsenter/symfony/tags) +> πŸš€ `shinsenter/symfony` is also available in [smaller minified version](https://docker.shin.company/symfony/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/symfony)](https://docker.shin.company/symfony) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/symfony/latest?label=shinsenter%2Fsymfony)](https://docker.shin.company/symfony) * * * ## About this project -Start creating beautiful Symfony websites with ease. +πŸ”° (PHP) Symfony Docker images for development and production. These images are actively maintained. + +Creating application using the Symfony framework with ease. + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). -Powered by [shinsenter/php](https://hub.docker.com/r/shinsenter/php). +> Symfony is a set of reusable PHP components and a PHP framework to build web applications, APIs, microservices and web services. More information can be found at their [official website](https://symfony.com). + +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. ## Usage ### Docker Pull command ```bash -docker pull shinsenter/symfony +docker pull shinsenter/symfony:latest ``` -### Docker Compose example +or -```yml -version: '3' -services: - my-container: - image: shinsenter/symfony:latest - volumes: - - ./my-website:/var/www/html - environment: - TZ: UTC - ports: - - "80:80" - - "443:443" +```bash +docker pull shinsenter/symfony:php${PHP_VERSION} ``` -View more image tags at [shinsenter/symfony/tags](https://hub.docker.com/r/shinsenter/symfony/tags). +or -## Customize your own image +```bash +docker pull shinsenter/symfony:php${PHP_VERSION}-tidy +``` -Dockerfile example for building your own Docker image extending this image. +> View more image tags at [shinsenter/symfony/tags](https://docker.shin.company/symfony/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. ```Dockerfile -FROM shinsenter/symfony +ENV WEBHOME="/var/www/html" +``` + +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. + +> Sometimes you may wish to change the default document root (away from `/var/www/html`), please consider changing the `$WEBHOME` value. + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod +``` + +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/symfony +``` + +For example: + +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/symfony composer dump-autoload +``` + +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). + +```Dockerfile +ARG PHP_VERSION=8.1 +FROM shinsenter/symfony:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== # Control your timezone ENV TZ="UTC" @@ -57,21 +150,78 @@ ENV PGID=9999 # sets web server root path ENV WEBHOME="/var/www/html" -# sets the working directory -WORKDIR $WEBHOME - # ========================================================== +# The project name to be pulled by "composer create-project" +# Default: ENV SYMFONY_PROJECT="symfony/skeleton" +# Example: ENV SYMFONY_PROJECT="sylius/sylius-standard" +ENV SYMFONY_PROJECT="symfony/skeleton" + # Set to "true" to install packages for development purposes ENV SYMFONY_INSTALL_DEVKIT=false # ========================================================== -# Please check https://hub.docker.com/r/shinsenter/php -# for more details of PHP environment variables. +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/symfony:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + ports: + - "80:80" + - "443:443" + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: my_database + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. -# Please check https://hub.docker.com/r/shinsenter/phpfpm-nginx -# for more details of Nginx environment variables. +```bash +docker-compose up -d ``` ## Supported platforms @@ -80,7 +230,7 @@ Currently, the supported architectures are: - linux/amd64 - linux/arm/v7 -- linux/arm64 +- linux/arm64/v8 - linux/ppc64le -You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/webapps/symfony/root/etc/cont-init.d/500-boot-symfony b/src/webapps/symfony/root/etc/cont-init.d/500-boot-symfony deleted file mode 100755 index 224a595a..00000000 --- a/src/webapps/symfony/root/etc/cont-init.d/500-boot-symfony +++ /dev/null @@ -1,34 +0,0 @@ -#!/command/with-contenv bash - -SYMFONY_ROOT="${WEBHOME:-/var/www/html}" -SYMFONY_CONSOLE="$SYMFONY_ROOT/bin/console" - -webuser-mkdir $SYMFONY_ROOT - -if [ ! -f "$SYMFONY_CONSOLE" ]; then - rm -rf $SYMFONY_ROOT/public $SYMFONY_ROOT/index.* - - echo "πŸ€– Installing Symfony from scratch..." - dirty - composer create-project \ - symfony/skeleton $SYMFONY_ROOT/ \ - --ansi \ - --no-cache \ - --no-dev \ - --no-interaction -fi - -if [ -f "$SYMFONY_CONSOLE" ]; then - if [ "$SYMFONY_INSTALL_DEVKIT" == "true" ]; then - echo "πŸ€– Installing packages that you usually need to build web applications..." - dirty - composer require -d $SYMFONY_ROOT/ \ - --ansi \ - --no-interaction \ - --optimize-autoloader \ - webapp - fi - - echo - php $SYMFONY_ROOT/bin/console about -fi diff --git a/src/webapps/symfony/root/startup/500-init-symfony b/src/webapps/symfony/root/startup/500-init-symfony new file mode 100755 index 00000000..6d47dbbf --- /dev/null +++ b/src/webapps/symfony/root/startup/500-init-symfony @@ -0,0 +1,19 @@ +#!/command/with-contenv bash +SYMFONY_PROJECT="${SYMFONY_PROJECT:-symfony/skeleton}" +SYMFONY_ROOT="$(webhome)" +SYMFONY_CONSOLE="$SYMFONY_ROOT/bin/console" +SYMFONY_DEVKIT="$SYMFONY_ROOT/vendor/symfony/debug-bundle" + +if [ ! -f "$SYMFONY_CONSOLE" ]; then + echo; echo "πŸ€– Installing $SYMFONY_PROJECT from scratch" + rm -rf $SYMFONY_ROOT/public $SYMFONY_ROOT/index.* + wdo composer-create -d $SYMFONY_ROOT/ $SYMFONY_PROJECT $SYMFONY_ROOT/ + wmd $SYMFONY_ROOT -R +fi + +if [ "$SYMFONY_INSTALL_DEVKIT" == "true" ] && [ -f "$SYMFONY_CONSOLE" ] && [ ! -d "$SYMFONY_DEVKIT" ]; then + echo; echo "πŸ€– Installing packages for development" + wdo composer-require -d $SYMFONY_ROOT/ webapp +fi + +[ -f "$SYMFONY_CONSOLE" ] && wdo php $SYMFONY_CONSOLE about \ No newline at end of file diff --git a/src/webapps/wordpress/Dockerfile b/src/webapps/wordpress/Dockerfile index 969b76e0..f16e26c2 100644 --- a/src/webapps/wordpress/Dockerfile +++ b/src/webapps/wordpress/Dockerfile @@ -1,41 +1,36 @@ -# This file is the work of https://github.com/shinsenter/php +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE ################################################################################ ARG BASE_IMAGE=shinsenter/phpfpm-apache +ARG IMAGE_SUFFIX="-tidy" ARG PHP_VERSION=8.1 ################################################################################ -# base image and platform -FROM ${BASE_IMAGE}:php${PHP_VERSION} as base +# base image +FROM ${BASE_IMAGE}:php${PHP_VERSION}${IMAGE_SUFFIX} -################################################################################ - -FROM base as source - -ARG WPCLI_URL=https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -ADD $WPCLI_URL /usr/bin/wp-cli -RUN chmod +x /usr/bin/wp-cli +# sets web server root path +ENV APACHE_DOCUMENT_ROOT="" ################################################################################ -# main image -FROM base - # adds config files -COPY --from=source /usr/bin/wp-cli /usr/bin/wp-cli -ADD root/ / +ADD root/ / -# sets web server root path -ENV WEBHOME="/var/www/html" -ENV APACHE_DOCUMENT_ROOT="" +# installs wp-cli +ARG WPCLI_URL=https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar +RUN php -r "copy('$WPCLI_URL', '/usr/bin/wp-cli');" && chmod +xr /usr/bin/wp-cli # sets the working directory -WORKDIR $WEBHOME +# WORKDIR $WEBHOME ################################################################################ # overrides parents env variables +ENV ENABLE_CRONTAB=true ENV PHP_ERROR_REPORTING="E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_WARNING" ENV PHP_MAX_EXECUTION_TIME=300 ENV PHP_POST_MAX_SIZE=100M diff --git a/src/webapps/wordpress/README.md b/src/webapps/wordpress/README.md index fed93fc2..9ef9fdb6 100644 --- a/src/webapps/wordpress/README.md +++ b/src/webapps/wordpress/README.md @@ -1,51 +1,150 @@ # shinsenter/wordpress -Start creating beautiful Wordpress websites with ease. Powered by shinsenter/php. +πŸ”° (PHP) Wordpress Docker images for development and production. -https://hub.docker.com/r/shinsenter/wordpress +> πŸ”— https://docker.shin.company/wordpress -[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/wordpress)](https://hub.docker.com/r/shinsenter/wordpress) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/wordpress/latest?label=shinsenter%2Fwordpress)](https://hub.docker.com/r/shinsenter/wordpress/tags) +> πŸš€ `shinsenter/wordpress` is also available in [smaller minified version](https://docker.shin.company/wordpress/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/wordpress)](https://docker.shin.company/wordpress) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/wordpress/latest?label=shinsenter%2Fwordpress)](https://docker.shin.company/wordpress) * * * ## About this project -Start creating beautiful Wordpress websites with ease. +πŸ”° (PHP) Wordpress Docker images for development and production. These images are actively maintained. + +Creating website using the Wordpress CMS framework with ease. + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). -Powered by [shinsenter/php](https://hub.docker.com/r/shinsenter/php). +> WordPress (WP, WordPress.org) is a free and open-source content management system (CMS) written in PHP and paired with a MySQL or MariaDB database. More information can be found at their [official website](https://wordpress.org). + +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. ## Usage ### Docker Pull command ```bash -docker pull shinsenter/wordpress +docker pull shinsenter/wordpress:latest ``` -### Docker Compose example +or -```yml -version: '3' -services: - my-container: - image: shinsenter/wordpress:latest - volumes: - - ./my-website:/var/www/html - environment: - TZ: UTC - ports: - - "80:80" - - "443:443" +```bash +docker pull shinsenter/wordpress:php${PHP_VERSION} ``` -View more image tags at [shinsenter/wordpress/tags](https://hub.docker.com/r/shinsenter/wordpress/tags). +or -## Customize your own image +```bash +docker pull shinsenter/wordpress:php${PHP_VERSION}-tidy +``` -Dockerfile example for building your own Docker image extending this image. +> View more image tags at [shinsenter/wordpress/tags](https://docker.shin.company/wordpress/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. ```Dockerfile -FROM shinsenter/wordpress +ENV WEBHOME="/var/www/html" +``` + +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. + +> Sometimes you may wish to change the default document root (away from `/var/www/html`), please consider changing the `$WEBHOME` value. + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in their [official documentation](https://getcomposer.org/doc). + +### WP-CLI + +The latest version of WP-CLI is installed and ready to use. + +> WP-CLI is the command-line interface for WordPress. You can update plugins, configure multisite installations and much more, without using a web browser. You can learn more from their [official website](https://wp-cli.org). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod +``` + +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/wordpress +``` + +For example: + +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/wordpress wp cli info +``` + +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). + +```Dockerfile +ARG PHP_VERSION=8.1 +FROM shinsenter/wordpress:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== # Control your timezone ENV TZ="UTC" @@ -57,9 +156,6 @@ ENV PGID=9999 # sets web server root path ENV WEBHOME="/var/www/html" -# sets the working directory -WORKDIR $WEBHOME - # ========================================================== # the locale for a fresh Wordpress @@ -73,11 +169,66 @@ ENV PHP_MAX_EXECUTION_TIME=300 ENV PHP_POST_MAX_SIZE=100M ENV PHP_UPLOAD_MAX_FILE_SIZE=10M -# Please check https://hub.docker.com/r/shinsenter/php -# for more details of PHP environment variables. +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` -# Please check https://hub.docker.com/r/shinsenter/phpfpm-apache -# for more details of Apache environment variables. +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/wordpress:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + ports: + - "80:80" + - "443:443" + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: my_database + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. + +```bash +docker-compose up -d ``` ## Supported platforms @@ -86,7 +237,7 @@ Currently, the supported architectures are: - linux/amd64 - linux/arm/v7 -- linux/arm64 +- linux/arm64/v8 - linux/ppc64le -You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/webapps/wordpress/root/etc/cont-init.d/500-boot-wordpress b/src/webapps/wordpress/root/etc/cont-init.d/500-boot-wordpress deleted file mode 100755 index 0e8b0f54..00000000 --- a/src/webapps/wordpress/root/etc/cont-init.d/500-boot-wordpress +++ /dev/null @@ -1,18 +0,0 @@ -#!/command/with-contenv bash - -WORDPRESS_ROOT="${WEBHOME:-/var/www/html}" -WORDPRESS_CHECK="$WORDPRESS_ROOT/wp-content" - -webuser-mkdir $WORDPRESS_ROOT - -if [ ! -d "$WORDPRESS_CHECK" ]; then - rm -f $WORDPRESS_ROOT/index.* - - echo "πŸ€– Installing Wordpress from scratch..." - dirty - wp-cli --allow-root \ - core download \ - --path=$WORDPRESS_ROOT/ \ - --locale="${WORDPRESS_LOCALE:-en_US}" \ - --force -fi \ No newline at end of file diff --git a/src/webapps/wordpress/root/etc/cron.d/wordpress-schedule b/src/webapps/wordpress/root/etc/cron.d/wordpress-schedule new file mode 100644 index 00000000..e39e831c --- /dev/null +++ b/src/webapps/wordpress/root/etc/cron.d/wordpress-schedule @@ -0,0 +1,3 @@ +MAILTO="" +SHELL=/bin/bash +*/10 * * * * webuser wp cron event run --due-now >/proc/1/fd/1 2>/proc/1/fd/2 diff --git a/src/webapps/wordpress/root/startup/500-init-wordpress b/src/webapps/wordpress/root/startup/500-init-wordpress new file mode 100755 index 00000000..a78b5f8d --- /dev/null +++ b/src/webapps/wordpress/root/startup/500-init-wordpress @@ -0,0 +1,12 @@ +#!/command/with-contenv bash +WORDPRESS_ROOT="$(webhome)" +WORDPRESS_CHECK="$WORDPRESS_ROOT/wp-content" + +if [ ! -d "$WORDPRESS_CHECK" ]; then + echo; echo "πŸ€– Installing Wordpress from scratch" + rm -f $WORDPRESS_ROOT/index.* + wp core download \ + --locale="${WORDPRESS_LOCALE:-en_US}" \ + --force + wmd $WORDPRESS_ROOT -R +fi \ No newline at end of file diff --git a/src/webapps/wordpress/root/usr/bin/wp b/src/webapps/wordpress/root/usr/bin/wp index 40c17ad2..f1f6967c 100755 --- a/src/webapps/wordpress/root/usr/bin/wp +++ b/src/webapps/wordpress/root/usr/bin/wp @@ -1,2 +1,2 @@ #!/bin/bash -sudo -u webuser -i -- /usr/bin/wp-cli --path="${WEBHOME:-/var/www/html}/" $@ \ No newline at end of file +exec wldo wp-cli --path="$(webhome)/" "$@" \ No newline at end of file diff --git a/src/webapps/yii/Dockerfile b/src/webapps/yii/Dockerfile new file mode 100644 index 00000000..6912a9b3 --- /dev/null +++ b/src/webapps/yii/Dockerfile @@ -0,0 +1,26 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +ARG BASE_IMAGE=shinsenter/phpfpm-apache +ARG IMAGE_SUFFIX="-tidy" +ARG PHP_VERSION=8.1 + +################################################################################ + +# base image +FROM ${BASE_IMAGE}:php${PHP_VERSION}${IMAGE_SUFFIX} + +# sets web server root path +ENV APACHE_DOCUMENT_ROOT="/web" + +################################################################################ + +# adds config files +ADD root/ / + +# sets the working directory +# WORKDIR $WEBHOME + +################################################################################ \ No newline at end of file diff --git a/src/webapps/yii/README.md b/src/webapps/yii/README.md new file mode 100644 index 00000000..8d8a06a3 --- /dev/null +++ b/src/webapps/yii/README.md @@ -0,0 +1,226 @@ +# shinsenter/yii + +πŸ”° (PHP) Yii Docker images for development and production. + +> πŸ”— https://docker.shin.company/yii + +> πŸš€ `shinsenter/yii` is also available in [smaller minified version](https://docker.shin.company/yii/tags?page=1&name=tidy). + +> πŸ“¦ Built on top of [shinsenter/php](https://docker.shin.company/php) docker base image. + +[![Docker Pulls](https://img.shields.io/docker/pulls/shinsenter/yii)](https://docker.shin.company/yii) [![Docker Image Size](https://img.shields.io/docker/image-size/shinsenter/yii/latest?label=shinsenter%2Fyii)](https://docker.shin.company/yii) + +* * * + +## About this project + +πŸ”° (PHP) Yii Docker images for development and production. These images are actively maintained. + +Creating application using the Yii framework with ease. + +You can also easily [add more PHP modules](#enabling-or-disabling-php-modules) or [customize your Docker image](#customize-docker-image). + +> Yii (Yes, it is!) is a fast, secure, and efficient PHP framework. Flexible yet pragmatic. More information can be found at their [official website](https://www.yiiframework.com). + +> πŸ’‘ To ensure that the image size is always compact and suitable for many different existing projects, the source code of the framework is not included in the container. + +> ⏬ However, if you want to start a new project, mount an empty directory to the document root path, it will automatically pull the latest version of the framework when you start the container. + +## Usage + +### Docker Pull command + +```bash +docker pull shinsenter/yii:latest +``` + +or + +```bash +docker pull shinsenter/yii:php${PHP_VERSION} +``` + +or + +```bash +docker pull shinsenter/yii:php${PHP_VERSION}-tidy +``` + +> View more image tags at [shinsenter/yii/tags](https://docker.shin.company/yii/tags). + +### The document root + +You can choose your own path for the document root by using the environment variable `$WEBHOME`. + +```Dockerfile +ENV WEBHOME="/var/www/html" +``` + +> The default document root is set to `/var/www/html`, and your application must be copied or mounted to this path. + +> Sometimes you may wish to change the default document root (away from `/var/www/html`), please consider changing the `$WEBHOME` value. + +### Composer + +The latest version of Composer is installed and ready to use. + +> Composer is a tool for dependency management in PHP, written in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. You can read more about Composer in our [official documentation](https://getcomposer.org/doc). + +### Access to your container + +Just open a terminal and run below command to access to your container: + +```bash +docker exec -it /bin/bash +``` + +### Enabling or disabling PHP modules + +There are many [pre-installed PHP modules](https://code.shin.company/php#pre-installed-php-modules) in the `shinsenter/php` Docker images, and I think it is quite enough for different PHP projects. If you want to add/remove these modules here is the guide. + +The `shinsenter/php` Docker images provide some helper scripts to more easily install/remove or enable/disable PHP extensions. +- `phpaddmod` (or `docker-php-ext-install`) +- `phpdelmod` (or `docker-php-ext-remove`) +- `phpenmod` (or `docker-php-ext-enable`) +- `phpdismod` (or `docker-php-ext-disable`) + +#### Installing PHP modules: + +```bash +docker exec -it phpaddmod +``` + +E.g.: `docker exec -it my-container phpaddmod imagick pgsql solr` + +#### Removing PHP modules: + +```bash +docker exec -it phpdelmod +``` + +E.g.: `docker exec -it my-container phpdelmod imagick pgsql solr` + +### Composer command + +Running a Composer command: + +```bash +docker exec -it composer +``` + +E.g.: `docker exec -it my-container composer install` + +### Docker Run command + +```bash +docker run --rm [run options] shinsenter/yii +``` + +For example: + +```bash +docker run --rm -v $(pwd):/var/www/html -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/yii composer dump-autoload +``` + +## Customize Docker image + +Here below is a sample `Dockerfile` for building your own Docker image extending this image. You also can add more [pre-defined Docker's ENV settings](https://code.shin.company/php#customize-docker-image) to change PHP-FPM behavior without copying configuration files to your containers. + +> Learn more about [Dockerfile](https://docs.docker.com/engine/reference/builder). + +```Dockerfile +ARG PHP_VERSION=8.1 +FROM shinsenter/yii:php${PHP_VERSION} + +# ========================================================== + +# you may want to install some PHP modules +# e.g: the following line will install imagick, pgsql, solr modules +RUN phpaddmod imagick pgsql solr + +# ========================================================== + +# Control your timezone +ENV TZ="UTC" + +# sets GID and UID +ENV PUID=9999 +ENV PGID=9999 + +# sets web server root path +ENV WEBHOME="/var/www/html" + +# ========================================================== + +# You can easily change PHP-FPM configurations +# by using pre-defined Docker's environment variables. +# Learn more: https://code.shin.company/php#customize-docker-image +``` + +Then run below command to build your Docker image. + +```bash +docker build [build options] - < Dockerfile +``` + +## Docker Compose example + +Create an empty directory for a new project and place in the directory a `docker-compose.yml` file with below content. + +> Learn more about [Docker Compose](https://docs.docker.com/compose). + +> To configure an HTTPS server, you need to mount the directory of the server certificate `server.crt` and private key `server.key` files to container's `/etc/ssl/web` path. You can also use a modern HTTP reverse proxy like [Traefik](https://hub.docker.com/_/traefik). + +```yml +version: '3' +services: + my-container: + image: shinsenter/yii:latest + volumes: + - ./my-website:/var/www/html + - ./ssl-certs:/etc/ssl/web + environment: + TZ: UTC + PUID: ${UID:-9999} + PGID: ${GID:-9999} + ports: + - "80:80" + - "443:443" + links: + - mysql + - redis + + ## OTHER CONTAINERS SUCH AS REDIS OR MYSQL ################################### + mysql: + image: mysql:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: mydb_p@ssw0rd + MYSQL_DATABASE: my_database + volumes: + - "./mysql/data:/var/lib/mysql" + - "./mysql/dump:/docker-entrypoint-initdb.d" + ports: + - "3306:3306" + redis: + image: redis:latest + ports: + - "6379:6379" +``` + +Then run below command to start containers. + +```bash +docker-compose up -d +``` + +## Supported platforms + +Currently, the supported architectures are: + +- linux/amd64 +- linux/arm/v7 +- linux/arm64/v8 +- linux/ppc64le + +> You do not need to use a platform-specific tag (although you can), Docker will automatically choose the appropriate architecture. \ No newline at end of file diff --git a/src/webapps/yii/root/startup/500-init-yii b/src/webapps/yii/root/startup/500-init-yii new file mode 100755 index 00000000..dd4097cf --- /dev/null +++ b/src/webapps/yii/root/startup/500-init-yii @@ -0,0 +1,11 @@ +#!/command/with-contenv bash +YII_PROJECT="${YII_PROJECT:-yiisoft/yii2-app-basic}" +YII_ROOT="$(webhome)" +YII_CHECK="$YII_ROOT/yii" + +if [ ! -f "$YII_CHECK" ]; then + echo; echo "πŸ€– Installing $YII_PROJECT from scratch" + rm -rf $YII_ROOT/web $YII_ROOT/index.* + wdo composer-create -d $YII_ROOT/ $YII_PROJECT $YII_ROOT/ + wmd $YII_ROOT -R +fi \ No newline at end of file diff --git a/tests/common.yml b/tests/common.yml index faf58dfe..dc3668cd 100644 --- a/tests/common.yml +++ b/tests/common.yml @@ -1,3 +1,8 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + version: '3' services: @@ -7,15 +12,20 @@ services: platform: ${BUILD_PLATFORM:-linux/arm64/v8} environment: - TZ=Asia/Ho_Chi_Minh - - PUID=1234 - - PGID=1234 + - PUID=${UID:-1234} + - PGID=${GID:-1234} - WEBHOME=/opt/www - - S6_CMD_WAIT_FOR_SERVICES_MAXTIME=600000 + - S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 common-php: extends: common build: args: - PHP_VERSION: ${PHP_VERSION:-8.1} + - IMAGE_SUFFIX= + - PHP_VERSION=${PHP_VERSION:-8.1} + environment: + - DEBUG_MODE=false + volumes: + - ./data/_ssl:/etc/ssl/web ################################################################################ diff --git a/tests/docker-compose.base-s6.yml b/tests/docker-compose.base-s6.yml index ede92649..2fb0ed2b 100644 --- a/tests/docker-compose.base-s6.yml +++ b/tests/docker-compose.base-s6.yml @@ -1,3 +1,8 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + version: '3' services: @@ -11,7 +16,6 @@ services: build: context: ../src/base-s6 args: - BASE_IMAGE: ubuntu:focal - S6_VERSION: ${S6_VERSION:-v3.1.0.1} + S6_VERSION: ${S6_VERSION} ################################################################################ diff --git a/tests/docker-compose.base-ubuntu.yml b/tests/docker-compose.base-ubuntu.yml index d764589c..25ebbe67 100644 --- a/tests/docker-compose.base-ubuntu.yml +++ b/tests/docker-compose.base-ubuntu.yml @@ -1,3 +1,8 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + version: '3' services: @@ -11,7 +16,7 @@ services: build: context: ../src/base-ubuntu args: - BASE_IMAGE: ubuntu:focal - S6_VERSION: ${S6_VERSION:-v3.1.0.1} + BASE_OS_IMAGE: ${BASE_OS_IMAGE:-ubuntu:latest} + S6_VERSION: ${S6_VERSION} ################################################################################ diff --git a/tests/docker-compose.cli.yml b/tests/docker-compose.cli.yml index 1a5ba9d9..67ddf75f 100644 --- a/tests/docker-compose.cli.yml +++ b/tests/docker-compose.cli.yml @@ -1,3 +1,8 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + version: '3' services: @@ -10,7 +15,5 @@ services: service: common-php build: context: ../src/php/cli - args: - BASE_IMAGE: shinsenter/s6-ubuntu:latest ################################################################################ diff --git a/tests/docker-compose.fpm.yml b/tests/docker-compose.fpm.yml index dcc5e24d..7223d802 100644 --- a/tests/docker-compose.fpm.yml +++ b/tests/docker-compose.fpm.yml @@ -1,3 +1,8 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + version: '3' services: @@ -10,7 +15,5 @@ services: service: common-php build: context: ../src/php/fpm - args: - BASE_IMAGE: shinsenter/php ################################################################################ diff --git a/tests/docker-compose.scratch.yml b/tests/docker-compose.scratch.yml new file mode 100644 index 00000000..8bea9a87 --- /dev/null +++ b/tests/docker-compose.scratch.yml @@ -0,0 +1,15 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +version: '3' +services: + + ############################################################################## + + s6-overlay: + image: shinsenter/scratch:latest + build: ../src/base + +################################################################################ diff --git a/tests/docker-compose.server.yml b/tests/docker-compose.server.yml index f47c4df9..641a9b5f 100644 --- a/tests/docker-compose.server.yml +++ b/tests/docker-compose.server.yml @@ -1,3 +1,8 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + version: '3' services: @@ -11,7 +16,7 @@ services: build: context: ../src/servers/fpm-apache ports: - - 8881:80 + - 9001:80 ############################################################################## @@ -23,6 +28,6 @@ services: build: context: ../src/servers/fpm-nginx ports: - - 8882:80 + - 9002:80 ################################################################################ diff --git a/tests/docker-compose.webapps.yml b/tests/docker-compose.webapps.yml index 05ce70ff..9e81c60e 100644 --- a/tests/docker-compose.webapps.yml +++ b/tests/docker-compose.webapps.yml @@ -1,33 +1,181 @@ +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + version: '3' services: ############################################################################## - wordpress: - image: shinsenter/wordpress:php${PHP_VERSION:-8.1} + database: + container_name: database + image: mariadb:latest + environment: + TZ: UTC + MYSQL_ROOT_PASSWORD: localhost + MYSQL_DATABASE: test + + redis: + container_name: redis + image: redis:latest + + ############################################################################## + + phpinfo: + image: shinsenter/phpfpm-nginx:php${PHP_VERSION:-8.1} + extends: + file: common.yml + service: common-php + volumes: + - ./data/phpinfo:/opt/www + ports: + - 9100:80 + + ############################################################################## + + cakephp4: + image: shinsenter/cakephp4:php${PHP_VERSION:-8.1} extends: file: common.yml service: common-php build: - context: ../src/webapps/wordpress + context: ../src/webapps/cakephp4 volumes: - - ./data/wordpress:/opt/www + - ./data/cakephp4:/opt/www ports: - - 9991:80 + - 9101:80 + environment: + - CAKE4_PROJECT=cakephp/app + +################################################################################ + + codeigniter4: + image: shinsenter/codeigniter4:php${PHP_VERSION:-8.1} + extends: + file: common.yml + service: common-php + build: + context: ../src/webapps/codeigniter4 + volumes: + - ./data/codeigniter4:/opt/www + ports: + - 9102:80 + environment: + - CI4_PROJECT=codeigniter4/appstarter ############################################################################## - phpmyadmin: - image: shinsenter/phpmyadmin:php${PHP_VERSION:-8.1} + crater: + image: shinsenter/crater:php${PHP_VERSION:-8.1} extends: file: common.yml service: common-php build: - context: ../src/webapps/phpmyadmin + context: ../src/webapps/crater volumes: - - ./data/phpmyadmin:/opt/www + - ./data/crater:/opt/www + ports: + - 9103:80 + environment: + - REDIS_HOST=redis + - LARAVEL_SCHEDULE_ENABLED=true + +################################################################################ + + flarum: + image: shinsenter/flarum:php${PHP_VERSION:-8.1} + extends: + file: common.yml + service: common-php + build: + context: ../src/webapps/flarum + volumes: + - ./data/flarum:/opt/www + ports: + - 9104:80 + environment: + - FLARUM_PROJECT=flarum/flarum + +################################################################################ + + fuelphp: + image: shinsenter/fuelphp:php${PHP_VERSION:-8.1} + extends: + file: common.yml + service: common-php + build: + context: ../src/webapps/fuelphp + volumes: + - ./data/fuelphp:/opt/www + ports: + - 9105:80 + environment: + - FUEL_PROJECT=fuel/fuel + +################################################################################ + + grav: + image: shinsenter/grav:php${PHP_VERSION:-8.1} + extends: + file: common.yml + service: common-php + build: + context: ../src/webapps/grav + volumes: + - ./data/grav:/opt/www + ports: + - 9106:80 + environment: + - GRAV_PROJECT=getgrav/grav + +################################################################################ + + hyperf: + image: shinsenter/hyperf:php${PHP_VERSION:-8.1} + extends: + file: common.yml + service: common-php + build: + context: ../src/webapps/hyperf + volumes: + - ./data/hyperf:/opt/www ports: - - 9992:80 + - 9107:80 + environment: + - HYPERF_PROJECT=hyperf/hyperf-skeleton + + ############################################################################## + + kirby: + image: shinsenter/kirby:php${PHP_VERSION:-8.1} + extends: + file: common.yml + service: common-php + build: + context: ../src/webapps/kirby + volumes: + - ./data/kirby:/opt/www + ports: + - 9108:80 + environment: + - KIRBY_PROJECT=getkirby/starterkit + +################################################################################ + + laminas: + image: shinsenter/laminas:php${PHP_VERSION:-8.1} + extends: + file: common.yml + service: common-php + build: + context: ../src/webapps/laminas + volumes: + - ./data/laminas:/opt/www + ports: + - 9109:80 + environment: + - ZEND_PROJECT=laminas/laminas-mvc-skeleton ############################################################################## @@ -41,23 +189,67 @@ services: volumes: - ./data/laravel:/opt/www ports: - - 9993:80 + - 9110:80 + environment: + - REDIS_HOST=redis + - LARAVEL_PROJECT=laravel/laravel + - LARAVEL_QUEUE_ENABLED=true + - LARAVEL_QUEUE_OPTIONS=--timeout=10 --tries=3 redis + - LARAVEL_SCHEDULE_ENABLED=true ############################################################################## - codeigniter4: - image: shinsenter/codeigniter4:php${PHP_VERSION:-8.1} + phpmyadmin: + image: shinsenter/phpmyadmin:php${PHP_VERSION:-8.1} extends: file: common.yml service: common-php build: - context: ../src/webapps/codeigniter4 + context: ../src/webapps/phpmyadmin volumes: - - ./data/codeigniter4:/opt/www + - ./data/phpmyadmin:/opt/www ports: - - 9994:80 + - 9111:80 + environment: + - PMA_PROJECT=phpmyadmin/phpmyadmin + - PMA_HOST=database + - PMA_PASSWORD=localhost + - PMA_USER=root -################################################################################ + ############################################################################## + + slim: + image: shinsenter/slim:php${PHP_VERSION:-8.1} + extends: + file: common.yml + service: common-php + build: + context: ../src/webapps/slim + volumes: + - ./data/slim:/opt/www + ports: + - 9112:80 + environment: + - SLIM_PROJECT=slim/slim-skeleton + + ############################################################################## + + statamic: + image: shinsenter/statamic:php${PHP_VERSION:-8.1} + extends: + file: common.yml + service: common-php + build: + context: ../src/webapps/statamic + volumes: + - ./data/statamic:/opt/www + ports: + - 9113:80 + environment: + - REDIS_HOST=redis + - STATAMIC_PROJECT=statamic/statamic + + ############################################################################## symfony: image: shinsenter/symfony:php${PHP_VERSION:-8.1} @@ -69,8 +261,39 @@ services: volumes: - ./data/symfony:/opt/www ports: - - 9995:80 + - 9114:80 environment: + - SYMFONY_PROJECT=symfony/skeleton - SYMFONY_INSTALL_DEVKIT=true ################################################################################ + + wordpress: + image: shinsenter/wordpress:php${PHP_VERSION:-8.1} + extends: + file: common.yml + service: common-php + build: + context: ../src/webapps/wordpress + volumes: + - ./data/wordpress:/opt/www + ports: + - 9115:80 + + ############################################################################## + + yii: + image: shinsenter/yii:php${PHP_VERSION:-8.1} + extends: + file: common.yml + service: common-php + build: + context: ../src/webapps/yii + volumes: + - ./data/yii:/opt/www + ports: + - 9116:80 + environment: + - YII_PROJECT=yiisoft/yii2-app-basic + + ############################################################################## diff --git a/tests/test.sh b/tests/test.sh index 1b8290c0..dcf0829b 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -1,24 +1,104 @@ -#!/bin/sh +#!/bin/bash +# This file belongs to the project https://code.shin.company/php +# Author: Shin +# License: https://code.shin.company/php/blob/main/LICENSE +################################################################################ + +[ ! -x "$(command -v docker)" ] && echo "Missing Docker." && exit 1 + BASE_DIR="$(git rev-parse --show-toplevel)" +SRC_DIR="$BASE_DIR/src" TEST_DIR="$BASE_DIR/tests" +################################################################################ + +if [ "$1" == "clean" ]; then + shift + rm -rf $TEST_DIR/data + docker system prune -af + clear +fi + +################################################################################ + +export UID=$(id -u) +export GID=$(id -g) export DOCKER_BUILDKIT=1 -export S6_VERSION="$(cat $BASE_DIR/S6_VERSION.txt)" +export BASE_OS_IMAGE="ubuntu:latest" +export S6_VERSION="$(cat $BASE_DIR/S6_VERSION)" export PHP_VERSION="${1:-8.1}" export BUILD_PLATFORM="${2:-linux/arm64/v8}" +################################################################################ + +tidy() { + local save_file="$1/Dockerfile.tidy" + local save_path="$(dirname $save_file)" + local image="$2" + local replacement="\${PHP_VERSION:-$PHP_VERSION}" + local argument="ARG PHP_VERSION=${PHP_VERSION}" + # mkdir -p $save_path && touch $save_file + if [ -f $save_file ]; then + $BASE_DIR/.bin/tidy-docker "$save_file" "$image" "${image}-tidy" + echo -e "${argument}\n$(cat $save_file \ + | sed "s/${PHP_VERSION}/${replacement}/" \ + | sed "s/FROM *scratch/FROM scratch\n${argument}/" \ + | awk NF)" >$save_file + else + $BASE_DIR/.bin/tidy-docker "$image" "${image}-tidy" \ + --build-arg PHP_VERSION=$PHP_VERSION --platform=$BUILD_PLATFORM + fi +} + +################################################################################ + clear -$BASE_DIR/.git-config/hooks/pre-commit +echo -e "\nπŸ€– Starting building S6 ${S6_VERSION} and \ +php:${PHP_VERSION} images for platform ${BUILD_PLATFORM}" +mkdir -p $SRC_DIR/base/scratch -echo -echo "πŸ€– Starting building S6 ${S6_VERSION} and \ -php:${PHP_VERSION} images for platform ${BUILD_PLATFORM}..." +################################################################################ +### Build +echo -e "\nBuilding Docker images" echo && date \ +&& $BASE_DIR/.bin/fix-attr $BASE_DIR \ +&& docker-compose -f $TEST_DIR/docker-compose.scratch.yml build \ && docker-compose -f $TEST_DIR/docker-compose.base-s6.yml build \ && docker-compose -f $TEST_DIR/docker-compose.base-ubuntu.yml build \ && docker-compose -f $TEST_DIR/docker-compose.cli.yml build \ && docker-compose -f $TEST_DIR/docker-compose.fpm.yml build \ && docker-compose -f $TEST_DIR/docker-compose.server.yml build \ && docker-compose -f $TEST_DIR/docker-compose.webapps.yml build \ -&& echo "Finished." \ No newline at end of file +&& echo -e "\nFinished." + +CODE="$?" +[ "$CODE" -ne 0 ] && echo "Build failed." && exit $CODE + +################################################################################ + +### Test +echo -e "\nTest running docker command" +command="composer --ansi create-project laravel/laravel" +docker run --rm -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/php:${PHP_VERSION}-cli $command +docker run --rm -e PUID=$(id -u) -e PGID=$(id -g) shinsenter/php:${PHP_VERSION}-fpm $command + +################################################################################ + +### Minify +echo -e "\nMinifying Docker images" +tidy $SRC_DIR/base-ubuntu "shinsenter/s6-ubuntu:latest" +for name in $(ls -1 $SRC_DIR/php/ | sort); do + tidy $SRC_DIR/php/$name "shinsenter/php:${PHP_VERSION}-${name}" +done +for name in $(ls -1 $SRC_DIR/servers/ | sort); do + tidy $SRC_DIR/servers/$name "shinsenter/php${name}:php${PHP_VERSION}" +done +for name in $(ls -1 $SRC_DIR/webapps/ | sort); do + tidy $SRC_DIR/webapps/$name "shinsenter/${name}:php${PHP_VERSION}" +done + +################################################################################ + +### Run tests +docker-compose -f $TEST_DIR/docker-compose.webapps.yml up --build --force-recreate \ No newline at end of file