No Description

bach db9d459fcb new commits for api & app 2 years ago
Docker fc971fa605 replaced npm install by npm ci 3 years ago
api @ 3ec797475c db9d459fcb new commits for api & app 2 years ago
app @ 23e7b57154 db9d459fcb new commits for api & app 2 years ago
bin 8769b61f82 minors updates 3 years ago
log cf6588c370 added log/nginx/.gitkeep 3 years ago
ressources c35ec4962b activated api xdebug 3 years ago
.env c35ec4962b activated api xdebug 3 years ago
.gitignore ef8640ba24 api and app new commits 3 years ago
.gitmodules f697afe63a docker ready for api (no app yet) 3 years ago
LICENSE.txt 97df594616 docker env first draft 3 years ago
Makefile ec31ac22ab updated makefil for new docker naming 2 years ago
README.md 0bbebb34dc readme: added submodule update precision 3 years ago
docker-compose.yml c35ec4962b activated api xdebug 3 years ago

README.md

En françaiS Docker Environement (drupal api + vuejs client)

En FrançaiS powered by druapl 9 for the api and vuejs for the app (client) in docker environement (nginx, php:7-fpm+drush, mysql, phpmyadmin, redis, npm)

Install docker

sudo pacman -S docker docker-compose docker-machine

start the docker service

sudo systemctl start docker

For all the following, DO NOT run docker or make commande as root or with sudo, use this setup: add your user to the docker user group, re-login, and restart docker.service.

https://wiki.archlinux.org/index.php/Docker#Installation

Clone this repos

this will clone this repos (main docker environement), the drupal 9 based api source code (without sites/default folder nor mysq ddb) and the vuejs app source code.

git clone --recursive -o figli https://figureslibres.io/gogs/bachir/docker-enfrancais.git

submodules :

setup /sites/default/settings.php


### get the sites/default/files folder
rsync the files from you know where (if you don't, you don't) to api/src/web/sites/default/files/

## Mysql
Copy your-sql-dump.sql into ./ressources/enfrancais.sql
It will be automaticly imported into the mysql container db (only) on the first ```make up```

## Hosts and reverse proxy

add to your /etc/hosts :

127.0.0.1 dev.enfrancais.fr 127.0.0.1 dev.phpmyadmin.enfrancais.fr

configure your vhosts to add a reverse proxy that will redirect the dev.enfrancais.fr to our container
Apache

ServerName dev.enfrancais.fr ProxyPass / http://127.0.0.1:8990/ ProxyPassReverse / http://127.0.0.1:8990/ ProxyRequests Off ProxyPreserveHost On proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k;

ServerName dev.phpmyadmin.enfrancais.fr ProxyPass / http://127.0.0.1:8991/ ProxyPassReverse / http://127.0.0.1:8991/ ProxyRequests Off ProxyPreserveHost On proxy_buffer_size 128k; proxy_buffers 4 256k; proxy_busy_buffers_size 256k;

nginx

server {

 listen 80;
 server_name dev.enfrancais.fr;

 access_log off;
 error_log  /var/log/nginx/enfrancais/error.log error;

 client_max_body_size 100m;

 location / {
     proxy_pass http://127.0.0.1:8990;
     proxy_set_header Host $host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forwarded-Proto $scheme;
     proxy_buffer_size          128k;
     proxy_buffers              4 256k;
     proxy_busy_buffers_size    256k;
 }

} server {

 listen 80;
 server_name dev.phpmyadmin.enfrancais.com;

 location / {
     proxy_pass http://127.0.0.1:8991;
     proxy_set_header Host $host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forwarded-Proto $scheme;
     proxy_buffer_size          128k;
     proxy_buffers              4 256k;
     proxy_busy_buffers_size    256k;
 }

}


## Docker

### docker-compose pull
pull the latest image of services

make pull


### build
only before the first run (may take some time)

make build

/!\ DO NOT use ```docker-compose build```, it will faile

### run
then each time you want to launch the app

make up

Be aware that a first up, since the db is empty, it will be populated with your file db.sql. It may take some time depending of your db size.

## Drupal Composer install
Only at first up, finish to install drupal composer dependencies
but first we need to downgrade composer to version 1

docker exec -u 0 -it enfrancais_api_1 /bin/bash composer selfupdate --1

ctrl+d

make exec_api composer install


## Visualize
You can now visit :
the app http://dev.enfrancais.fr
or the api http://dev.enfrancais.fr/api
on your browser

## Coding
### drush
you can access to drush by loging into the php container

make exec_api

once inside the php container in /var/www/html you can use drush as usual


## Updating code

git pull figli master

then update all submodules

git submodule update --recursive --checkout

or only one

git submodule update --checkout app/

or

git submodule update --checkout api/ make api_maj_config


## Updating manualy mysql db
copy your db backup into the mysql container
```sh
sudo docker cp your-db-file.sql enfrancais_mysql_1:/root/

log into mysql container

make exec_mysql

once inside the mysql container you can use mysql command to drop then create and load the db with your file

mysql -uroot -penfrancais
> drop database enfrancais;
> create database enfrancais;
> exit;
mysql -uroot -penfrancais enfrancais < your-db-file.sql

Makefile

DO NOT use directly docker or docker-compose to run this instance use make instead like make up

pull:
		docker-compose pull

build:
		docker-compose build --build-arg USER_UID=$(USER_UID) --build-arg USER_UNAME=$(USER_UNAME) --build-arg USER_GID=$(USER_GID) --build-arg USER_GNAME=$(USER_GNAME)

buildnc:
		docker-compose build --no-cache --build-arg USER_UID=$(USER_UID) --build-arg USER_UNAME=$(USER_UNAME) --build-arg USER_GID=$(USER_GID) --build-arg USER_GNAME=$(USER_GNAME)

downbuildup: down build up

up:
		docker-compose up -d

ps:
		docker-compose ps

logs:
		docker-compose logs -f

api_maj_config: api_crd api_composer_install api_updb api_cim api_cr

api_crd:
		docker exec enfrancais_api_1 /bin/bash -c "drush cache-clear drush"

api_cr:
		docker exec enfrancais_api_1 /bin/bash -c "drush cr"

api_updb:
		docker exec enfrancais_api_1 /bin/bash -c "drush updb -y"

api_cim:
		docker exec enfrancais_api_1 /bin/bash -c "drush config-import -y"

api_composer_install:
		docker exec enfrancais_api_1 /bin/bash -c "composer install --no-dev"

down:
		docker-compose down

exec_api:
		docker exec -it enfrancais_api_1 bash

exec_app:
		docker exec -it enfrancais_app_1 sh

restart_app:
  docker-compose restart app

exec_mysql:
		docker exec -it enfrancais_mysql_1 bash