From 700fad9ddb6c0e06ed6e8059b93be91682379ece Mon Sep 17 00:00:00 2001 From: Fu Cheng Date: Fri, 17 May 2024 10:58:45 +0800 Subject: [PATCH] Add version 2.4.6-p5 --- .github/FUNDING.yml | 1 + .github/workflows/docker-publish.yml | 16 +++---- Dockerfile.hbs | 6 +-- README.md | 16 +++---- docker-compose.yaml.hbs | 2 +- update.js | 11 ++++- versions/2.4.4-p6/Dockerfile | 2 +- versions/2.4.5-p5/Dockerfile | 2 +- versions/2.4.6-p3/Dockerfile | 2 +- versions/2.4.6-p5/Dockerfile | 62 +++++++++++++++++++++++++++ versions/2.4.6-p5/auth.json | 8 ++++ versions/2.4.6-p5/docker-compose.yaml | 56 ++++++++++++++++++++++++ versions/2.4.6-p5/env | 22 ++++++++++ versions/2.4.6-p5/install-magento | 37 ++++++++++++++++ versions/2.4.6-p5/install-sampledata | 9 ++++ 15 files changed, 226 insertions(+), 26 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 versions/2.4.6-p5/Dockerfile create mode 100644 versions/2.4.6-p5/auth.json create mode 100644 versions/2.4.6-p5/docker-compose.yaml create mode 100644 versions/2.4.6-p5/env create mode 100644 versions/2.4.6-p5/install-magento create mode 100644 versions/2.4.6-p5/install-sampledata diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..04445c1f5 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +ko_fi: alexcheng1982 diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index f3c1c8e3a..357f17d5b 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -2,11 +2,11 @@ name: Docker on: push: - branches: [ "master" ] + branches: ["master"] # Publish semver tags as releases. - tags: [ 'v*.*.*' ] + tags: ["v*.*.*"] pull_request: - branches: [ "master" ] + branches: ["master"] env: # Use docker.io for Docker Hub if empty @@ -14,10 +14,8 @@ env: # github.repository as / IMAGE_NAME: ${{ github.repository }} - jobs: build: - runs-on: ubuntu-latest permissions: contents: read @@ -29,9 +27,7 @@ jobs: fail-fast: true matrix: version: - - 2.4.6-p3 - - 2.4.5-p5 - - 2.4.4-p6 + - 2.4.6-p5 steps: - name: Checkout repository @@ -43,7 +39,7 @@ jobs: if: github.event_name != 'pull_request' uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1 with: - cosign-release: 'v2.1.1' + cosign-release: "v2.1.1" # Set up BuildKit Docker container builder to be able to build # multi-platform images and export cache @@ -70,7 +66,7 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=raw,value=${{ matrix.version }} - + # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: Build and push Docker image diff --git a/Dockerfile.hbs b/Dockerfile.hbs index 26186f2d9..1dddf0ad1 100644 --- a/Dockerfile.hbs +++ b/Dockerfile.hbs @@ -1,4 +1,4 @@ -FROM ghcr.io/alexcheng1982/docker-apache2-php8:{{phpVersion}} +FROM {{baseImage}}:{{phpVersion}} LABEL maintainer="alexcheng1982@gmail.com" LABEL php_version="{{phpVersion}}" @@ -9,7 +9,7 @@ ENV MAGENTO_VERSION {{magento2Version}} ENV INSTALL_DIR /var/www/html ENV COMPOSER_HOME /var/www/.composer/ -RUN curl -sS https://getcomposer.org/installer | php \ +RUN curl -sS https://getcomposer.org/installer | php {{composerInstallArgs}}\ && mv composer.phar /usr/local/bin/composer COPY ./auth.json $COMPOSER_HOME @@ -38,7 +38,7 @@ RUN chsh -s /bin/bash www-data RUN chown -R www-data:www-data /var/www -RUN su www-data -c "composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition $INSTALL_DIR $MAGENTO_VERSION" +RUN su www-data -c "COMPOSER_MEMORY_LIMIT=-1 composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition $INSTALL_DIR $MAGENTO_VERSION" RUN cd $INSTALL_DIR \ && find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + \ diff --git a/README.md b/README.md index 172dc4302..0dfb3b5cf 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,15 @@ This repo provides Docker images for different Magento 2.4 versions. Refer to [this page](https://github.com/alexcheng1982/docker-magento2/pkgs/container/docker-magento2/versions) to see all available versions. -| Version | Container image | -| ---------- | ------------------------------------------------ | -| `2.4.6-p3` | `ghcr.io/alexcheng1982/docker-magento2:2.4.6-p3` | -| `2.4.5-p5` | `ghcr.io/alexcheng1982/docker-magento2:2.4.5-p5` | -| `2.4.4-p6` | `ghcr.io/alexcheng1982/docker-magento2:2.4.4-p6` | +| Version | PHP Version | Container image | +| ---------- | ----------- | ------------------------------------------------ | +| `2.4.6-p3` | `8.1` | `ghcr.io/alexcheng1982/docker-magento2:2.4.6-p3` | +| `2.4.5-p5` | `8.1` | `ghcr.io/alexcheng1982/docker-magento2:2.4.5-p5` | +| `2.4.4-p6` | `8.1` | `ghcr.io/alexcheng1982/docker-magento2:2.4.4-p6` | This docker image is based on my [docker-apache2-php8](https://github.com/alexcheng1982/docker-apache2-php8) image for Apache 2 and PHP 8. Please refer to the image label `php_version` for the actual PHP version. In general, Magento uses PHP `8.1` starting from `2.4.4`. Versions `2.4.2` and `2.4.3` use PHP `7.4`. Please refer to the label `php_version` of the image to get the actual PHP version. -> This docker image is based on [phusion/baseimage-docker](https://github.com/phusion/baseimage-docker) with Ubuntu 22.04 LTS. The reason to use `phusion/baseimage-docker` is to support multiple processes, which is important to get cron jobs working in Magento. +> This docker image is based on [phusion/baseimage-docker](https://github.com/phusion/baseimage-docker) with Ubuntu 22.04 LTS. The reason to use `phusion/baseimage-docker` is to support multiple processes, which is important to get cronjobs working in Magento. **Please note: this Docker image is for Magento 2 related development and testing only, not ready for production use. Setting up a Magento 2 production server requires more configurations. You can use this image as the base to build customized images.** @@ -87,7 +87,7 @@ Please see the following video for a quick demo. ## Installation -After starting the container, you'll see the setup page of Magento 2. You can use the script `install-magento` to quickly install Magento 2. The installation script uses the variables in the `env` file. Use `docker ps` to find the container name; +After starting the container, you'll see the setup page of Magento 2. You can use the script `install-magento` to quickly install Magento 2. The installation script uses the variables in the `env` file. Use `docker ps` to find the container name. ### Magento 2 @@ -132,7 +132,7 @@ If the default port `80` cannot be used for some reasons, you can change to a di You can add a volume to folder `/var/www/html`, see the `docker-compose.yml` file. -``` +```yaml volumes: - magento-data:/var/www/html ``` diff --git a/docker-compose.yaml.hbs b/docker-compose.yaml.hbs index 352ac8563..c89cded31 100644 --- a/docker-compose.yaml.hbs +++ b/docker-compose.yaml.hbs @@ -15,7 +15,7 @@ services: env_file: - env db: - image: mysql:8.0.0 + image: mysql:{{mysqlVersion}} volumes: - db-data:/var/lib/mysql env_file: diff --git a/update.js b/update.js index 632213117..b4faca7c0 100644 --- a/update.js +++ b/update.js @@ -6,19 +6,28 @@ const path = require("path"); const versions = [ { + baseImage: "ghcr.io/alexcheng1982/docker-apache2-php8", phpVersion: "8.1", - magento2Version: "2.4.6-p3", + magento2Version: "2.4.6-p5", openSearchVersion: "2", + mysqlVersion: "8.0.0", + composerInstallArgs: "", }, { + baseImage: "ghcr.io/alexcheng1982/docker-apache2-php8", phpVersion: "8.1", magento2Version: "2.4.5-p5", openSearchVersion: "1", + mysqlVersion: "8.0.0", + composerInstallArgs: "", }, { + baseImage: "ghcr.io/alexcheng1982/docker-apache2-php8", phpVersion: "8.1", magento2Version: "2.4.4-p6", openSearchVersion: "1", + mysqlVersion: "8.0.0", + composerInstallArgs: "", }, ]; diff --git a/versions/2.4.4-p6/Dockerfile b/versions/2.4.4-p6/Dockerfile index ac0d11de2..f514bb215 100644 --- a/versions/2.4.4-p6/Dockerfile +++ b/versions/2.4.4-p6/Dockerfile @@ -38,7 +38,7 @@ RUN chsh -s /bin/bash www-data RUN chown -R www-data:www-data /var/www -RUN su www-data -c "composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition $INSTALL_DIR $MAGENTO_VERSION" +RUN su www-data -c "COMPOSER_MEMORY_LIMIT=-1 composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition $INSTALL_DIR $MAGENTO_VERSION" RUN cd $INSTALL_DIR \ && find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + \ diff --git a/versions/2.4.5-p5/Dockerfile b/versions/2.4.5-p5/Dockerfile index 759bb2ebb..e747d42c5 100644 --- a/versions/2.4.5-p5/Dockerfile +++ b/versions/2.4.5-p5/Dockerfile @@ -38,7 +38,7 @@ RUN chsh -s /bin/bash www-data RUN chown -R www-data:www-data /var/www -RUN su www-data -c "composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition $INSTALL_DIR $MAGENTO_VERSION" +RUN su www-data -c "COMPOSER_MEMORY_LIMIT=-1 composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition $INSTALL_DIR $MAGENTO_VERSION" RUN cd $INSTALL_DIR \ && find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + \ diff --git a/versions/2.4.6-p3/Dockerfile b/versions/2.4.6-p3/Dockerfile index c8adcbc20..c4fe6ceea 100644 --- a/versions/2.4.6-p3/Dockerfile +++ b/versions/2.4.6-p3/Dockerfile @@ -38,7 +38,7 @@ RUN chsh -s /bin/bash www-data RUN chown -R www-data:www-data /var/www -RUN su www-data -c "composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition $INSTALL_DIR $MAGENTO_VERSION" +RUN su www-data -c "COMPOSER_MEMORY_LIMIT=-1 composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition $INSTALL_DIR $MAGENTO_VERSION" RUN cd $INSTALL_DIR \ && find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + \ diff --git a/versions/2.4.6-p5/Dockerfile b/versions/2.4.6-p5/Dockerfile new file mode 100644 index 000000000..cd4cfe67b --- /dev/null +++ b/versions/2.4.6-p5/Dockerfile @@ -0,0 +1,62 @@ +FROM ghcr.io/alexcheng1982/docker-apache2-php8:8.1 + +LABEL maintainer="alexcheng1982@gmail.com" +LABEL php_version="8.1" +LABEL magento_version="2.4.6-p5" +LABEL description="Magento Open Source 2.4.6-p5 with PHP 8.1" + +ENV MAGENTO_VERSION 2.4.6-p5 +ENV INSTALL_DIR /var/www/html +ENV COMPOSER_HOME /var/www/.composer/ + +RUN curl -sS https://getcomposer.org/installer | php \ + && mv composer.phar /usr/local/bin/composer +COPY ./auth.json $COMPOSER_HOME + +RUN requirements="libpng++-dev libzip-dev libmcrypt-dev libmcrypt4 libcurl3-dev libfreetype6 libjpeg-turbo8 libjpeg-turbo8-dev libfreetype6-dev libicu-dev libxslt1-dev zip unzip libxml2 libonig-dev" \ + set -eux; \ + apt-get update; \ + apt-get install -y $requirements; \ + rm -rf /var/lib/apt/lists/* + +RUN set -eux; \ + docker-php-ext-install pdo_mysql; \ + docker-php-ext-configure gd --with-freetype --with-jpeg; \ + docker-php-ext-install gd; \ + docker-php-ext-install mbstring; \ + docker-php-ext-install zip; \ + docker-php-ext-install intl; \ + docker-php-ext-install xsl; \ + docker-php-ext-install soap; \ + docker-php-ext-install sockets; \ + docker-php-ext-install bcmath + +RUN yes '' | pecl install mcrypt-1.0.6 \ + && echo 'extension=mcrypt.so' > /usr/local/etc/php/conf.d/mcrypt.ini + +RUN chsh -s /bin/bash www-data + +RUN chown -R www-data:www-data /var/www + +RUN su www-data -c "COMPOSER_MEMORY_LIMIT=-1 composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition $INSTALL_DIR $MAGENTO_VERSION" + +RUN cd $INSTALL_DIR \ + && find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + \ + && find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + \ + && chown -R :www-data . \ + && chmod u+x bin/magento + +COPY ./install-magento /usr/local/bin/install-magento +RUN chmod +x /usr/local/bin/install-magento + +COPY ./install-sampledata /usr/local/bin/install-sampledata +RUN chmod +x /usr/local/bin/install-sampledata + +RUN a2enmod rewrite +RUN echo "memory_limit=2048M" > /usr/local/etc/php/conf.d/memory-limit.ini + +RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +WORKDIR $INSTALL_DIR + +VOLUME $INSTALL_DIR \ No newline at end of file diff --git a/versions/2.4.6-p5/auth.json b/versions/2.4.6-p5/auth.json new file mode 100644 index 000000000..8506a6847 --- /dev/null +++ b/versions/2.4.6-p5/auth.json @@ -0,0 +1,8 @@ + { + "http-basic": { + "repo.magento.com": { + "username": "5310458a34d580de1700dfe826ff19a1", + "password": "255059b03eb9d30604d5ef52fca7465d" + } + } +} \ No newline at end of file diff --git a/versions/2.4.6-p5/docker-compose.yaml b/versions/2.4.6-p5/docker-compose.yaml new file mode 100644 index 000000000..1c49b92cd --- /dev/null +++ b/versions/2.4.6-p5/docker-compose.yaml @@ -0,0 +1,56 @@ +version: '3.0' +services: + web: + image: ghcr.io/alexcheng1982/docker-magento2:2.4.6-p5 + ports: + - "80:80" + links: + - db + - opensearch + depends_on: + - db + - opensearch + volumes: + - magento-data:/var/www/html + env_file: + - env + db: + image: mysql:8.0.0 + volumes: + - db-data:/var/lib/mysql + env_file: + - env + phpmyadmin: + image: phpmyadmin/phpmyadmin + ports: + - "8580:80" + links: + - db + depends_on: + - db + opensearch: + image: opensearchproject/opensearch:2 + environment: + - cluster.name=opensearch-cluster + - node.name=opensearch + - discovery.seed_hosts=opensearch + - cluster.initial_cluster_manager_nodes=opensearch + - bootstrap.memory_lock=true + - plugins.security.disabled=true + - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" + ulimits: + memlock: + soft: -1 + hard: -1 + nofile: + soft: 65536 + hard: 65536 + volumes: + - opensearch-data:/usr/share/opensearch/data + ports: + - 9200:9200 + - 9600:9600 +volumes: + magento-data: + db-data: + opensearch-data: \ No newline at end of file diff --git a/versions/2.4.6-p5/env b/versions/2.4.6-p5/env new file mode 100644 index 000000000..69c215f1c --- /dev/null +++ b/versions/2.4.6-p5/env @@ -0,0 +1,22 @@ +MYSQL_HOST=db +MYSQL_ROOT_PASSWORD=myrootpassword +MYSQL_USER=magento +MYSQL_PASSWORD=magento +MYSQL_DATABASE=magento + +MAGENTO_LANGUAGE=en_GB +MAGENTO_TIMEZONE=Pacific/Auckland +MAGENTO_DEFAULT_CURRENCY=NZD +MAGENTO_URL=http://local.magento +MAGENTO_BACKEND_FRONTNAME=admin +MAGENTO_USE_SECURE=0 +MAGENTO_BASE_URL_SECURE=0 +MAGENTO_USE_SECURE_ADMIN=0 + +MAGENTO_ADMIN_FIRSTNAME=Admin +MAGENTO_ADMIN_LASTNAME=MyStore +MAGENTO_ADMIN_EMAIL=amdin@example.com +MAGENTO_ADMIN_USERNAME=admin +MAGENTO_ADMIN_PASSWORD=magentorocks1 + +OPENSEARCH_HOST=opensearch \ No newline at end of file diff --git a/versions/2.4.6-p5/install-magento b/versions/2.4.6-p5/install-magento new file mode 100644 index 000000000..a59e0cffd --- /dev/null +++ b/versions/2.4.6-p5/install-magento @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +su www-data <