-
Notifications
You must be signed in to change notification settings - Fork 192
Enable build of multi-platform images (amd64, arm32 & arm64) #426
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2a649f7
Enable build of multi-platform images thanks to docker buildx
Quetzacoalt91 119b142
Add optio to build a single base image
Quetzacoalt91 3287700
Enable env var on python scripts for generation of prestashop/prestas…
Quetzacoalt91 aaf44f5
Update workflow to have one github action worker per base image
Quetzacoalt91 467585b
Changes from tests in GitHub actions
Quetzacoalt91 b980460
Update how to file
Quetzacoalt91 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,54 +1,72 @@ | ||
| #!/bin/bash | ||
|
|
||
| cd $(cd "$( dirname "$0" )" && pwd) | ||
| : ${PLATFORM_ARGS:="linux/arm/v7,linux/arm64/v8,linux/amd64"} | ||
| : ${DOCKER_REPOSITORY:="prestashop/base"} | ||
|
|
||
| if [ -z "$1" ] || [ "$1" == "-p" ]; then | ||
| PS_VERSIONS_FILE="tags.txt"; | ||
| else | ||
| PS_VERSIONS_FILE="$1"; | ||
| fi | ||
| set -e | ||
| cd $(cd "$( dirname "$0" )" && pwd) | ||
|
|
||
| # Default values | ||
| PS_VERSIONS_FILE="tags.txt" | ||
| SINGLE_VERSION="" | ||
| FORCE=false | ||
| while getopts ":fp" option; do | ||
| case $option in | ||
| p) | ||
| PUSH=true | ||
| ;; | ||
| f) | ||
| FORCE=true | ||
| ;; | ||
| esac | ||
| PUSH=false | ||
|
|
||
| # Parse arguments | ||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| --version) | ||
| SINGLE_VERSION="$2" | ||
| shift 2 | ||
| ;; | ||
| --file) | ||
| PS_VERSIONS_FILE="$2" | ||
| shift 2 | ||
| ;; | ||
| -f) | ||
| FORCE=true | ||
| shift | ||
| ;; | ||
| -p) | ||
| PUSH=true | ||
| shift | ||
| ;; | ||
| *) | ||
| echo "Unknown option: $1" | ||
| echo "Usage: $0 [--version <version>] [--file <filename>] [-f] [-p]" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| docker_tag_exists() { | ||
| curl --silent -f -lSL https://hub.docker.com/v2/repositories/$1/tags/$2 > /dev/null | ||
| curl --silent -f -lSL https://hub.docker.com/v2/repositories/$1/tags/$2 > /dev/null 2>&1 | ||
| } | ||
|
|
||
| docker_image() | ||
| { | ||
| if ! $FORCE && docker_tag_exists prestashop/base ${version}; then | ||
| echo "Docker Image already pushed : prestashop/base:$version" | ||
| docker_image() { | ||
| version="$1" | ||
| if ! $FORCE && docker_tag_exists ${DOCKER_REPOSITORY} ${version}; then | ||
| echo "Docker Image already pushed : $DOCKER_REPOSITORY:$version" | ||
| return | ||
| else | ||
| echo "Docker build & tag : prestashop/base:$version" | ||
| id=$(echo $(docker build --quiet=true images/${version} 2>/dev/null) | awk '{print $NF}') | ||
| echo $id; | ||
| docker tag $id prestashop/base:${version} | ||
|
|
||
|
|
||
| if [ -z "$PUSH" ]; then | ||
| # Do not push | ||
| return | ||
| fi | ||
| echo "Docker Push : prestashop/base:$version" | ||
|
|
||
| docker push prestashop/base:${version} | ||
| echo "Docker build & tag : $DOCKER_REPOSITORY:$version" | ||
| docker buildx build \ | ||
| --progress=plain \ | ||
| --platform ${PLATFORM_ARGS} \ | ||
| --builder container \ | ||
| --tag ${DOCKER_REPOSITORY}:${version} \ | ||
| $([ "$PUSH" == "true" ] && echo "--push") \ | ||
| images/${version} | ||
| fi | ||
| } | ||
|
|
||
|
|
||
| # Generate base images for PHP tags | ||
| echo "Reading tags in ${PS_VERSIONS_FILE} ..." | ||
| while read version; do | ||
| docker_image $version | ||
| done < $PS_VERSIONS_FILE | ||
| if [ -n "$SINGLE_VERSION" ]; then | ||
| echo "Building single version: $SINGLE_VERSION" | ||
| docker_image "$SINGLE_VERSION" | ||
| else | ||
| echo "Reading tags in ${PS_VERSIONS_FILE} ..." | ||
| while read -r version; do | ||
| [ -z "$version" ] && continue | ||
| docker_image "$version" | ||
| done < "$PS_VERSIONS_FILE" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.