Compare commits

...

13 Commits

Author SHA1 Message Date
Mathieu Jaumotte 6d8b858cc8 Merge branch 'php82' into main 2023-03-30 15:56:17 +02:00
Julien Fastré 571d662737 Merge pull request 'Feature: build a php base image usable for CI' (#1) from php82_ci into php82
Reviewed-on: #1
2023-02-17 15:41:16 +00:00
Julien Fastré 78a98bff40
Feature: publish base image 2023-02-17 16:39:53 +01:00
Mathieu Jaumotte 2f18130e72 Revert "remove gd deps"
This reverts commit eb059453282539b899b3dbdce72cb970d5c28bff.
2023-02-08 09:36:41 +01:00
Julien Fastré 2af27e8b42 Feature: add php-cs-fixer to the base image
Php-cs-fixer have conflicts with the symfony and doctrine version in use for us.

I propose to add it to the image until php-cs-fixer becomes compatible again with our dependencies.

This commit also add the environment variable PHP_CS_FIXER_IGNORE_ENV to make it works with php 8.2 (currently, it does not work with php > 8.1)
2023-02-08 09:36:41 +01:00
Mathieu Jaumotte fcd00855f9 improve DockerFile deps to avoid errors with chill 2023-02-08 09:36:41 +01:00
Mathieu Jaumotte e9c478c062 adapt Makefile and rename chill_php occurences by chill_php82 2023-02-08 09:36:41 +01:00
Mathieu Jaumotte d38e9a5c0a add shell preference 2023-02-08 09:36:41 +01:00
Mathieu Jaumotte b63a4f2a5f finish image 2023-02-08 09:36:41 +01:00
Mathieu Jaumotte 1a1188c612 merge deps RUN blocks to optimize 2023-02-08 09:36:41 +01:00
Mathieu Jaumotte 39b9e839c2 remove gd deps 2023-02-08 09:36:41 +01:00
Mathieu Jaumotte 23c438f0d7 add postgresql-client 2023-02-08 09:36:41 +01:00
Mathieu Jaumotte a4fd3dbeb6 Upgrade chill_base_php image to PHP8: install deps and php extension 2023-02-08 09:36:41 +01:00
6 changed files with 83 additions and 30 deletions

View File

@ -79,3 +79,36 @@ steps:
Dockerfile: docker/nginx/Dockerfile Dockerfile: docker/nginx/Dockerfile
depends_on: depends_on:
- build-assets - build-assets
---
kind: pipeline
type: docker
name: build-base-image-php82
trigger:
event:
- cron
- push
cron:
- base-image-php82
steps:
- name: build-base-image
image: plugins/docker
settings:
username:
from_secret: docker_username_gitea
password:
from_secret: docker_password_gitea
registry: gitea.champs-libres.be/chill-project/chill-skeleton-basic
repo: gitea.champs-libres.be/chill-project/chill-skeleton-basic/base-image
tag: php82
target: chill_base_php82
pull_image: true
---
kind: signature
hmac: 212da184e3fedeb03530cc66dbf9c8974e461e214dda5a698b11012e66e4531a
...

View File

@ -1,4 +1,4 @@
FROM php:7.4-fpm-buster AS chill_base_php FROM php:8.2-fpm-alpine AS chill_base_php82
ENV POSTGRES_VERSION 14 ENV POSTGRES_VERSION 14
@ -6,27 +6,31 @@ ENV POSTGRES_VERSION 14
ARG UID=1000 ARG UID=1000
ARG GID=1000 ARG GID=1000
RUN apt update && apt -y --no-install-recommends install wget gnupg \ # install php extensions and deps
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \ RUN apk update && apk add --no-cache \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" > /etc/apt/sources.list.d/pgdg.list \ wget gnupg \
&& apt update && apt -y --no-install-recommends install \ libpq-dev \
libicu-dev \ icu-dev icu-libs icu-data-full \
g++ \ oniguruma-dev \
postgresql-server-dev-$POSTGRES_VERSION \ libzip libzip-dev \
libzip-dev libzip4 unzip \ linux-headers \
libfreetype6-dev \ gcc g++ make autoconf \
libonig-dev `# install oniguruma, required for mbstring` \ bash git \
libpng-dev \ && docker-php-ext-install pdo_pgsql intl mbstring zip bcmath exif sockets \
libjpeg62-turbo-dev \ && git clone https://github.com/nikic/php-ast.git \
git \ && cd php-ast \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \ && phpize \
&& docker-php-ext-install -j$(nproc) gd \ && ./configure \
&& docker-php-ext-install intl pdo_pgsql mbstring zip bcmath sockets exif \ && make install \
&& pecl install redis \ && echo 'extension=ast.so' > /usr/local/etc/php/php.ini \
&& docker-php-ext-enable redis \ && cd .. && rm -rf php-ast \
&& apt remove -y wget libicu-dev g++ gnupg libzip-dev \ && pecl install redis \
&& apt autoremove -y \ && docker-php-ext-enable redis \
&& apt purge -y && apk add libpng-dev libjpeg-turbo-dev freetype-dev \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd \
&& apk add postgresql${POSTGRES_VERSION}-client \
&& apk del --purge wget gnupg libpq-dev icu-dev oniguruma-dev libzip-dev linux-headers gcc g++ make autoconf
RUN { \ RUN { \
echo ""; \ echo ""; \
@ -41,15 +45,31 @@ RUN { \
echo ""; \ echo ""; \
} >> /usr/local/etc/php/conf.d/date.ini } >> /usr/local/etc/php/conf.d/date.ini
# temporary fix, while php-cs-fixer has conflict dependencies
# with chill
RUN curl -o /usr/local/bin/php-cs-fixer https://cs.symfony.com/download/php-cs-fixer-v3.phar \
&& chmod +x /usr/local/bin/php-cs-fixer
# to make php-cs-fixer works with php 8.2
ENV PHP_CS_FIXER_IGNORE_ENV=1
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
ENV COMPOSER_ALLOW_SUPERUSER=1 ENV COMPOSER_ALLOW_SUPERUSER=1
ENV COMPOSER_MEMORY_LIMIT=-1 ENV COMPOSER_MEMORY_LIMIT=-1
# shell bash preference
RUN sed -i " \
s|root:x:0:0:root:/root:/bin/ash|root:x:0:0:root:/root:/bin/bash|g; \
s|postgres:x:70:70:PostgreSQL user:/var/lib/postgresql:/bin/sh|postgres:x:70:70:PostgreSQL user:/var/lib/postgresql:/bin/bash|g" \
/etc/passwd
# chmod on redis.so
RUN chmod 755 -R /usr/local/lib/php/extensions/
WORKDIR /var/www/app WORKDIR /var/www/app
CMD ["php-fpm"] CMD ["php-fpm"]
FROM chill_base_php AS chill_php FROM chill_base_php82 AS chill_php82
# copy directories # copy directories

View File

@ -2,12 +2,12 @@ THIS_FILE := $(lastword $(MAKEFILE_LIST))
PWD:=$(shell echo ${PWD}) PWD:=$(shell echo ${PWD})
UID:=$(shell id -u) UID:=$(shell id -u)
GID:=$(shell id -g) GID:=$(shell id -g)
BASE_TAG=chill_base_php BASE_TAG=chill_base_php82
DOCKERNODE_CMD=docker run --rm --user ${UID}:${GID} -v ${PWD}:/app --workdir /app -e YARN_CACHE_FOLDER=/app/.yarncache node:16 DOCKERNODE_CMD=docker run --rm --user ${UID}:${GID} -v ${PWD}:/app --workdir /app -e YARN_CACHE_FOLDER=/app/.yarncache node:16
DOCKER_COMPOSE_PHP_EXEC_CMD=docker-compose run --rm --user $(UID):$(GID) -e CLEAR_CACHE=false -e COMPOSER_HOME=/var/www/app/.composer --entrypoint /usr/bin/env php DOCKER_COMPOSE_PHP_EXEC_CMD=docker-compose run --rm --user $(UID):$(GID) -e CLEAR_CACHE=false -e COMPOSER_HOME=/var/www/app/.composer --entrypoint /usr/bin/env php
DOCKER_PHP_EXEC_CMD_BASE=docker run --rm --user $(UID):$(GID) -v ${PWD}:/var/www/app -e CLEAR_CACHE=false -e COMPOSER_HOME=/var/www/app/.composer --entrypoint /usr/bin/env $(BASE_TAG) DOCKER_PHP_EXEC_CMD_BASE=docker run --rm --user $(UID):$(GID) -v ${PWD}:/var/www/app -e CLEAR_CACHE=false -e COMPOSER_HOME=/var/www/app/.composer --entrypoint /usr/bin/env $(BASE_TAG)
PHP_BASE_IMAGE=php:7.4-fpm-buster PHP_BASE_IMAGE=php:8.2-fpm-alpine
PHP_BASE_IMAGE_CHILL=chill_base_php PHP_BASE_IMAGE_CHILL=chill_php82
NGINX_BASE_IMAGE=nginx NGINX_BASE_IMAGE=nginx
CALVER=$(shell date "+v%Y%m%d%H%M")-${CALVERSION} CALVER=$(shell date "+v%Y%m%d%H%M")-${CALVERSION}
ifneq (,$(wildcard ./.env)) ifneq (,$(wildcard ./.env))
@ -39,7 +39,7 @@ build-assets:
$(DOCKERNODE_CMD) yarn run encore production $(DOCKERNODE_CMD) yarn run encore production
init: init:
docker build --target chill_base_php -t $(BASE_TAG) . docker build --target $(PHP_BASE_IMAGE_CHILL) -t $(BASE_TAG) .
$(DOCKER_PHP_EXEC_CMD_BASE) composer update --no-scripts --no-interaction $(DOCKER_PHP_EXEC_CMD_BASE) composer update --no-scripts --no-interaction
@$(MAKE) -f $(THIS_FILE) build-assets @$(MAKE) -f $(THIS_FILE) build-assets
@$(MAKE) -f $(THIS_FILE) post-install @$(MAKE) -f $(THIS_FILE) post-install

View File

@ -8,7 +8,7 @@ services:
args: args:
UID: ${PHP_FPM_USER:-1000} UID: ${PHP_FPM_USER:-1000}
# uncomment and set your own image if needed # uncomment and set your own image if needed
image: ${IMAGE_PHP-chill_php}:${VERSION:-latest} image: ${IMAGE_PHP-chill_php82}:${VERSION:-latest}
volumes: volumes:
- .:/var/www/app - .:/var/www/app
environment: environment:

View File

@ -10,7 +10,7 @@ services:
args: args:
UID: ${PHP_FPM_USER:-1000} UID: ${PHP_FPM_USER:-1000}
# uncomment and set your own image if needed # uncomment and set your own image if needed
image: ${IMAGE_PHP-chill_php}:${VERSION:-latest} image: ${IMAGE_PHP-chill_php82}:${VERSION:-latest}
# #
# normally, you should not mount any volume and use your own image # normally, you should not mount any volume and use your own image
# #

View File

@ -8,7 +8,7 @@ services:
args: args:
UID: ${PHP_FPM_USER:-1000} UID: ${PHP_FPM_USER:-1000}
# uncomment and set your own image if needed # uncomment and set your own image if needed
image: ${IMAGE_PHP:-chill_php}:${VERSION:-latest} image: ${IMAGE_PHP:-chill_php82}:${VERSION:-latest}
volumes: volumes:
- .:/var/www/app - .:/var/www/app
environment: environment: