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

chore(Dockerfile): delete unused Dockerfile files

parent 3ab43fc3
No related branches found
No related tags found
No related merge requests found
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-xml \
php8.2-zip && \
rm -rf /var/lib/apt/lists/*
# QA prerequisites - Install PHIVE
RUN curl -sSL https://phar.io/releases/phive.phar --output phive.phar && \
chmod +x phive.phar && \
mv -v phive.phar /usr/local/bin/phive && \
phive --version
# 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
# Caching of all PHP dependencies declared in composer.json files
WORKDIR "/php/"
RUN REPO=https://gitlab.adullact.net/adullact/pki/tajine.git && \
pwd && \
git clone ${REPO} && \
cd tajine/ && \
phive install --force-accept-unsigned \
--trust-gpg-keys \
661E97400F658E25,96141E4421A9B0D5,033E5F8D801A2F8D,F4D32E2C9343B2AE,B8F640134AB1782E,AA36B9960B5B823D,C5095986493B4AA0,8101FB57DD8130F0,95DE904AB800754A11D80B605E6DDE998AB73B8E,4AA394086372C20A,9093F8B32E4815AA,51C67305FFC2E5C0,E82B2FB314E9906E,12CE0F1D262429A5 && \
cd webapp/ && \
composer install --no-progress \
--no-suggest \
--no-interaction \
--no-scripts && \
rm -rf /php/tajine/
# 661E97400F658E25 ---> captainhook
# 96141E4421A9B0D5 ---> churn
# 033E5F8D801A2F8D ---> composer-require-checker
# F4D32E2C9343B2AE ---> composer-unused
# B8F640134AB1782E ---> deptrac
# AA36B9960B5B823D ---> grumphp
# C5095986493B4AA0 ---> infection
# 8101FB57DD8130F0 ---> phan
# 95DE904AB800754A11D80B605E6DDE998AB73B8E ---> phpcbf, phpcs
# 4AA394086372C20A ---> phpcpd, phploc, phpunit
# 9093F8B32E4815AA ---> phpmd
# 51C67305FFC2E5C0 ---> phpstan
# E82B2FB314E9906E ---> php-cs-fixer
# ---> php-parallel-lint ---> TODO use --force-accept-unsigned option
# 12CE0F1D262429A5 ---> psalm
# CI prerequisites - Install PHP extensions mandatory to use Infection tool
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -y --no-install-recommends \
install php8.2-xdebug && \
rm -rf /var/lib/apt/lists/*
# Check cache
RUN ls -l /root/.phive/phars/ && \
du -hs /root/.phive/phars/ && \
du -hs /root/.cache/composer/
# Display software versions
RUN echo "-------------------" && php --version && \
echo "-------------------" && composer -V && \
echo "-------------------" && phive --version && \
echo "-------------------" && symfony -V && \
echo "-------------------"
# Set Docker LABEL
LABEL version="1.0.0" \
description="Prerequisites for PHP 8.2, Composer, Phive, Symfony-CLI, Xdebug and Make"
# CI ~ Prerequisites for PHP 8.2, Composer and Phive
Docker image of prerequisites for PHP **8.2**, Composer and Phive.
## 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="Prerequisites for PHP 8.2, Composer and Phive"
```
### Build Docker image and push to container registry
Build new Docker image and push to [Gitlab container registry](https://gitlab.adullact.net/adullact/pki/tajine/container_registry)
```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="adullact/pki/tajine"
DOCKER_IMAGE_NAME="php-8.2_composer_phive"
DOCKER_IMAGE_VERSION="v1.0.0" # must be identical to LABEL.version in Dockerfile
# Login to Gitlab
docker login "${GITLAB_URI}"
# 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
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.3 \
php8.3-bcmath \
php8.3-curl \
php8.3-intl \
php8.3-mbstring \
php8.3-pgsql \
php8.3-xml \
php8.3-zip && \
rm -rf /var/lib/apt/lists/*
# QA prerequisites - Install PHIVE
RUN curl -sSL https://phar.io/releases/phive.phar --output phive.phar && \
chmod +x phive.phar && \
mv -v phive.phar /usr/local/bin/phive && \
phive --version
# 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
# Caching of all PHP dependencies declared in composer.json files
WORKDIR "/php/"
RUN REPO=https://gitlab.adullact.net/adullact/pki/tajine.git && \
pwd && \
git clone ${REPO} && \
cd tajine/ && \
phive install --force-accept-unsigned \
--trust-gpg-keys \
661E97400F658E25,96141E4421A9B0D5,033E5F8D801A2F8D,F4D32E2C9343B2AE,B8F640134AB1782E,AA36B9960B5B823D,C5095986493B4AA0,8101FB57DD8130F0,95DE904AB800754A11D80B605E6DDE998AB73B8E,4AA394086372C20A,9093F8B32E4815AA,51C67305FFC2E5C0,E82B2FB314E9906E,12CE0F1D262429A5 && \
cd webapp/ && \
composer install --no-progress \
--no-suggest \
--no-interaction \
--no-scripts && \
rm -rf /php/tajine/
# 661E97400F658E25 ---> captainhook
# 96141E4421A9B0D5 ---> churn
# 033E5F8D801A2F8D ---> composer-require-checker
# F4D32E2C9343B2AE ---> composer-unused
# B8F640134AB1782E ---> deptrac
# AA36B9960B5B823D ---> grumphp
# C5095986493B4AA0 ---> infection
# 8101FB57DD8130F0 ---> phan
# 95DE904AB800754A11D80B605E6DDE998AB73B8E ---> phpcbf, phpcs
# 4AA394086372C20A ---> phpcpd, phploc, phpunit
# 9093F8B32E4815AA ---> phpmd
# 51C67305FFC2E5C0 ---> phpstan
# E82B2FB314E9906E ---> php-cs-fixer
# ---> php-parallel-lint ---> TODO use --force-accept-unsigned option
# 12CE0F1D262429A5 ---> psalm
# CI prerequisites - Install PHP extensions mandatory to use Infection tool
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -y --no-install-recommends \
install php8.3-xdebug && \
rm -rf /var/lib/apt/lists/*
# Check cache
RUN ls -l /root/.phive/phars/ && \
du -hs /root/.phive/phars/ && \
du -hs /root/.cache/composer/
# Display software versions
RUN echo "-------------------" && php --version && \
echo "-------------------" && composer -V && \
echo "-------------------" && phive --version && \
echo "-------------------" && symfony -V && \
echo "-------------------"
# Set Docker LABEL
LABEL version="1.0.0" \
description="Prerequisites for PHP 8.3, Composer, Phive, Symfony-CLI, Xdebug and Make"
# CI ~ Prerequisites for PHP 8.3, Composer and Phive
Docker image of prerequisites for PHP **8.3**, Composer and Phive.
## 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="Prerequisites for PHP 8.3, Composer and Phive"
```
### Build Docker image and push to container registry
Build new Docker image and push to [Gitlab container registry](https://gitlab.adullact.net/adullact/pki/tajine/container_registry)
```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="adullact/pki/tajine"
DOCKER_IMAGE_NAME="php-8.3_composer_phive"
DOCKER_IMAGE_VERSION="v1.0.0" # must be identical to LABEL.version in Dockerfile
# Login to Gitlab
docker login "${GITLAB_URI}"
# 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
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