diff --git a/.drone.star b/.drone.star new file mode 100644 index 0000000000000000000000000000000000000000..f231cb81853767a0ec41c30e8920de2dcffbeb23 --- /dev/null +++ b/.drone.star @@ -0,0 +1,152 @@ +matrix = [ + { + 'PHP_VERSION': '5', + 'ALPINE_VERSION': ['3.8', '3.7'], + 'TESTING_REPO': 0, + 'PHP_SESSION': 0, + }, + { + 'PHP_VERSION': '7', + 'ALPINE_VERSION': ['3.15', '3.14', '3.13', '3.12', '3.11', '3.10', '3.9', '3.8', '3.7'], + 'TESTING_REPO': 0, + 'PHP_SESSION': 1, + }, + { + 'PHP_VERSION': '8', + 'TESTING_REPO': 0, + 'PHP_SESSION': 1, + 'ALPINE_VERSION': ['3.16', '3.15', '3.14', '3.13'], + }, + { + 'PHP_VERSION': '81', + 'ALPINE_VERSION': ['edge', 'latest', '3.16', '3.17'], + 'TESTING_REPO': 0, + 'PHP_SESSION': 1, + }, + { + 'PHP_VERSION': '82', + 'ALPINE_VERSION': ['edge'], + 'TESTING_REPO': 1, + 'PHP_SESSION': 1, + } + ] + +def main(ctx): + return [buildContainer(step['PHP_VERSION'], ALPINE_VERSION, step['TESTING_REPO'], step['PHP_SESSION']) for step in matrix for ALPINE_VERSION in step['ALPINE_VERSION']] + +def buildContainer(PHP_VERSION, ALPINE_VERSION, TESTING_REPO, PHP_SESSION): + return { + 'kind': 'pipeline', + 'type': 'docker', + 'name': 'php' + PHP_VERSION + '-alpine' + ALPINE_VERSION, + 'steps': [ + { + 'name': 'detect-image-tag', + 'image': 'archlinux', + 'commands': [ + '''if [[ "$DRONE_BRANCH" == "master" ]]; then + tag="latest"; + echo "Running on default branch '$DRONE_BRANCH': tag = 'latest'"; + else + tag="$DRONE_BRANCH"; + echo "Running on branch '$DRONE_BRANCH': tag = $tag"; + fi''', + 'echo "tag=$tag" >> .env' + ] + }, + { + 'name': 'detect-registry-urls', + 'image': 'archlinux', + 'commands': [ + 'echo "Repo: $DRONE_REPO"', + 'registry_image=$(echo "$DRONE_GIT_HTTP_URL" | awk -F "://" \'{print $2}\' | awk -F ".git" \'{print tolower($1)}\')', + 'registry_domain=$(echo "$registry_image" | awk -F "/" \'{print $1}\')', + 'echo "registry_image=$registry_image" >> .env', + 'echo "registry_domain=$registry_domain" >> .env' + ] + }, + { + 'name': 'login to registry', + 'image': 'docker:dind', + 'volumes': [ + { + 'name': 'docker', + 'path': '/root/.docker' + } + ], + 'environment': { + 'DOCKER_PASSWORD': { + 'from_secret': 'docker_password' + } + }, + 'commands': [ + 'source .env', + 'cat .env', + 'echo $DOCKER_PASSWORD | docker login --username $DRONE_REPO_OWNER --password-stdin $registry_domain' + ] + }, + { + 'name': 'wait for docker', + 'image': 'archlinux', + 'volumes': [ + { + 'name': 'sockets', + 'path': '/var/run' + }, + ], + 'commands': [ + '''while [ ! -S /var/run/docker.sock ]; do + echo "Waiting for docker socket..." + sleep 1 + done''' + ] + }, + { + 'name': 'build image', + 'image': 'docker:dind', + 'volumes': [ + { + 'name': 'sockets', + 'path': '/var/run' + }, + { + 'name': 'docker', + 'path': '/root/.docker' + } + ], + 'commands': [ + 'source .env', + 'cat .env', + 'docker context create build', + 'docker buildx create build --use', + 'docker buildx build --squash --platform linux/amd64,linux/arm,linux/arm64 --push --build-arg PHP_VERSION=' + PHP_VERSION + ' --build-arg ALPINE_VERSION=' + ALPINE_VERSION + ' --build-arg TESTING_REPO=' + str(TESTING_REPO) + ' --build-arg PHP_SESSION=' + str(PHP_SESSION) + ' -t $registry_image:${tag}' + PHP_VERSION + '-' + ALPINE_VERSION + ' .' + ] + } + ], + 'services': [ + { + 'name': 'docker', + 'image': 'docker:dind', + 'privileged': True, + 'environment': { + 'DOCKER_TLS_CERTDIR': '/certs' + }, + 'volumes': [ + { + 'name': 'sockets', + 'path': '/var/run' + } + ] + } + ], + 'volumes': [ + { + 'name': 'sockets', + 'temp': {} + }, + { + 'name': 'docker', + 'temp': {} + } + ], + } \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 28b830b8457719ccf12c0c4945519c20660a81ba..0e61d2b5e19d6d900eb57f6665048ee8bcd1d312 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,57 +1,63 @@ .parallel: parallel: matrix: - - PHP_VERSION: "7" - ALPINE_VERSION: ["3.15", "3.14", "3.13", "3.12", "3.11", "3.10"] - TESTING_REPO: 0 - PHP_SESSION: 1 - - - PHP_VERSION: "8" - TESTING_REPO: 0 - PHP_SESSION: 1 - ALPINE_VERSION: ["3.16", "3.15", "3.14", "3.13"] - - - PHP_VERSION: "81" - ALPINE_VERSION: [edge, "latest", "3.16", "3.17", "3.18", "3.19"] - TESTING_REPO: 0 - PHP_SESSION: 1 - - - PHP_VERSION: "82" - ALPINE_VERSION: [edge, "latest", "3.18", "3.19"] - TESTING_REPO: 0 - PHP_SESSION: 1 - - - PHP_VERSION: "83" - ALPINE_VERSION: [edge, "latest", "3.19"] - TESTING_REPO: 0 - PHP_SESSION: 1 + + - PHP_VERSION: "7" + ALPINE_VERSION: ["3.15"] + TESTING_REPO: 0 + PHP_SESSION: 1 + + - PHP_VERSION: "8" + TESTING_REPO: 0 + PHP_SESSION: 1 + ALPINE_VERSION: ["3.16", "3.15"] + + - PHP_VERSION: "81" + ALPINE_VERSION: ["3.16", "3.17", "3.18", "3.19"] + TESTING_REPO: 0 + PHP_SESSION: 1 + + - PHP_VERSION: "82" + ALPINE_VERSION: [edge, "latest", "3.18", "3.19", "3.20"] + TESTING_REPO: 0 + PHP_SESSION: 1 + + - PHP_VERSION: "83" + ALPINE_VERSION: [edge, "latest", "3.20", "3.19"] + TESTING_REPO: 0 + PHP_SESSION: 1 + + - PHP_VERSION: "84" + ALPINE_VERSION: [edge] + TESTING_REPO: 1 + PHP_SESSION: 1 docker-build: # Use the official docker image. image: gitlab.jonasled.de/jonasled/buildx-docker:latest retry: 2 stage: build - parallel: !reference [.parallel,parallel] + parallel: !reference [.parallel, parallel] services: - - docker:dind + - docker:dind before_script: - - docker context create build - - docker buildx create build --use - - docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d - - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + - docker context create build + - docker buildx create build --use + - docker run --rm --privileged docker/binfmt:66f9012c56a8316f9244ffd7622d7c21c1f6f28d + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY # Default branch leaves tagempty (= latest tag) # All other branches are tagged with the escaped branch name (commit ref slug) script: - - | - if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then - tag="" - else - tag="$CI_COMMIT_REF_SLUG-" - fi - - docker buildx build --platform linux/amd64,linux/arm64 --provenance false --build-arg TESTING_REPO=${TESTING_REPO} --build-arg ALPINE_VERSION=${ALPINE_VERSION} --build-arg PHP_VERSION=${PHP_VERSION} --build-arg PHP_SESSION=${PHP_SESSION} --push --tag "$CI_REGISTRY_IMAGE:${tag}${PHP_VERSION}-${ALPINE_VERSION}" . + - | + if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then + tag="" + else + tag="$CI_COMMIT_REF_SLUG-" + fi + - docker buildx build --platform linux/amd64,linux/arm64 --provenance false --build-arg TESTING_REPO=${TESTING_REPO} --build-arg ALPINE_VERSION=${ALPINE_VERSION} --build-arg PHP_VERSION=${PHP_VERSION} --build-arg PHP_SESSION=${PHP_SESSION} --push --tag "$CI_REGISTRY_IMAGE:${tag}${PHP_VERSION}-${ALPINE_VERSION}" . # Run this job in a branch where a Dockerfile exists rules: - - if: $CI_COMMIT_BRANCH - exists: - - Dockerfile + - if: $CI_COMMIT_BRANCH + exists: + - Dockerfile diff --git a/Readme.md b/Readme.md index e357fedd8431ec6df29f31eeb3d977769e29a2f7..18360228cc166bb22cac79b21b0c40a4bbdcfdd1 100644 --- a/Readme.md +++ b/Readme.md @@ -18,26 +18,20 @@ This is a Alpine Linux based Docker Container, which comes with nginx and PHP pr The Image is available in multiple PHP and alpine versions. The following tag name will be used for every image: `<branch>-<php version>-<alpine version>`. For the master branch, the branch tag is not included. At the moment the following versions are available: |PHP Version|Alpine Version|Tag Name|Notes |---|---|---|---| +|8.4|edge|84-edge|Still in beta| +|8.3|3.20|83-3.20|| +|8.3|3.19|3-3.19|| |8.3|latest|83-latest|| |8.3|edge|83-edge|| -|8.3|3.19|83-3.19|| -|8.2|latest|82-latest|| -|8.2|edge|82-edge|| +|8.2|3.20|82-3.20|| |8.2|3.19|82-3.19|| |8.2|3.18|82-3.18|| -|8.1|latest|81-latest|| -|8.1|edge|81-edge|| -|8.1|3.19|81-3.19|| -|8.1|3.18|81-3.18|| -|8.1|3.17|81-3.17|| +|8.2|latest|82-latest|| +|8.2|edge|82-edge|| |8.1|3.16|81-3.16|| +|8.1|3.17|81-3.17|| +|8.1|3.18|81-3.18|| +|8.1|3.19|81-3.19|| |8.0|3.16|8-3.16|| |8.0|3.15|8-3.15|| -|8.0|3.14|8-3.14|| -|8.0|3.13|8-3.13|| |7.4|3.15|7-3.15|| -|7.4|3.14|7-3.14|| -|7.4|3.13|7-3.13|| -|7.3|3.12|7-3.12|| -|7.3|3.11|7-3.11|| -|7.3|3.10|7-3.10||