Skip to content

Commit

Permalink
Mise à jour des workflows CI pour prendre en charge PHP FPM et PHP Ap…
Browse files Browse the repository at this point in the history
…ache
  • Loading branch information
koromerzhin committed Mar 25, 2024
1 parent 91e1ef1 commit 1f8f49d
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 95 deletions.
44 changes: 41 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ jobs:
uses: zoexx/github-action-json-file-properties@release
with:
file_path: "matrix.json"
php:
phpfpm:
strategy:
fail-fast: false
matrix:
php: ${{ fromJson(needs.generatejobs.outputs.php) }}
name: PHP ${{ matrix.php.version }}
name: PHP FPM ${{ matrix.php.version }}
needs: generatejobs
runs-on: ubuntu-22.04
steps:
Expand All @@ -54,7 +54,7 @@ jobs:
- name: "Generate file SH IF LAST"
timeout-minutes: 60
if: matrix.php.disable == 'off'
run: npm run docker:build:php --folder=${{ matrix.php.version }} --xdebug=${{ matrix.php.xdebug }} --latest=${{ matrix.php.latest }}
run: npm run docker:build:php --folder=${{ matrix.php.version }} --xdebug=${{ matrix.php.xdebug }} --latest=${{ matrix.php.latest }} --select=phpfpm
- name: "Build image PHP FPM"
timeout-minutes: 60
if: matrix.php.disable == 'off'
Expand All @@ -67,6 +67,42 @@ jobs:
timeout-minutes: 60
if: matrix.php.disable == 'off'
run: npm run docker:image:ls
- name: Set up QEMU
if: github.ref == 'refs/heads/main' && matrix.php.disable == 'off'
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: github.ref == 'refs/heads/main' && matrix.php.disable == 'off'
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: github.ref == 'refs/heads/main' && matrix.php.disable == 'off'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push Docker
if: github.ref == 'refs/heads/main' && matrix.php.disable == 'off'
run: npm run docker:push:php
phpapache:
strategy:
fail-fast: false
matrix:
php: ${{ fromJson(needs.generatejobs.outputs.php) }}
name: PHP APACHE${{ matrix.php.version }}
needs: generatejobs
runs-on: ubuntu-22.04
steps:
- name: cdout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install npm dependencies
timeout-minutes: 60
if: matrix.php.disable == 'off'
run: npm install
- name: "Generate file SH IF LAST"
timeout-minutes: 60
if: matrix.php.disable == 'off'
run: npm run docker:build:php --folder=${{ matrix.php.version }} --xdebug=${{ matrix.php.xdebug }} --latest=${{ matrix.php.latest }} --select=apache
- name: "Build image PHP APACHE"
timeout-minutes: 60
if: matrix.php.disable == 'off'
Expand Down Expand Up @@ -95,3 +131,5 @@ jobs:
if: github.ref == 'refs/heads/main' && matrix.php.disable == 'off'
run: npm run docker:push:php



198 changes: 106 additions & 92 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ function getXdebug(options) {
return xdebug;
}

function getSelect(options) {
const only =
process.env.npm_config_select != undefined
? process.env.npm_config_select
: options.select;

return only;
}

function getVersions(folder) {
const versions = fs
.readdirSync(`images/${folder}`, { withFileTypes: true })
Expand All @@ -51,134 +60,139 @@ program
.description("build php images")
.option("--folder <folder>", "images version")
.option("--latest", "latest")
.option("--select", "select")
.action(async (options) => {
const selectfolder = getSelectfolder(options);
cmdbuild = [];
cmdtag = [];
versions = getVersions("phpfpm");
versions.forEach((version) => {
let versionimage = setVersionImage(selectfolder, version);
if (
selectfolder == undefined ||
selectfolder == version ||
selectfolder.split(version).length - 1 == 1
) {
cmdbuild.push(`mkdir -p build/phpfpm/${versionimage}`);
cmdbuild.push(
`cp images/phpfpm/${version}/Dockerfile build/phpfpm/${versionimage}/Dockerfile`
);
cmdbuild.push(
`sed -i 's/VERSIONIMAGE/php:${versionimage}-fpm/' build/phpfpm/${versionimage}/Dockerfile`
);
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-fpm build/phpfpm/${versionimage} --target build-phpfpm`
);
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-fpm-wordpress build/phpfpm/${versionimage} --target build-phpfpm-wordpress`
);
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-fpm-symfony build/phpfpm/${versionimage} --target build-phpfpm-symfony`
);
if (getXdebug(options) == 'on') {
if (getSelect(options) == 'phpfpm' || getSelect(options) == undefined) {
cmdbuild = [];
cmdtag = [];
versions = getVersions("phpfpm");
versions.forEach((version) => {
let versionimage = setVersionImage(selectfolder, version);
if (
selectfolder == undefined ||
selectfolder == version ||
selectfolder.split(version).length - 1 == 1
) {
cmdbuild.push(`mkdir -p build/phpfpm/${versionimage}`);
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-fpm-xdebug build/phpfpm/${versionimage} --target build-phpfpm-xdebug`
`cp images/phpfpm/${version}/Dockerfile build/phpfpm/${versionimage}/Dockerfile`
);
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-fpm-wordpress-xdebug build/phpfpm/${versionimage} --target build-phpfpm-wordpress-xdebug`
`sed -i 's/VERSIONIMAGE/php:${versionimage}-fpm/' build/phpfpm/${versionimage}/Dockerfile`
);
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-fpm-symfony-xdebug build/phpfpm/${versionimage} --target build-phpfpm-symfony-xdebug`
`docker build -t koromerzhin/php:${versionimage}-fpm build/phpfpm/${versionimage} --target build-phpfpm`
);
}
if (getLatest(options) == 'on') {
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-fpm koromerzhin/php:fpm-latest`
);
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-fpm-wordpress koromerzhin/php:fpm-wordpress-latest`
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-fpm-wordpress build/phpfpm/${versionimage} --target build-phpfpm-wordpress`
);
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-fpm-symfony koromerzhin/php:fpm-symfony-latest`
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-fpm-symfony build/phpfpm/${versionimage} --target build-phpfpm-symfony`
);
if (getXdebug(options) == 'on') {
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-fpm-xdebug build/phpfpm/${versionimage} --target build-phpfpm-xdebug`
);
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-fpm-wordpress-xdebug build/phpfpm/${versionimage} --target build-phpfpm-wordpress-xdebug`
);
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-fpm-symfony-xdebug build/phpfpm/${versionimage} --target build-phpfpm-symfony-xdebug`
);
}
if (getLatest(options) == 'on') {
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-fpm-wordpress-xdebug koromerzhin/php:fpm-latest-wordpress-xdebug`
`docker image tag koromerzhin/php:${versionimage}-fpm koromerzhin/php:fpm-latest`
);
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-fpm-symfony-xdebug koromerzhin/php:fpm-latest-symfony-xdebug`
`docker image tag koromerzhin/php:${versionimage}-fpm-wordpress koromerzhin/php:fpm-wordpress-latest`
);
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-fpm-xdebug koromerzhin/php:fpm-latest-xdebug`
`docker image tag koromerzhin/php:${versionimage}-fpm-symfony koromerzhin/php:fpm-symfony-latest`
);
if (getXdebug(options) == 'on') {
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-fpm-wordpress-xdebug koromerzhin/php:fpm-latest-wordpress-xdebug`
);
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-fpm-symfony-xdebug koromerzhin/php:fpm-latest-symfony-xdebug`
);
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-fpm-xdebug koromerzhin/php:fpm-latest-xdebug`
);
}
}
}
}
});
saveInFile('build', cmdbuild, "fpm", selectfolder);
saveInFile('tag', cmdtag, "fpm", selectfolder);
cmdbuild = [];
cmdtag = [];
versions = getVersions("php-apache");
versions.forEach((version) => {
let versionimage = setVersionImage(selectfolder, version);
if (
selectfolder == undefined ||
selectfolder == version ||
selectfolder.split(version).length - 1 == 1
) {
cmdbuild.push(`mkdir -p build/php-apache/${versionimage}`);
cmdbuild.push(
`cp images/php-apache/${version}/Dockerfile build/php-apache/${versionimage}/Dockerfile`
);
cmdbuild.push(
`sed -i 's/VERSIONIMAGE/php:${versionimage}-apache/' build/php-apache/${versionimage}/Dockerfile`
);
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-apache build/php-apache/${versionimage} --target build-php-apache`
);
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-apache-wordpress build/php-apache/${versionimage} --target build-php-apache-wordpress`
);
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-apache-symfony build/php-apache/${versionimage} --target build-php-apache-symfony`
);
if (getXdebug(options) == 'on') {
});
saveInFile('build', cmdbuild, "fpm", selectfolder);
saveInFile('tag', cmdtag, "fpm", selectfolder);
}
if (getSelect(options) == 'apache' || getSelect(options) == undefined) {
cmdbuild = [];
cmdtag = [];
versions = getVersions("php-apache");
versions.forEach((version) => {
let versionimage = setVersionImage(selectfolder, version);
if (
selectfolder == undefined ||
selectfolder == version ||
selectfolder.split(version).length - 1 == 1
) {
cmdbuild.push(`mkdir -p build/php-apache/${versionimage}`);
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-apache-xdebug build/php-apache/${versionimage} --target build-php-apache-xdebug`
`cp images/php-apache/${version}/Dockerfile build/php-apache/${versionimage}/Dockerfile`
);
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-apache-wordpress-xdebug build/php-apache/${versionimage} --target build-php-apache-wordpress-xdebug`
`sed -i 's/VERSIONIMAGE/php:${versionimage}-apache/' build/php-apache/${versionimage}/Dockerfile`
);
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-apache-symfony-xdebug build/php-apache/${versionimage} --target build-php-apache-symfony-xdebug`
);
}
if (getLatest(options) == 'on') {
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-apache koromerzhin/php:apache-latest`
`docker build -t koromerzhin/php:${versionimage}-apache build/php-apache/${versionimage} --target build-php-apache`
);
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-apache-wordpress koromerzhin/php:apache-wordpress-latest`
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-apache-wordpress build/php-apache/${versionimage} --target build-php-apache-wordpress`
);
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-apache-symfony koromerzhin/php:apache-symfony-latest`
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-apache-symfony build/php-apache/${versionimage} --target build-php-apache-symfony`
);
if (getXdebug(options) == 'on') {
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-apache-xdebug build/php-apache/${versionimage} --target build-php-apache-xdebug`
);
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-apache-wordpress-xdebug build/php-apache/${versionimage} --target build-php-apache-wordpress-xdebug`
);
cmdbuild.push(
`docker build -t koromerzhin/php:${versionimage}-apache-symfony-xdebug build/php-apache/${versionimage} --target build-php-apache-symfony-xdebug`
);
}
if (getLatest(options) == 'on') {
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-apache-xdebug koromerzhin/php:apache-latest-xdebug`
`docker image tag koromerzhin/php:${versionimage}-apache koromerzhin/php:apache-latest`
);
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-apache-wordpress-xdebug koromerzhin/php:apache-wordpress-latest-xdebug`
`docker image tag koromerzhin/php:${versionimage}-apache-wordpress koromerzhin/php:apache-wordpress-latest`
);
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-apache-symfony-xdebug koromerzhin/php:apache-symfony-latest-xdebug`
`docker image tag koromerzhin/php:${versionimage}-apache-symfony koromerzhin/php:apache-symfony-latest`
);
if (getXdebug(options) == 'on') {
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-apache-xdebug koromerzhin/php:apache-latest-xdebug`
);
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-apache-wordpress-xdebug koromerzhin/php:apache-wordpress-latest-xdebug`
);
cmdtag.push(
`docker image tag koromerzhin/php:${versionimage}-apache-symfony-xdebug koromerzhin/php:apache-symfony-latest-xdebug`
);
}
}
}
}
});
saveInFile('build', cmdbuild, "php-apache", selectfolder);
saveInFile('tag', cmdtag, "php-apache", selectfolder);
});
saveInFile('build', cmdbuild, "php-apache", selectfolder);
saveInFile('tag', cmdtag, "php-apache", selectfolder);
}
});

function saveInFile(type, cmd, image, selectfolder) {
Expand Down

0 comments on commit 1f8f49d

Please sign in to comment.