Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
Revert "first commit"
Browse files Browse the repository at this point in the history
This reverts commit e96f2d3.
  • Loading branch information
sanderhartman committed May 23, 2024
1 parent e96f2d3 commit 795e1c6
Show file tree
Hide file tree
Showing 18 changed files with 548 additions and 96 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build & Push Docker Images

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'

jobs:
generate-jobs:
name: Generate Jobs
runs-on: ubuntu-latest
outputs:
strategy: ${{ steps.generate-jobs.outputs.strategy }}
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 14
- uses: php-actions/composer@v5
with:
only_args: --version
- name: Add Composer Credentials
run: composer config -g http-basic.repo.magento.com ${{ secrets.COMPOSER_AUTH_USERNAME }} ${{ secrets.COMPOSER_AUTH_PASSWORD }}
- name: Add Magento Composer Repository
run: composer config -g repo.packagist false && composer config -g repositories.repo.magento.com composer https://repo.magento.com
- id: install-dependencies
name: Install NPM Dependencies
run: npm install
working-directory: ./lib
- id: generate-jobs
name: Generate Jobs
run: echo "::set-output name=strategy::{\"matrix\":{\"include\":$(npm run --silent versions)}}"
working-directory: ./lib

build:
needs: generate-jobs
strategy: ${{ fromJson(needs.generate-jobs.outputs.strategy) }}
name: "${{ matrix.version }}-php-${{ matrix.php.version }}-${{ matrix.php.variant }}"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- id: build
name: Build
run: ${{ matrix.build }}
- id: push
name: Push
run: docker push weprovide/magento --all-tags
- id: images
name: Images
run: docker image ls
24 changes: 24 additions & 0 deletions .github/workflows/readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Push README to Docker Hub

on:
workflow_dispatch:
push:
paths:
- 'README.md'

jobs:
push-readme:
runs-on: ubuntu-latest
name: Push README to Docker Hub
steps:
- uses: actions/checkout@v2
- name: Push README to Docker Hub
uses: christian-korneck/update-container-description-action@v1
env:
DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKER_PASS: ${{ secrets.DOCKERHUB_PASSWORD }}
with:
destination_container_repo: weprovide/magento
provider: dockerhub
short_description: 'A Docker image meant to be used in CI / CD processes for Magento platforms and environments'
readme_file: 'README.md'
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/magento-docker-image.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/magento2plugin.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

19 changes: 0 additions & 19 deletions .idea/php.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

35 changes: 0 additions & 35 deletions Dockerfile

This file was deleted.

54 changes: 54 additions & 0 deletions Dockerfile.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
FROM php:${php.version}-cli-${php.variant}

# Magento 2 does not support Composer 2
COPY --from=composer:1 /usr/bin/composer /usr/bin/composer

<% if (php.variant.startsWith('alpine')) { %>
RUN apk add --no-cache unzip \
rsync \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
icu-dev \
libxslt-dev \
libzip-dev \
curl \
g++ \
make \
libxml2-dev \
git \
libsodium-dev
<% } else { %>
RUN apt-get update && apt-get install -y \
unzip \
rsync \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libicu-dev \
libxslt-dev \
libzip-dev \
curl \
build-essential \
libxml2-dev \
git-core \
libsodium-dev
<% } %>

# See https://github.com/docker-library/php/issues/912#issuecomment-559918036
<% if (semver.satisfies(semver.coerce(php.version), '>= 7.4')) { %>
RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ && docker-php-ext-install gd
<% } else { %>
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && docker-php-ext-install gd
<% } %>

RUN docker-php-ext-install intl
RUN docker-php-ext-install xsl
RUN docker-php-ext-install zip
RUN docker-php-ext-install pdo pdo_mysql
RUN docker-php-ext-install soap
RUN docker-php-ext-install bcmath
RUN docker-php-ext-install sodium

# "sockets" is only necessary for Magento >= 2.4 but apparently Magento Commerce (EE) 2.3 requires it as well
RUN docker-php-ext-install sockets
25 changes: 25 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
The MIT License (MIT)
=====================

Copyright © `2021` `Julian van den Berkmortel`

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the “Software”), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Docker with PHP 8.1
# Magento Docker Image
I couldn't really find what I needed. A Docker image which was kept up-to-date and included everything necessary to be used in a CI / CD process.

Dockerfile to create a docker image with PHP-FPM 8.1 and Composer 2. You can use this docker image for CI/CD
purposes and build your Magento 2 application. You can find the image
at [Docker hub](https://hub.docker.com/repository/docker/sanderhartman/magento2-php81-imagick/general).

With added support for Image Magick
I decided to create a repository which uses GitHub Actions to periodically build and push Docker images based on the latest supported Magento versions.
1 change: 1 addition & 0 deletions lib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
69 changes: 69 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env node
const fs = require('fs');
const { execSync } = require('child_process');
const path = require('path');
const semver = require('semver');
const _ = require('lodash');
const tags = require('./tags');

const matrix = [];
const semverVersions = JSON.parse(fs.readFileSync(path.join(__dirname, '../versions.json'), { encoding: 'utf-8' }));

let magentoVersions = JSON.parse(execSync('composer show --all --format=json magento/project-community-edition')).versions
.map(semver.parse)
.map(magentoSemver => `${magentoSemver.major}.${magentoSemver.minor}`)
.reduce((deduplicated, magentoVersion) => {
if (deduplicated.indexOf(magentoVersion) === -1) {
deduplicated.push(magentoVersion);
}

return deduplicated;
}, []);

const dockerfile = fs.readFileSync(path.join(__dirname, '../Dockerfile.template'), { encoding: 'utf-8' });

let matrixVersions = [];

for (const magentoVersion of magentoVersions) {
for (const [semverVersion, semverMetrixConfig] of Object.entries(semverVersions)) {
// coerce the "major.minor" notation into "major.minor.patch" so that it can satisfy the semver notation
if (semver.satisfies(semver.coerce(magentoVersion).toString(), semverVersion)) {
for (const phpVariant of semverMetrixConfig.php) {
matrixVersions.push({
magento: magentoVersion,
php: phpVariant.version,
variant: phpVariant.variant
});
}

break;
}
}
}

matrixVersions = tags(matrixVersions);

// run: echo '${{ matrix.dockerfile }}' | docker build --build-arg PHP=${{ matrix.php.version }} --build-arg VARIANT=${{ matrix.php.variant }} --tag weprovide/magento:${{ matrix.version }}-php-${{ matrix.php.version }}-${{ matrix.php.variant }} -

for (const matrixVersion of matrixVersions) {
const matrixDockerfile = _.template(dockerfile)({
magento: matrixVersion.version.magento,
php: {
version: matrixVersion.version.php,
variant: matrixVersion.version.variant
},
semver
});

const tags = matrixVersion.tags.map(tag => `--tag weprovide/magento:${tag}`).join(' ');

matrix.push({
version: matrixVersion.version.magento,
php: {
version: matrixVersion.version.php,
variant: matrixVersion.version.variant
},
build: `echo '${matrixDockerfile}' | docker build ${tags} -`});
}

process.stdout.write(JSON.stringify(matrix));
Loading

0 comments on commit 795e1c6

Please sign in to comment.