Skip to content
Snippets Groups Projects
Commit 715b41fc authored by Fabrice Gangler's avatar Fabrice Gangler :art:
Browse files

ci: add new Dockerfile files (replace Phive dependencies by Composer dependencies)

parent c38e554e
No related branches found
No related tags found
No related merge requests found
......@@ -3,4 +3,8 @@
Docker images of prerequisites usign by **Gitlab CI**:
- [PHP 8.1, Composer and Phive](./php.8.1_composer_phive/)
- [PHP 8.2, Composer and Phive](./php.8.2_composer_phive/)
- [PHP 8.3, Composer and Phive](./php.8.2_composer_phive/)
- [PHP 8.3, Composer and Phive](./php.8.3_composer_phive/)
- [Ubuntu 22.04, PHP 8.1 (Ubuntu packages), Composer, Symfony-CLI, Xdebug and Make](./php.8.1_composer/)
- [Ubuntu 22.04, PHP 8.2 (ppa:ondrej/php), Composer, Symfony-CLI, Xdebug and Make](./php.8.2_composer/)
- [Ubuntu 24.04, PHP 8.3 (Ubuntu packages), Composer, Symfony-CLI, Xdebug and Make](./php.8.3_composer/)
- [Ubuntu 24.04, PHP 8.4 (ppa:ondrej/php), Composer, Symfony-CLI, Xdebug and Make](./php.8.4_composer/)
FROM ubuntu:22.04
# System prerequisites
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -y --no-install-recommends \
install git \
make \
gpg-agent \
software-properties-common \
ca-certificates \
curl \
zip \
unzip \
gpg && \
rm -rf /var/lib/apt/lists/*
# Allow to use another version of PHP than Ubuntu PHP version
# RUN add-apt-repository ppa:ondrej/php
# Webapp prerequisites - Install PHP and PHP extensions
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -y --no-install-recommends \
install php8.1 \
php8.1-bcmath \
php8.1-curl \
php8.1-intl \
php8.1-mbstring \
php8.1-pgsql \
php8.1-sqlite3 \
php8.1-xdebug \
php8.1-xml \
php8.1-zip && \
rm -rf /var/lib/apt/lists/*
# PHP Xdebug extension is mandatory to use Infection tool
# Webapp prerequisites - Install COMPOSER
RUN curl -sSL https://getcomposer.org/installer --output composer-setup.php && \
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php && \
rm -v composer-setup.php && \
chmod +x composer.phar && \
mv -v composer.phar /usr/local/bin/composer && \
composer -V
# QA prerequisites - Install Symfony CLI
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN curl -sS https://get.symfony.com/cli/installer | /bin/bash && \
mv /root/.symfony5/bin/symfony /usr/local/bin/symfony && \
symfony -V
# Install all phar files declared in phive.xml
WORKDIR "/php/"
RUN REPO=https://gitlab.adullact.net/Comptoir/comptoir-du-libre.git && \
pwd && \
git clone ${REPO} source-code && \
cd /php/source-code/webapp/ && \
composer install --no-progress \
--no-interaction \
--no-scripts && \
cd /php/source-code/bin/tools_via_composer/ && \
composer install --no-progress \
--no-interaction \
--no-scripts && \
mkdir -p /php/composer-cache/tools/ && \
mkdir -p /php/composer-cache/webapp/ && \
cp /php/source-code/bin/tools_via_composer/composer.json /php/composer-cache/tools/ && \
cp /php/source-code/bin/tools_via_composer/composer.lock /php/composer-cache/tools/ && \
cp -r /php/source-code/bin/tools_via_composer/vendor /php/composer-cache/tools/ && \
cd /php/composer-cache/tools/ && \
tar -czf vendor.tar.gz vendor/ && \
cp -r /php/source-code/webapp/composer.json /php/composer-cache/webapp/ && \
cp -r /php/source-code/webapp/composer.lock /php/composer-cache/webapp/ && \
cp -r /php/source-code/webapp/vendor /php/composer-cache/webapp/ && \
cd /php/composer-cache/webapp/ && \
tar -czf vendor.tar.gz vendor/ && \
rm -rf /php/composer-cache/webapp/vendor/ && \
rm -rf /php/composer-cache/tools/vendor/ && \
rm -rf /php/source-code/
# Display software versions
RUN echo "-------------------" >> /php/software-infos.txt && \
cat /etc/os-release >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
php --version >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
php -m >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
composer -V >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
symfony -V >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
cat /php/software-infos.txt
# # DEBUG
# RUN ls -l /php/ && \
# ls -l /php/composer-cache/ && \
# ls -l /php/composer-cache/webapp && \
# cd /php/composer-cache/webapp && tar -xzf vendor.tar.gz && \
# ls -l /php/composer-cache/webapp && \
# ls -l /php/composer-cache/webapp/vendor && \
# ls -l /php/composer-cache/tools && \
# cd /php/composer-cache/tools && tar -xzf vendor.tar.gz && \
# ls -l /php/composer-cache/tools && \
# ls -l /php/composer-cache/tools/vendor
#
# # DEBUG Check cache
# RUN du -hs /root/.cache/composer/ && \
# du -hs /php/composer-cache/*
# Set Docker LABEL
LABEL version="1.0.0" \
description="CI Prerequisites : Ubuntu 22.04, PHP 8.1 (Ubuntu packages), Composer, Symfony-CLI, Xdebug and Make"
# CI Prerequisites : Ubuntu 22.04, PHP 8.1 (Ubuntu packages), Composer, Symfony-CLI, Xdebug and Make
**Table of contents**
[Toc]
-------------------------------------------------------
## CI Prerequisites
Docker image of CI Prerequisites :
- Ubuntu 22.04
- PHP **8.1** (`Ubuntu packages`)
- Composer
- Symfony-CLI
- Xdebug
- Make
-------------------------------------------------------
## To update Docker image
### Edit Dockerfile
Edit [Dockerfile](Dockerfile) according to your needs
and in addition you must to change in this file `LABEL version="1.0.0"`
following [semantic versioning](http://semver.org/) recommendations:
```shell script
MAJOR.MINOR.PATCH
# MAJOR ---> a breaking change (incompatible API changes)
# MINOR ---> add a new feature
# PATCH ---> fix a bug
```
```dockerfile
# Set Docker LABEL and display software versions
LABEL version="1.0.0" \
description="CI Prerequisites : Ubuntu 22.04, PHP 8.1 (Ubuntu packages), Composer, Symfony-CLI, Xdebug and Make"
```
### Build Docker image and push to container registry
Build new Docker image and push to [Gitlab container registry](https://gitlab.adullact.net/Comptoir/comptoir-du-libre/container_registry)
#### Configure variables in particular DOCKER_IMAGE_VERSION
```bash
# Configure variables
# in particular DOCKER_IMAGE_VERSION
# which must be identical to LABEL.version in Dockerfile
GITLAB_URI="gitlab.adullact.net:4567"
GITLAB_REPOSITORY="comptoir/comptoir-du-libre"
DOCKER_IMAGE_NAME="php-8.1_composer"
DOCKER_IMAGE_VERSION="v1.0.0" # must be identical to LABEL.version in Dockerfile
```
#### Build new Docker image (option 1: without docker cache)
Must be used to push a new Docker image (without Docker cache):
```bash
# Build new Docker image
docker images | grep "${DOCKER_IMAGE_NAME}"
docker build --no-cache --progress plain -t "${GITLAB_URI}/${GITLAB_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}" .
docker images | grep "${DOCKER_IMAGE_NAME}"
```
#### Build new Docker image (option 2: with docker cache)
Useful for debugging (with Docker cache):
```bash
# Build new Docker image
docker build --progress plain -t "${GITLAB_URI}/${GITLAB_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}" .
docker images | grep "${DOCKER_IMAGE_NAME}"
```
#### Push to Gitlab container registry
```bash
# Login to Gitlab
docker login "${GITLAB_URI}"
# Push to Gitlab container registry
docker push "${GITLAB_URI}/${GITLAB_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}"
# Logout to remove Gitlab credentials from $HOME/.docker/config.json file
docker logout "${GITLAB_URI}"
```
FROM ubuntu:22.04
# System prerequisites
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -y --no-install-recommends \
install git \
make \
gpg-agent \
software-properties-common \
ca-certificates \
curl \
zip \
unzip \
gpg && \
rm -rf /var/lib/apt/lists/*
# Allow to use another version of PHP than Ubuntu PHP version
RUN add-apt-repository ppa:ondrej/php
# Webapp prerequisites - Install PHP and PHP extensions
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -y --no-install-recommends \
install php8.2 \
php8.2-bcmath \
php8.2-curl \
php8.2-intl \
php8.2-mbstring \
php8.2-pgsql \
php8.2-sqlite3 \
php8.2-xdebug \
php8.2-xml \
php8.2-zip && \
rm -rf /var/lib/apt/lists/*
# PHP Xdebug extension is mandatory to use Infection tool
# Webapp prerequisites - Install COMPOSER
RUN curl -sSL https://getcomposer.org/installer --output composer-setup.php && \
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php && \
rm -v composer-setup.php && \
chmod +x composer.phar && \
mv -v composer.phar /usr/local/bin/composer && \
composer -V
# QA prerequisites - Install Symfony CLI
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN curl -sS https://get.symfony.com/cli/installer | /bin/bash && \
mv /root/.symfony5/bin/symfony /usr/local/bin/symfony && \
symfony -V
# Install all phar files declared in phive.xml
WORKDIR "/php/"
RUN REPO=https://gitlab.adullact.net/Comptoir/comptoir-du-libre.git && \
pwd && \
git clone ${REPO} source-code && \
cd /php/source-code/webapp/ && \
composer install --no-progress \
--no-interaction \
--no-scripts && \
cd /php/source-code/bin/tools_via_composer/ && \
composer install --no-progress \
--no-interaction \
--no-scripts && \
mkdir -p /php/composer-cache/tools/ && \
mkdir -p /php/composer-cache/webapp/ && \
cp /php/source-code/bin/tools_via_composer/composer.json /php/composer-cache/tools/ && \
cp /php/source-code/bin/tools_via_composer/composer.lock /php/composer-cache/tools/ && \
cp -r /php/source-code/bin/tools_via_composer/vendor /php/composer-cache/tools/ && \
cd /php/composer-cache/tools/ && \
tar -czf vendor.tar.gz vendor/ && \
cp -r /php/source-code/webapp/composer.json /php/composer-cache/webapp/ && \
cp -r /php/source-code/webapp/composer.lock /php/composer-cache/webapp/ && \
cp -r /php/source-code/webapp/vendor /php/composer-cache/webapp/ && \
cd /php/composer-cache/webapp/ && \
tar -czf vendor.tar.gz vendor/ && \
rm -rf /php/composer-cache/webapp/vendor/ && \
rm -rf /php/composer-cache/tools/vendor/ && \
rm -rf /php/source-code/
# Display software versions
RUN echo "-------------------" >> /php/software-infos.txt && \
cat /etc/os-release >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
php --version >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
php -m >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
composer -V >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
symfony -V >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
cat /php/software-infos.txt
# # DEBUG
# RUN ls -l /php/ && \
# ls -l /php/composer-cache/ && \
# ls -l /php/composer-cache/webapp && \
# cd /php/composer-cache/webapp && tar -xzf vendor.tar.gz && \
# ls -l /php/composer-cache/webapp && \
# ls -l /php/composer-cache/webapp/vendor && \
# ls -l /php/composer-cache/tools && \
# cd /php/composer-cache/tools && tar -xzf vendor.tar.gz && \
# ls -l /php/composer-cache/tools && \
# ls -l /php/composer-cache/tools/vendor
#
# # DEBUG Check cache
# RUN du -hs /root/.cache/composer/ && \
# du -hs /php/composer-cache/*
# Set Docker LABEL
LABEL version="1.0.0" \
description="CI Prerequisites : Ubuntu 22.04, PHP 8.2 (ppa:ondrej/php), Composer, Symfony-CLI, Xdebug and Make"
# CI Prerequisites : Ubuntu 22.04, PHP 8.2 (ppa:ondrej/php), Composer, Symfony-CLI, Xdebug and Make
**Table of contents**
[Toc]
-------------------------------------------------------
## CI Prerequisites
Docker image of CI Prerequisites :
- Ubuntu 22.04
- PHP **8.2** (`ppa:ondrej/php`)
- Composer
- Symfony-CLI
- Xdebug
- Make
-------------------------------------------------------
## To update Docker image
### Edit Dockerfile
Edit [Dockerfile](Dockerfile) according to your needs
and in addition you must to change in this file `LABEL version="1.0.0"`
following [semantic versioning](http://semver.org/) recommendations:
```shell script
MAJOR.MINOR.PATCH
# MAJOR ---> a breaking change (incompatible API changes)
# MINOR ---> add a new feature
# PATCH ---> fix a bug
```
```dockerfile
# Set Docker LABEL and display software versions
LABEL version="1.0.0" \
description="CI Prerequisites : Ubuntu 22.04, PHP 8.2 (ppa:ondrej/php), Composer, Symfony-CLI, Xdebug and Make"
```
### Build Docker image and push to container registry
Build new Docker image and push to [Gitlab container registry](https://gitlab.adullact.net/Comptoir/comptoir-du-libre/container_registry)
#### Configure variables in particular DOCKER_IMAGE_VERSION
```bash
# Configure variables
# in particular DOCKER_IMAGE_VERSION
# which must be identical to LABEL.version in Dockerfile
GITLAB_URI="gitlab.adullact.net:4567"
GITLAB_REPOSITORY="comptoir/comptoir-du-libre"
DOCKER_IMAGE_NAME="php-8.2_composer"
DOCKER_IMAGE_VERSION="v1.0.0" # must be identical to LABEL.version in Dockerfile
```
#### Build new Docker image (option 1: without docker cache)
Must be used to push a new Docker image (without Docker cache):
```bash
# Build new Docker image
docker images | grep "${DOCKER_IMAGE_NAME}"
docker build --no-cache --progress plain -t "${GITLAB_URI}/${GITLAB_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}" .
docker images | grep "${DOCKER_IMAGE_NAME}"
```
#### Build new Docker image (option 2: with docker cache)
Useful for debugging (with Docker cache):
```bash
# Build new Docker image
docker build --progress plain -t "${GITLAB_URI}/${GITLAB_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}" .
docker images | grep "${DOCKER_IMAGE_NAME}"
```
#### Push to Gitlab container registry
```bash
# Login to Gitlab
docker login "${GITLAB_URI}"
# Push to Gitlab container registry
docker push "${GITLAB_URI}/${GITLAB_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}"
# Logout to remove Gitlab credentials from $HOME/.docker/config.json file
docker logout "${GITLAB_URI}"
```
FROM ubuntu:24.04
# System prerequisites
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -y --no-install-recommends \
install git \
make \
gpg-agent \
software-properties-common \
ca-certificates \
curl \
zip \
unzip \
gpg && \
rm -rf /var/lib/apt/lists/*
# Allow to use another version of PHP than Ubuntu PHP version
# RUN add-apt-repository ppa:ondrej/php
# Webapp prerequisites - Install PHP and PHP extensions
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -y --no-install-recommends \
install php8.3 \
php8.3-bcmath \
php8.3-curl \
php8.3-intl \
php8.3-mbstring \
php8.3-pgsql \
php8.3-sqlite3 \
php8.3-xdebug \
php8.3-xml \
php8.3-zip && \
rm -rf /var/lib/apt/lists/*
# PHP Xdebug extension is mandatory to use Infection tool
# Webapp prerequisites - Install COMPOSER
RUN curl -sSL https://getcomposer.org/installer --output composer-setup.php && \
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php && \
rm -v composer-setup.php && \
chmod +x composer.phar && \
mv -v composer.phar /usr/local/bin/composer && \
composer -V
# QA prerequisites - Install Symfony CLI
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN curl -sS https://get.symfony.com/cli/installer | /bin/bash && \
mv /root/.symfony5/bin/symfony /usr/local/bin/symfony && \
symfony -V
# Install all phar files declared in phive.xml
WORKDIR "/php/"
RUN REPO=https://gitlab.adullact.net/Comptoir/comptoir-du-libre.git && \
pwd && \
git clone ${REPO} source-code && \
cd /php/source-code/webapp/ && \
composer install --no-progress \
--no-interaction \
--no-scripts && \
cd /php/source-code/bin/tools_via_composer/ && \
composer install --no-progress \
--no-interaction \
--no-scripts && \
mkdir -p /php/composer-cache/tools/ && \
mkdir -p /php/composer-cache/webapp/ && \
cp /php/source-code/bin/tools_via_composer/composer.json /php/composer-cache/tools/ && \
cp /php/source-code/bin/tools_via_composer/composer.lock /php/composer-cache/tools/ && \
cp -r /php/source-code/bin/tools_via_composer/vendor /php/composer-cache/tools/ && \
cd /php/composer-cache/tools/ && \
tar -czf vendor.tar.gz vendor/ && \
cp -r /php/source-code/webapp/composer.json /php/composer-cache/webapp/ && \
cp -r /php/source-code/webapp/composer.lock /php/composer-cache/webapp/ && \
cp -r /php/source-code/webapp/vendor /php/composer-cache/webapp/ && \
cd /php/composer-cache/webapp/ && \
tar -czf vendor.tar.gz vendor/ && \
rm -rf /php/composer-cache/webapp/vendor/ && \
rm -rf /php/composer-cache/tools/vendor/ && \
rm -rf /php/source-code/
# Display software versions
RUN echo "-------------------" >> /php/software-infos.txt && \
cat /etc/os-release >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
php --version >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
php -m >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
composer -V >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
symfony -V >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
cat /php/software-infos.txt
# # DEBUG
# RUN ls -l /php/ && \
# ls -l /php/composer-cache/ && \
# ls -l /php/composer-cache/webapp && \
# cd /php/composer-cache/webapp && tar -xzf vendor.tar.gz && \
# ls -l /php/composer-cache/webapp && \
# ls -l /php/composer-cache/webapp/vendor && \
# ls -l /php/composer-cache/tools && \
# cd /php/composer-cache/tools && tar -xzf vendor.tar.gz && \
# ls -l /php/composer-cache/tools && \
# ls -l /php/composer-cache/tools/vendor
#
# # DEBUG Check cache
# RUN du -hs /root/.cache/composer/ && \
# du -hs /php/composer-cache/*
# Set Docker LABEL
LABEL version="1.0.0" \
description="CI Prerequisites : Ubuntu 24.04, PHP 8.3 (Ubuntu packages), Composer, Symfony-CLI, Xdebug and Make"
# CI Prerequisites : Ubuntu 24.04, PHP 8.3 (Ubuntu packages), Composer, Symfony-CLI, Xdebug and Make
**Table of contents**
[Toc]
-------------------------------------------------------
## CI Prerequisites
Docker image of CI Prerequisites :
- Ubuntu 24.04
- PHP **8.3** (`Ubuntu packages`)
- Composer
- Symfony-CLI
- Xdebug
- Make
-------------------------------------------------------
## To update Docker image
### Edit Dockerfile
Edit [Dockerfile](Dockerfile) according to your needs
and in addition you must to change in this file `LABEL version="1.0.0"`
following [semantic versioning](http://semver.org/) recommendations:
```shell script
MAJOR.MINOR.PATCH
# MAJOR ---> a breaking change (incompatible API changes)
# MINOR ---> add a new feature
# PATCH ---> fix a bug
```
```dockerfile
# Set Docker LABEL and display software versions
LABEL version="1.0.0" \
description="CI Prerequisites : Ubuntu 24.04, PHP 8.3 (Ubuntu packages), Composer, Symfony-CLI, Xdebug and Make"
```
### Build Docker image and push to container registry
Build new Docker image and push to [Gitlab container registry](https://gitlab.adullact.net/Comptoir/comptoir-du-libre/container_registry)
#### Configure variables in particular DOCKER_IMAGE_VERSION
```bash
# Configure variables
# in particular DOCKER_IMAGE_VERSION
# which must be identical to LABEL.version in Dockerfile
GITLAB_URI="gitlab.adullact.net:4567"
GITLAB_REPOSITORY="comptoir/comptoir-du-libre"
DOCKER_IMAGE_NAME="php-8.3_composer"
DOCKER_IMAGE_VERSION="v1.0.0" # must be identical to LABEL.version in Dockerfile
```
#### Build new Docker image (option 1: without docker cache)
Must be used to push a new Docker image (without Docker cache):
```bash
# Build new Docker image
docker images | grep "${DOCKER_IMAGE_NAME}"
docker build --no-cache --progress plain -t "${GITLAB_URI}/${GITLAB_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}" .
docker images | grep "${DOCKER_IMAGE_NAME}"
```
#### Build new Docker image (option 2: with docker cache)
Useful for debugging (with Docker cache):
```bash
# Build new Docker image
docker build --progress plain -t "${GITLAB_URI}/${GITLAB_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}" .
docker images | grep "${DOCKER_IMAGE_NAME}"
```
#### Push to Gitlab container registry
```bash
# Login to Gitlab
docker login "${GITLAB_URI}"
# Push to Gitlab container registry
docker push "${GITLAB_URI}/${GITLAB_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}"
# Logout to remove Gitlab credentials from $HOME/.docker/config.json file
docker logout "${GITLAB_URI}"
```
FROM ubuntu:24.04
# System prerequisites
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -y --no-install-recommends \
install git \
make \
gpg-agent \
software-properties-common \
ca-certificates \
curl \
zip \
unzip \
gpg && \
rm -rf /var/lib/apt/lists/*
# Allow to use another version of PHP than Ubuntu PHP version
RUN add-apt-repository ppa:ondrej/php
# Webapp prerequisites - Install PHP and PHP extensions
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -y --no-install-recommends \
install php8.4 \
php8.4-bcmath \
php8.4-curl \
php8.4-intl \
php8.4-mbstring \
php8.4-pgsql \
php8.4-sqlite3 \
php8.4-xdebug \
php8.4-xml \
php8.4-zip && \
rm -rf /var/lib/apt/lists/*
# PHP Xdebug extension is mandatory to use Infection tool
# Webapp prerequisites - Install COMPOSER
RUN curl -sSL https://getcomposer.org/installer --output composer-setup.php && \
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
php composer-setup.php && \
rm -v composer-setup.php && \
chmod +x composer.phar && \
mv -v composer.phar /usr/local/bin/composer && \
composer -V
# QA prerequisites - Install Symfony CLI
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN curl -sS https://get.symfony.com/cli/installer | /bin/bash && \
mv /root/.symfony5/bin/symfony /usr/local/bin/symfony && \
symfony -V
# Install all phar files declared in phive.xml
WORKDIR "/php/"
RUN REPO=https://gitlab.adullact.net/Comptoir/comptoir-du-libre.git && \
pwd && \
git clone ${REPO} source-code && \
cd /php/source-code/webapp/ && \
composer install --no-progress \
--no-interaction \
--no-scripts && \
cd /php/source-code/bin/tools_via_composer/ && \
composer install --no-progress \
--no-interaction \
--no-scripts && \
mkdir -p /php/composer-cache/tools/ && \
mkdir -p /php/composer-cache/webapp/ && \
cp /php/source-code/bin/tools_via_composer/composer.json /php/composer-cache/tools/ && \
cp /php/source-code/bin/tools_via_composer/composer.lock /php/composer-cache/tools/ && \
cp -r /php/source-code/bin/tools_via_composer/vendor /php/composer-cache/tools/ && \
cd /php/composer-cache/tools/ && \
tar -czf vendor.tar.gz vendor/ && \
cp -r /php/source-code/webapp/composer.json /php/composer-cache/webapp/ && \
cp -r /php/source-code/webapp/composer.lock /php/composer-cache/webapp/ && \
cp -r /php/source-code/webapp/vendor /php/composer-cache/webapp/ && \
cd /php/composer-cache/webapp/ && \
tar -czf vendor.tar.gz vendor/ && \
rm -rf /php/composer-cache/webapp/vendor/ && \
rm -rf /php/composer-cache/tools/vendor/ && \
rm -rf /php/source-code/
# Display software versions
RUN echo "-------------------" >> /php/software-infos.txt && \
cat /etc/os-release >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
php --version >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
php -m >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
composer -V >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
symfony -V >> /php/software-infos.txt && \
echo "-------------------" >> /php/software-infos.txt && \
cat /php/software-infos.txt
# # DEBUG
# RUN ls -l /php/ && \
# ls -l /php/composer-cache/ && \
# ls -l /php/composer-cache/webapp && \
# cd /php/composer-cache/webapp && tar -xzf vendor.tar.gz && \
# ls -l /php/composer-cache/webapp && \
# ls -l /php/composer-cache/webapp/vendor && \
# ls -l /php/composer-cache/tools && \
# cd /php/composer-cache/tools && tar -xzf vendor.tar.gz && \
# ls -l /php/composer-cache/tools && \
# ls -l /php/composer-cache/tools/vendor
#
# # DEBUG Check cache
# RUN du -hs /root/.cache/composer/ && \
# du -hs /php/composer-cache/*
# Set Docker LABEL
LABEL version="1.0.0" \
description="CI Prerequisites : Ubuntu 24.04, PHP 8.4 (ppa:ondrej/php), Composer, Symfony-CLI, Xdebug and Make"
# CI Prerequisites : Ubuntu 24.04, PHP 8.4 (ppa:ondrej/php), Composer, Symfony-CLI, Xdebug and Make
**Table of contents**
[Toc]
-------------------------------------------------------
## CI Prerequisites
Docker image of CI Prerequisites :
- Ubuntu 24.04
- PHP **8.4** (`ppa:ondrej/php`)
- Composer
- Symfony-CLI
- Xdebug
- Make
-------------------------------------------------------
## To update Docker image
### Edit Dockerfile
Edit [Dockerfile](Dockerfile) according to your needs
and in addition you must to change in this file `LABEL version="1.0.0"`
following [semantic versioning](http://semver.org/) recommendations:
```shell script
MAJOR.MINOR.PATCH
# MAJOR ---> a breaking change (incompatible API changes)
# MINOR ---> add a new feature
# PATCH ---> fix a bug
```
```dockerfile
# Set Docker LABEL and display software versions
LABEL version="1.0.0" \
description="CI Prerequisites : Ubuntu 24.04, PHP 8.4 (ppa:ondrej/php), Composer, Symfony-CLI, Xdebug and Make"
```
### Build Docker image and push to container registry
Build new Docker image and push to [Gitlab container registry](https://gitlab.adullact.net/Comptoir/comptoir-du-libre/container_registry)
#### Configure variables in particular DOCKER_IMAGE_VERSION
```bash
# Configure variables
# in particular DOCKER_IMAGE_VERSION
# which must be identical to LABEL.version in Dockerfile
GITLAB_URI="gitlab.adullact.net:4567"
GITLAB_REPOSITORY="comptoir/comptoir-du-libre"
DOCKER_IMAGE_NAME="php-8.4_composer"
DOCKER_IMAGE_VERSION="v1.0.0" # must be identical to LABEL.version in Dockerfile
```
#### Build new Docker image (option 1: without docker cache)
Must be used to push a new Docker image (without Docker cache):
```bash
# Build new Docker image
docker images | grep "${DOCKER_IMAGE_NAME}"
docker build --no-cache --progress plain -t "${GITLAB_URI}/${GITLAB_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}" .
docker images | grep "${DOCKER_IMAGE_NAME}"
```
#### Build new Docker image (option 2: with docker cache)
Useful for debugging (with Docker cache):
```bash
# Build new Docker image
docker build --progress plain -t "${GITLAB_URI}/${GITLAB_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}" .
docker images | grep "${DOCKER_IMAGE_NAME}"
```
#### Push to Gitlab container registry
```bash
# Login to Gitlab
docker login "${GITLAB_URI}"
# Push to Gitlab container registry
docker push "${GITLAB_URI}/${GITLAB_REPOSITORY}/${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION}"
# Logout to remove Gitlab credentials from $HOME/.docker/config.json file
docker logout "${GITLAB_URI}"
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment