Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

make PHP Version configurable #6822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
Loading
from
Open

Conversation

Spirit-act
Copy link

This merge request is a follow up to #6770 and issue #6769.

Changes

It adds a build arg to specify the PHP Version you want to build.

I also updated the COMPOSER_ALLOW_SUPERUSER env variable to the current format.

Docker Hub

I could not figure out, how to Docker Hub Containers are build, but with this Dockerfile and a matrix pipeline, multiple versions could be build and published.

Add a build arg to specify the PHP Version to build with.

Also change legacy ENV declaration.

Signed-off-by: Spirit-act <16631523+Spirit-act@users.noreply.github.com>
@Naktibalda
Copy link
Member

@Spirit-act
Copy link
Author

Spirit-act commented Feb 14, 2025

Thanks for the Link, I forgot to look at the GitHub wiki.

If I understand correctly, in order to adopt my changes, only the docs section for the build needs to be changed.

cd Codeception

# Build with default PHP Version (8.1)
docker build --no-cache --pull -t codeception/codeception:5.0.3 .
docker build --no-cache --pull --build-arg flavor=alpine -t codeception/codeception:5.0.3-alpine .

# Push default build
docker push codeception/codeception:5.0.3
docker push codeception/codeception:5.0.3-alpine


# Build with PHP 8.2
docker build --no-cache --pull \
    --build-arg flavor=PHP_VERSION=8.2 -t codeception/codeception:5.0.3-php8.2 .
docker build --no-cache --pull \
    --build-arg flavor=PHP_VERSION=8.2 \
    --build-arg flavor=alpine -t codeception/codeception:5.0.3-php8.2-alpine .

# Push PHP8.2 build
docker push codeception/codeception:5.0.3-php8.2
docker push codeception/codeception:5.0.3-php8.2-alpine


# Build with PHP 8.3
docker build --no-cache --pull \
    --build-arg flavor=PHP_VERSION=8.3 -t codeception/codeception:5.0.3-php8.3 .
docker build --no-cache --pull \
    --build-arg flavor=PHP_VERSION=8.3 \
    --build-arg flavor=alpine -t codeception/codeception:5.0.3-php8.3-alpine .

# Push PHP8.3 build
docker push codeception/codeception:5.0.3-php8.3
docker push codeception/codeception:5.0.3-php8.3-alpine


# Build with PHP 8.4
docker build --no-cache --pull \
    --build-arg flavor=PHP_VERSION=8.4 -t codeception/codeception:5.0.3-php8.4 .
docker build --no-cache --pull \
    --build-arg flavor=PHP_VERSION=8.4 \
    --build-arg flavor=alpine -t codeception/codeception:5.0.3-php8.4-alpine .

# Push PHP8.4 build
docker push codeception/codeception:5.0.3-php8.4
docker push codeception/codeception:5.0.3-php8.4-alpine


# Tag default build as latest
docker tag codeception/codeception:5.0.3 codeception/codeception:latest
docker tag codeception/codeception:5.0.3-alpine codeception/codeception:latest-alpine

# Push latest tag
docker push codeception/codeception:latest
docker push codeception/codeception:latest-alpine

It would also be possible to wrap this in a script. Example:

#!/bin/bash

PHP_VERSIONS=(
    '8.1'
    '8.2'
    '8.3'
    '8.4'
)

if [[ -z "$1" ]]; then
    echo "Please specify the Codeception Version (e.g.: 5.0.3)."
    exit 1;
fi

echo " - build default images - "
docker build --no-cache --pull -t codeception/codeception:${1} .
docker build --no-cache --pull --build-arg flavor=alpine -t codeception/codeception:${1}-alpine .
echo ""

for VERSION in "${PHP_VERSIONS[@]}"; do
    echo " - build ${VERSION} image - "
    docker build --no-cache --pull --build-arg flavor=PHP_VERSION=$VERSION -t codeception/codeception:${1}-php${VERSION} .
    docker build --no-cache --pull --build-arg flavor=PHP_VERSION=$VERSION --build-arg flavor=alpine -t codeception/codeception:${1}-php${VERSION}-alpine .

    echo " - push ${VERSION} image - "
    docker push codeception/codeception:${1}-php${VERSION}
    docker push codeception/codeception:${1}-php${VERSION}-alpine
    echo ""                                                                                                                                                                                                                                                                                                                 
done                                                                                                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                            
echo " - tag default build as latest - "                                                                                                                                                                                                                                                                                   
docker tag codeception/codeception:${1} codeception/codeception:latest                                                                                                                                                                                                                                                      
docker tag codeception/codeception:${1}-alpine codeception/codeception:latest-alpine                                                                                                                                                                                                                                        
                                                                                                                                                                                                                                                                                                                            
echo "- push latest tag - "                                                                                                                                                                                                                                                                                                 
docker push codeception/codeception:latest                                                                                                                                                                                                                                                                                  
docker push codeception/codeception:latest-alpine

If there is something else which needs to be done, feel free to add a comment.
Thanks in advanced.


Edit: The tags for the images are just examples and can be changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.