diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000000..2124c7f13a --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,91 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +# GitHub recommends pinning actions to a commit SHA. +# To get a newer version, you will need to update the SHA. +# You can also reference a tag or branch, but the action may change without warning. + +name: Publish Docker image + +on: + release: + types: [published] + +jobs: + push_to_registries: + name: Push Docker image to multiple registries + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + attestations: write + id-token: write + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Log in to Docker Hub + uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: | + tjipenk/webserver + ghcr.io/${{ github.repository }} + + - name: Build and push Docker images + id: push_ver54 + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: ./bin/php56 + push: true + tags: php56 + labels: ${{ steps.meta.outputs.labels }} + + - name: Build and push Docker images + id: push_ver75 + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: ./bin/php74 + push: true + tags: php74 + labels: ${{ steps.meta.outputs.labels }} + + - name: Build and push Docker images + id: push_ver8 + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: ./bin/php8 + push: true + tags: php8 + labels: ${{ steps.meta.outputs.labels }} + + - name: Build and push Docker images + id: push_ver83 + uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 + with: + context: ./bin/php83 + push: true + tags: php83 + labels: ${{ steps.meta.outputs.labels }} + + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v1 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..6c2ff60b60 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "githubPullRequests.ignoredPullRequestBranches": [ + "master" + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 127c17789f..de42c11844 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ As of now, we have several different PHP versions. Use appropriate php version a - Run the `docker compose up -d`. ```shell -git clone https://github.com/sprintcube/docker-compose-lamp.git +git clone https://github.com/tjipenk/docker-compose-lamp.git cd docker-compose-lamp/ cp sample.env .env // modify sample.env as needed diff --git a/bash_webserver.sh b/bash_webserver.sh new file mode 100755 index 0000000000..64184f093f --- /dev/null +++ b/bash_webserver.sh @@ -0,0 +1 @@ +docker-compose run --rm webserver bash diff --git a/bin/crond/Dockerfile b/bin/crond/Dockerfile new file mode 100644 index 0000000000..89d3ef77ea --- /dev/null +++ b/bin/crond/Dockerfile @@ -0,0 +1,12 @@ +FROM alpine:latest + +LABEL maintainer="Alvin F" + +RUN apk add --no-cache curl + +###################### +# Run crond # +# -f for Foreground # +###################### + +CMD ["/usr/sbin/crond", "-f"] diff --git a/bin/laravel10/Dockerfile b/bin/laravel10/Dockerfile new file mode 100644 index 0000000000..e91af3cdfd --- /dev/null +++ b/bin/laravel10/Dockerfile @@ -0,0 +1,64 @@ +FROM ubuntu:22.04 + +LABEL maintainer="Taylor Otwell" + +ARG WWWGROUP +ARG NODE_VERSION=18 +ARG POSTGRES_VERSION=15 + +WORKDIR /var/www/html + +ENV DEBIAN_FRONTEND noninteractive +ENV TZ=UTC + +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +RUN apt-get update \ + && apt-get install -y gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python +2 dnsutils librsvg2-bin \ + && curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg + --dearmor | tee /etc/apt/keyrings/ppa_ondrej_php.gpg > /dev/null \ + && echo "deb [signed-by=/etc/apt/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jam +my main" > /etc/apt/sources.list.d/ppa_ondrej_php.list \ + && apt-get update \ + && apt-get install -y php8.2-cli php8.2-dev \ + php8.2-pgsql php8.2-sqlite3 php8.2-gd php8.2-imagick \ + php8.2-curl \ + php8.2-imap php8.2-mysql php8.2-mbstring \ + php8.2-xml php8.2-zip php8.2-bcmath php8.2-soap \ + php8.2-intl php8.2-readline \ + php8.2-ldap \ + php8.2-msgpack php8.2-igbinary php8.2-redis php8.2-swoole \ + php8.2-memcached php8.2-pcov php8.2-xdebug \ + && curl -sLS https://getcomposer.org/installer | php -- --install-dir=/usr/bin/ --filename=composer \ + && curl -sLS https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \ + && apt-get install -y nodejs \ + && npm install -g npm \ + && curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | tee /etc/apt/keyrings/yarn.gpg >/dev/null \ + && echo "deb [signed-by=/etc/apt/keyrings/yarn.gpg] https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.l +ist.d/yarn.list \ + && curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | tee /etc/apt/keyrings/pgdg.gpg >/de +v/null \ + && echo "deb [signed-by=/etc/apt/keyrings/pgdg.gpg] http://apt.postgresql.org/pub/repos/apt jammy-pgdg main" > /etc/ +apt/sources.list.d/pgdg.list \ + && apt-get update \ + && apt-get install -y yarn \ + && apt-get install -y mysql-client \ + && apt-get install -y postgresql-client-$POSTGRES_VERSION \ + && apt-get -y autoremove \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.2 + +RUN groupadd --force -g $WWWGROUP sail +RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail + +COPY start-container /usr/local/bin/start-container +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf +COPY php.ini /etc/php/8.2/cli/conf.d/99-sail.ini +RUN chmod +x /usr/local/bin/start-container + +EXPOSE 8000 + +ENTRYPOINT ["start-container"] \ No newline at end of file diff --git a/bin/laravel10/php.ini b/bin/laravel10/php.ini new file mode 100644 index 0000000000..97f0ba9ffe --- /dev/null +++ b/bin/laravel10/php.ini @@ -0,0 +1,7 @@ +[PHP] +post_max_size = 100M +upload_max_filesize = 100M +variables_order = EGPCS + +[opcache] +opcache.enable_cli=1 \ No newline at end of file diff --git a/bin/laravel10/start-container b/bin/laravel10/start-container new file mode 100644 index 0000000000..7651ecd1f6 --- /dev/null +++ b/bin/laravel10/start-container @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +if [ ! -z "$WWWUSER" ]; then + usermod -u $WWWUSER sail +fi + +if [ ! -d /.composer ]; then + mkdir /.composer +fi + +chmod -R ugo+rw /.composer + +if [ $# -gt 0 ]; then + exec gosu $WWWUSER "$@" +else + exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf +fi \ No newline at end of file diff --git a/bin/laravel10/supervisord.conf b/bin/laravel10/supervisord.conf new file mode 100644 index 0000000000..4d0a68ec3c --- /dev/null +++ b/bin/laravel10/supervisord.conf @@ -0,0 +1,14 @@ +[supervisord] +nodaemon=true +user=root +logfile=/var/log/supervisor/supervisord.log +pidfile=/var/run/supervisord.pid + +[program:php] +command=/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80 +user=sail +environment=LARAVEL_SAIL="1" +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 \ No newline at end of file diff --git a/bin/php74/Dockerfile b/bin/php74/Dockerfile index f8b7d99e8b..4ec57b2320 100644 --- a/bin/php74/Dockerfile +++ b/bin/php74/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.4.2-apache-buster +FROM php:7.4.33-apache-buster # Surpresses debconf complaints of trying to install apt packages interactively # https://github.com/moby/moby/issues/4032#issuecomment-192327844 @@ -51,6 +51,12 @@ RUN apt-get update && \ pecl install imagick && \ docker-php-ext-enable imagick +# Install mcrypt +RUN apt-get -y update && \ + apt-get install -y libmcrypt-dev && \ + rm -rf /var/lib/apt/lists/* && \ + pecl install mcrypt-1.0.4 && docker-php-ext-enable mcrypt + # Other PHP7 Extensions RUN docker-php-ext-install pdo_mysql && \ diff --git a/bin/php8/Dockerfile b/bin/php8/Dockerfile index fc76afb609..fdc4805367 100644 --- a/bin/php8/Dockerfile +++ b/bin/php8/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.0.19-apache-buster +FROM php:8.0.27-apache-buster # Surpresses debconf complaints of trying to install apt packages interactively # https://github.com/moby/moby/issues/4032#issuecomment-192327844 diff --git a/bin/php81/Dockerfile b/bin/php81/Dockerfile index aa7f3508ff..4b9ce0f0ab 100644 --- a/bin/php81/Dockerfile +++ b/bin/php81/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.1-apache-buster +FROM php:8.1.14-apache-buster # Surpresses debconf complaints of trying to install apt packages interactively # https://github.com/moby/moby/issues/4032#issuecomment-192327844 diff --git a/bin/php82/Dockerfile b/bin/php82/Dockerfile index d14be2de3b..8d4a789475 100644 --- a/bin/php82/Dockerfile +++ b/bin/php82/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.2.1-apache-buster +FROM php:8.2.8-apache-bullseye # Surpresses debconf complaints of trying to install apt packages interactively # https://github.com/moby/moby/issues/4032#issuecomment-192327844 @@ -36,13 +36,18 @@ openssl && \ curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer # Install xdebug -RUN pecl install xdebug-3.2.1 && \ +RUN pecl install xdebug && \ docker-php-ext-enable xdebug && \ mkdir /var/log/xdebug # Install redis -RUN pecl install redis-5.3.7 && \ +RUN pecl install redis && \ docker-php-ext-enable redis + +# Install memcached +RUN apt-get update && apt-get install -y libmemcached-dev libssl-dev zlib1g-dev \ + && pecl install memcached-3.2.0 \ + && docker-php-ext-enable memcached # Install imagick RUN apt-get update && \ @@ -80,6 +85,25 @@ RUN docker-php-ext-install pdo_mysql && \ docker-php-ext-install calendar && \ docker-php-ext-install exif +# Install Node JS +#RUN apt-get update && \ +# apt-get install -yq --no-install-recommends \ +# open-ssl \ +# curl \ +# wget \ +# git \ +# gnupg \ +# # more stuff + +#RUN curl -fsSL https://deb.nodesource.com/setup_current.x | bash - && \ +# apt-get install -y nodejs npm unzip \ +# build-essential && \ +# node --version && \ +# npm --version + +RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - +RUN apt install nodejs + # Install Freetype RUN apt-get -y update && \ diff --git a/build_container.sh b/build_container.sh new file mode 100644 index 0000000000..f9d8fa0e83 --- /dev/null +++ b/build_container.sh @@ -0,0 +1,3 @@ +#!/bin/bash +docker-compose build webserver + diff --git a/config/php/php.ini b/config/php/php.ini index d38c9cb033..5283ac4639 100644 --- a/config/php/php.ini +++ b/config/php/php.ini @@ -1,6 +1,6 @@ -memory_limit = 256M -post_max_size = 100M -upload_max_filesize = 100M +memory_limit = 512M +post_max_size = 512M +upload_max_filesize = 512M # Xdebug 2 #xdebug.remote_enable=1 @@ -14,4 +14,4 @@ upload_max_filesize = 100M #xdebug.start_with_request=yes #xdebug.client_host=host.docker.internal #xdebug.client_port=9003 -#xdebug.idekey=VSCODE \ No newline at end of file +#xdebug.idekey=VSCODE diff --git a/data/crond/.gitkeep b/data/crond/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/data/crond/crond b/data/crond/crond new file mode 100644 index 0000000000..de762b78d4 --- /dev/null +++ b/data/crond/crond @@ -0,0 +1 @@ +* * * * 10 curl http://webserver/ > /dev/null \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 4cb90d0d16..3fd8c5402e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,5 @@ version: "3" - + services: webserver: build: @@ -8,7 +8,7 @@ services: restart: "always" ports: - "${HOST_MACHINE_UNSECURE_HOST_PORT}:80" - - "${HOST_MACHINE_SECURE_HOST_PORT}:443" + # - "${HOST_MACHINE_SECURE_HOST_PORT}:443" links: - database volumes: @@ -38,7 +38,8 @@ services: - "127.0.0.1:${HOST_MACHINE_MYSQL_PORT}:3306" volumes: - ${MYSQL_INITDB_DIR-./config/initdb}:/docker-entrypoint-initdb.d - - ${MYSQL_DATA_DIR-./data/mysql}:/var/lib/mysql + # - ${MYSQL_DATA_DIR-./data/mysql}:/var/lib/mysql + - database:/var/lib/mysql - ${MYSQL_LOG_DIR-./logs/mysql}:/var/log/mysql environment: MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} @@ -53,8 +54,8 @@ services: environment: PMA_HOST: database PMA_PORT: 3306 - PMA_USER: root - PMA_PASSWORD: ${MYSQL_ROOT_PASSWORD} + # PMA_USER: root + # PMA_PASSWORD: ${MYSQL_ROOT_PASSWORD} MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} MYSQL_USER: ${MYSQL_USER} MYSQL_PASSWORD: ${MYSQL_PASSWORD} @@ -62,12 +63,28 @@ services: MEMORY_LIMIT: ${MEMORY_LIMIT} ports: - "${HOST_MACHINE_PMA_PORT}:80" - - "${HOST_MACHINE_PMA_SECURE_PORT}:443" volumes: - - /sessions + - phpmyadmin:/sessions - ${PHP_INI-./config/php/php.ini}:/usr/local/etc/php/conf.d/php-phpmyadmin.ini redis: container_name: "${COMPOSE_PROJECT_NAME}-redis" image: redis:latest + volumes: + - redis:/data ports: - "127.0.0.1:${HOST_MACHINE_REDIS_PORT}:6379" + crond: + container_name: "${COMPOSE_PROJECT_NAME}-crond" + build: + context: ./bin/crond + volumes: + - ./data/crond/crond:/etc/crontabs/root + - ./data/crond/log:/var/log/ + +volumes: + database: + name: ${DATABASE} + redis: + name: redis-${COMPOSE_PROJECT_NAME} + phpmyadmin: + name: phpmyadmin-sess-${COMPOSE_PROJECT_NAME} diff --git a/sample.env b/sample.env index e1df9da174..9438081da3 100644 --- a/sample.env +++ b/sample.env @@ -4,8 +4,10 @@ # To determine the name of your containers COMPOSE_PROJECT_NAME=lamp + # Possible values: php54, php56, php71, php72, php73, php74, php8, php81, php82, php83 PHPVERSION=php83 + DOCUMENT_ROOT=./www APACHE_DOCUMENT_ROOT=/var/www/html VHOSTS_DIR=./config/vhosts @@ -27,23 +29,24 @@ XDEBUG_PORT=9003 # For Apple Silicon User: # Please select Mariadb as Database. Oracle doesn't build their SQL Containers for the arm Architecure -DATABASE=mysql8 +DATABASE=mariadb104 MYSQL_INITDB_DIR=./config/initdb -MYSQL_DATA_DIR=./data/mysql +## database volumes +#MYSQL_DATA_DIR=./data/mysql MYSQL_LOG_DIR=./logs/mysql # If you already have the port 80 in use, you can change it (for example if you have Apache) HOST_MACHINE_UNSECURE_HOST_PORT=80 # If you already have the port 443 in use, you can change it (for example if you have Apache) -HOST_MACHINE_SECURE_HOST_PORT=443 +# HOST_MACHINE_SECURE_HOST_PORT=443 # If you already have the port 3306 in use, you can change it (for example if you have MySQL) HOST_MACHINE_MYSQL_PORT=3306 # If you already have the port 8080 in use, you can change it (for example if you have PMA) HOST_MACHINE_PMA_PORT=8080 -HOST_MACHINE_PMA_SECURE_PORT=8443 +# HOST_MACHINE_PMA_SECURE_PORT=8443 # If you already has the port 6379 in use, you can change it (for example if you have Redis) HOST_MACHINE_REDIS_PORT=6379