From e8ee078a2fc22de586923a9092e090ba26055fdf Mon Sep 17 00:00:00 2001 From: badPointer Date: Sun, 23 Jul 2023 17:10:26 +0000 Subject: [PATCH 1/2] feat: introduce Debian flavor of Docker image, use by default --- .gitlab-ci.yml | 24 ++++++++++------ Dockerfile | 6 ++-- Dockerfile.alpine | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 12 deletions(-) create mode 100644 Dockerfile.alpine diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index adaac9b..79ac1fc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -49,24 +49,30 @@ release: rules: - if: $CI_COMMIT_TAG -ncc-docker-build: +ncc-docker: image: docker:latest services: - docker:dind before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY script: - - | - if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then - tag="" - echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'" - else - tag=":$CI_COMMIT_REF_SLUG" - echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag" - fi - docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" . - docker push "$CI_REGISTRY_IMAGE${tag}" rules: - if: $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_BRANCH == 'dev' exists: - Dockerfile + +ncc-docker-alpine: + image: docker:latest + services: + - docker:dind + before_script: + - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY + script: + - docker build --pull -t "$CI_REGISTRY_IMAGE${tag}-alpine" . + - docker push "$CI_REGISTRY_IMAGE${tag}-alpine" + rules: + - if: $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_BRANCH == 'dev' + exists: + - Dockerfile.alpine diff --git a/Dockerfile b/Dockerfile index 980f2a6..931c938 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,7 +44,7 @@ RUN git clone https://git.n64.cc/nosial/ncc.git; # Main stage: Copies downloaded files and installs all # -FROM php:8.1-fpm-alpine +FROM php:8.1-fpm # Add extensions ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ @@ -57,8 +57,8 @@ RUN install-php-extensions mbstring \ ctype \ common; \ - # Add git and tar - apk add git tar; \ + # Add git + apt install -y git; \ # Install phive, phab and ncc; create workdir chmod +x phive.phar; \ diff --git a/Dockerfile.alpine b/Dockerfile.alpine new file mode 100644 index 0000000..980f2a6 --- /dev/null +++ b/Dockerfile.alpine @@ -0,0 +1,70 @@ +# Copyright 2022-2023 Nosial - All Rights Reserved. +# +# 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. +# +# ncc in Docker +# +# This image is intended to be used as a base for projects using ncc. +# + +# +# Builder stage: downloads necessary files and serves them on a silver platter. +# + +FROM php:8.1-fpm AS builder +WORKDIR /tmp + +# Install some stuff the default image doesn't come with +RUN apt update -yqq; \ + apt install git libpq-dev libzip-dev zip make wget gnupg -yqq + +# Download phive and install phab +RUN wget -O phive.phar https://phar.io/releases/phive.phar; \ + wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc; \ + gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79; \ + gpg --verify phive.phar.asc phive.phar; \ + rm phive.phar.asc; chmod +x phive.phar; ./phive.phar install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C + +# Download the latest version of ncc (Nosial Code Compiler) +RUN git clone https://git.n64.cc/nosial/ncc.git; \ + cd ncc; make redist + +# +# Main stage: Copies downloaded files and installs all +# + +FROM php:8.1-fpm-alpine + +# Add extensions +ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ + +# Copy downloaded files +COPY --from=builder /tmp/. . + +# Install extensions required to run ncc +RUN install-php-extensions mbstring \ + ctype \ + common; \ + + # Add git and tar + apk add git tar; \ + + # Install phive, phab and ncc; create workdir + chmod +x phive.phar; \ + mv phive.phar /usr/local/bin/phive; \ + phive install phpab --global --trust-gpg-keys 0x2A8299CE842DD38C; \ + cd ncc; php build/src/INSTALL --auto --install-composer; cd ..; rm -rf ncc; \ + mkdir /app + +WORKDIR /app From 0e388bbbda1534a8d26c0395ffb3a9b28b2bdd19 Mon Sep 17 00:00:00 2001 From: badPointer Date: Sun, 23 Jul 2023 17:44:04 +0000 Subject: [PATCH 2/2] feat: reverse behavior --- .gitlab-ci.yml | 8 ++++---- Dockerfile | 6 +++--- Dockerfile.alpine => Dockerfile.debian | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) rename Dockerfile.alpine => Dockerfile.debian (96%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 79ac1fc..33ff5fa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -63,16 +63,16 @@ ncc-docker: exists: - Dockerfile -ncc-docker-alpine: +ncc-docker-debian: image: docker:latest services: - docker:dind before_script: - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY script: - - docker build --pull -t "$CI_REGISTRY_IMAGE${tag}-alpine" . - - docker push "$CI_REGISTRY_IMAGE${tag}-alpine" + - docker build --pull -t "$CI_REGISTRY_IMAGE${tag}-debian" . + - docker push "$CI_REGISTRY_IMAGE${tag}-debian" rules: - if: $CI_COMMIT_BRANCH == 'master' || $CI_COMMIT_BRANCH == 'dev' exists: - - Dockerfile.alpine + - Dockerfile.debian diff --git a/Dockerfile b/Dockerfile index 931c938..980f2a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,7 +44,7 @@ RUN git clone https://git.n64.cc/nosial/ncc.git; # Main stage: Copies downloaded files and installs all # -FROM php:8.1-fpm +FROM php:8.1-fpm-alpine # Add extensions ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ @@ -57,8 +57,8 @@ RUN install-php-extensions mbstring \ ctype \ common; \ - # Add git - apt install -y git; \ + # Add git and tar + apk add git tar; \ # Install phive, phab and ncc; create workdir chmod +x phive.phar; \ diff --git a/Dockerfile.alpine b/Dockerfile.debian similarity index 96% rename from Dockerfile.alpine rename to Dockerfile.debian index 980f2a6..931c938 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.debian @@ -44,7 +44,7 @@ RUN git clone https://git.n64.cc/nosial/ncc.git; # Main stage: Copies downloaded files and installs all # -FROM php:8.1-fpm-alpine +FROM php:8.1-fpm # Add extensions ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ @@ -57,8 +57,8 @@ RUN install-php-extensions mbstring \ ctype \ common; \ - # Add git and tar - apk add git tar; \ + # Add git + apt install -y git; \ # Install phive, phab and ncc; create workdir chmod +x phive.phar; \