Skip to content

Commit

Permalink
Merge pull request afup#1389 from stakovicz/feat-1374-docker-change-p…
Browse files Browse the repository at this point in the history
…hp-7.0

feat 1374: docker change PHP 7
  • Loading branch information
agallou authored Jan 6, 2024
2 parents 19e0c96 + bf3c219 commit 82d4e55
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 287 deletions.
2 changes: 1 addition & 1 deletion .env-dist
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## Options to pass to `docker-compose up` command
## Options to pass to `docker compose up` command
#DOCKER_UP_OPTIONS= -d # -d will launch container in detached mode
#ENABLE_XDEBUG=true # enable the PHP xDebug extension
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ js_dist
/bin/php-cs-fixer
/bin/simple-phpunit
/bin/vobject
/docker-compose.override.yml
/compose.override.yml
/composer.phar
/data

45 changes: 23 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,30 @@

CURRENT_UID ?= $(shell id -u)
DOCKER_UP_OPTIONS ?=
DOCKER_COMPOSE_BIN ?= docker compose

.PHONY: install docker-up docker-stop docker-down test hooks vendors db-seed db-migrations reset-db init console phpstan

install: vendors

docker-up: .env var/logs/.docker-build data docker-compose.override.yml
CURRENT_UID=$(CURRENT_UID) docker-compose up $(DOCKER_UP_OPTIONS)
docker-up: .env var/logs/.docker-build data compose.override.yml
CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) up $(DOCKER_UP_OPTIONS)

docker-stop:
CURRENT_UID=$(CURRENT_UID) docker-compose stop
CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) stop

docker-down:
CURRENT_UID=$(CURRENT_UID) docker-compose down
CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) down

var/logs/.docker-build: docker-compose.yml docker-compose.override.yml $(shell find docker -type f)
CURRENT_UID=$(CURRENT_UID) ENABLE_XDEBUG=$(ENABLE_XDEBUG) docker-compose build
var/logs/.docker-build: compose.yml compose.override.yml $(shell find docker -type f)
CURRENT_UID=$(CURRENT_UID) ENABLE_XDEBUG=$(ENABLE_XDEBUG) $(DOCKER_COMPOSE_BIN) build
touch var/logs/.docker-build

.env:
cp .env-dist .env

docker-compose.override.yml:
cp docker-compose.override.yml-dist docker-compose.override.yml
compose.override.yml:
cp compose.override.yml-dist compose.override.yml

vendors: vendor node_modules

Expand Down Expand Up @@ -58,24 +59,24 @@ init:

init-db:
make reset-db
CURRENT_UID=$(CURRENT_UID) docker-compose run --rm cliphp make db-migrations
CURRENT_UID=$(CURRENT_UID) docker-compose run --rm cliphp make db-seed
CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) run --rm cliphp make db-migrations
CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) run --rm cliphp make db-seed

config: configs/application/config.php app/config/parameters.yml
CURRENT_UID=$(CURRENT_UID) docker-compose run --no-deps --rm cliphp make vendors
CURRENT_UID=$(CURRENT_UID) docker-compose run --no-deps --rm cliphp make assets
CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) run --no-deps --rm cliphp make vendors
CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) run --no-deps --rm cliphp make assets

test:
./bin/atoum
./bin/php-cs-fixer fix --dry-run -vv


test-functional: data config htdocs/uploads
CURRENT_UID=$(CURRENT_UID) docker-compose stop dbtest apachephptest planetetest mailcatcher
CURRENT_UID=$(CURRENT_UID) docker-compose up -d dbtest apachephptest planetetest mailcatcher
CURRENT_UID=$(CURRENT_UID) docker-compose run --no-deps --rm cliphp ./bin/behat
CURRENT_UID=$(CURRENT_UID) docker-compose run --no-deps --rm cliphp ./bin/behat -c behat-planete.yml
CURRENT_UID=$(CURRENT_UID) docker-compose stop dbtest apachephptest planetetest mailcatcher
CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) stop dbtest apachephptest planetetest mailcatcher
CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) up -d dbtest apachephptest planetetest mailcatcher
CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) run --no-deps --rm cliphp ./bin/behat
CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) run --no-deps --rm cliphp ./bin/behat -c behat-planete.yml
CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) stop dbtest apachephptest planetetest mailcatcher

data:
mkdir data
Expand All @@ -88,17 +89,17 @@ hooks: .git/hooks/pre-commit .git/hooks/post-checkout

.git/hooks/pre-commit: Makefile
echo "#!/bin/sh" > .git/hooks/pre-commit
echo "docker-compose run --rm cliphp make test" >> .git/hooks/pre-commit
echo "docker compose run --rm cliphp make test" >> .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

.git/hooks/post-checkout: Makefile
echo "#!/bin/sh" > .git/hooks/post-checkout
echo "docker-compose run --rm cliphp make vendor" >> .git/hooks/post-checkout
echo "docker compose run --rm cliphp make vendor" >> .git/hooks/post-checkout
chmod +x .git/hooks/post-checkout

reset-db:
echo 'DROP DATABASE IF EXISTS web' | docker-compose run --rm db /opt/mysql_no_db
echo 'CREATE DATABASE web' | docker-compose run --rm db /opt/mysql_no_db
echo 'DROP DATABASE IF EXISTS web' | $(DOCKER_COMPOSE_BIN) run -T --rm db /opt/mysql_no_db
echo 'CREATE DATABASE web' | $(DOCKER_COMPOSE_BIN) -T --rm db /opt/mysql_no_db

db-migrations:
php bin/phinx migrate
Expand All @@ -107,7 +108,7 @@ db-seed:
php bin/phinx seed:run

console:
CURRENT_UID=$(CURRENT_UID) docker-compose run --rm cliphp bash
CURRENT_UID=$(CURRENT_UID) $(DOCKER_COMPOSE_BIN) run --rm cliphp bash

phpstan:
docker run -v $(shell pwd):/app --rm ghcr.io/phpstan/phpstan
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
## Applications

On accède aux applications via docker et les différents ports des applications.
Vous retrouverez les ports dans le fichier `docker-compose.override.yml`
Vous retrouverez les ports dans le fichier `compose.override.yml`

Par défaut:
* Site AFUP : <https://localhost:9205/>
* Planète PHP : <https://localhost:9215/>
* Mailcatcher: <http://localhost:1181/>

_Les ports utilisés peuvent être modifiés dans le fichier `docker-compose.override.yml`._
_Les ports utilisés peuvent être modifiés dans le fichier `compose.override.yml`._

## Mise en place avec docker

Expand All @@ -30,8 +30,7 @@ Vous pouvez aussi y accéder directement via la commande: `docker/bin/mysql`
* `make docker-stop` : éteint les containers en fonctionnement.
* `make docker-down` : détruit les containers existants.
* `docker/bin/mysql` : connexion à la base de données.
* `docker/bin/bash` : PHP 5.6 cli.
* `docker/bin/bashphp7` : PHP 7.0 cli.
* `docker/bin/bash` : PHP cli.

### Configuration avancée

Expand All @@ -42,7 +41,7 @@ Ce fichier contient la liste des options disponibles.

#### `DOCKER_UP_OPTIONS`

liste des options à passer à la commande `docker-composer up`.
liste des options à passer à la commande `docker composer up`.

## Base de données

Expand Down
File renamed without changes.
31 changes: 0 additions & 31 deletions docker-compose.yml → compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,6 @@ services:
- db
- mailcatcher

apachephp7:
build:
context: ./docker/dockerfiles/apachephp7
args:
uid: ${CURRENT_UID:-1001}
gid: "1001"
ENABLE_XDEBUG: ${ENABLE_XDEBUG:-false}
environment:
SYMFONY_ENV: "dev"
volumes:
- ./:/var/www/html
links:
- db
- mailcatcher

apachephptest:
build:
context: ./docker/dockerfiles/apachephp
Expand Down Expand Up @@ -128,21 +113,5 @@ services:
- dbtest
command: "false"

cliphp7:
build:
context: ./docker/dockerfiles/apachephp7
args:
uid: ${CURRENT_UID:-1001}
gid: "1001"
ENABLE_XDEBUG: ${ENABLE_XDEBUG:-false}
user: localUser
volumes:
- ./data/composer:/home/localUser/.composer
- ./:/var/www/html
links:
- db
- mailcatcher
command: "false"

mailcatcher:
image: dockage/mailcatcher:0.9.0
2 changes: 1 addition & 1 deletion docker/bin/bash
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
docker-compose run --rm cliphp /bin/bash
docker compose run --rm cliphp /bin/bash
2 changes: 0 additions & 2 deletions docker/bin/bashphp7

This file was deleted.

3 changes: 1 addition & 2 deletions docker/bin/mysql
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/bin/bash
docker-compose run --rm db /opt/mysql

docker compose run --rm db /opt/mysql
3 changes: 1 addition & 2 deletions docker/bin/mysql_event
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/bin/bash
docker-compose run --rm dbevent /opt/mysql

docker compose run --rm dbevent /opt/mysql
11 changes: 6 additions & 5 deletions docker/dockerfiles/apachephp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM php:5.6-apache

ARG ENABLE_XDEBUG=false
FROM php:7.0-apache

RUN echo 'deb http://archive.debian.org/debian stretch main' > /etc/apt/sources.list

ARG ENABLE_XDEBUG=false

## Update system
RUN apt-get update && \
apt-get upgrade -y && \
Expand All @@ -24,8 +24,8 @@ RUN apt-get update && \
libicu-dev \
wget && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install pdo_mysql mbstring mysqli zip gd mcrypt intl && \
if [ "$ENABLE_XDEBUG" = "true" ]; then pecl install xdebug-2.5.5 && docker-php-ext-enable xdebug; fi && \
docker-php-ext-install pdo_mysql mbstring mysqli zip gd mcrypt intl pcntl && \
if [ "$ENABLE_XDEBUG" = "true" ]; then pecl install xdebug-2.6.1 && docker-php-ext-enable xdebug; fi && \
apt-get autoremove --purge -y && \
rm -rf /var/lib/apt/lists/*

Expand All @@ -45,6 +45,7 @@ RUN apt-get update && \
gnupg && \
curl -k -sL https://deb.nodesource.com/setup_6.x | bash - && \
apt-get install -y nodejs && \
apt-get autoremove --purge -y && \
rm -rf /var/lib/apt/lists/*

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
Expand Down
73 changes: 0 additions & 73 deletions docker/dockerfiles/apachephp7/Dockerfile

This file was deleted.

12 changes: 0 additions & 12 deletions docker/dockerfiles/apachephp7/apache.conf

This file was deleted.

35 changes: 0 additions & 35 deletions docker/dockerfiles/apachephp7/apache.crt

This file was deleted.

Loading

0 comments on commit 82d4e55

Please sign in to comment.