Linphone User Registry WEB Front-end:Vol.1

Create Linphone user registry web front-end by Laravel. Install the laravel-auth in git project apps into docker php-fpm container, modify these codes and add the new files for meeting the Linphone user auth and database structure.
You need nginx, mariadb and phpmyadmin containers for managing the database.
Install procedures is the following:
- Create Docker Network
- Create Docker-Compose File
- Create Dockerfile
- Install laravel-auth
User Login
User Home
GitHub
https://github.com/laravel/laravel
Laravel Document
https://laravel.com/docs/7.x
laravel-auth
https://github.com/jeremykenedy/laravel-auth
1. Create Docker Network
Create common network "br0" for each container
https://docs.docker.com/engine/reference/commandline/network_create/
$ docker network create --driver=bridge --subnet=172.18.0.0/16 br0
2. Create Docker-Compose File
Create the docker-compose file composed of nginx, mariadb, phpmyadmin and php-fpm containers. Separately prepare for the dockerfiles and shell script to extend each container function.
Note) The premise it works under Letsencrypt+nginx reverse proxy environment. Please also refer to the following.
https://ficus-forum.myvnc.com/t/topic/317/2?u=tk-fuse
docker-compose.yml
version: '3'
services:
mariadb:
container_name: laravel-mariadb
image: mariadb
restart: always
volumes:
- ./db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=xxxxxxxx
- MYSQL_DATABASE=laravel
- MYSQL_USER=laravel
- MYSQL_PASSWORD=xxxxxxxx
networks:
proxy-tier:
ipv4_address: 172.18.0.5
# nginx
nginx:
container_name: nginx
image: nginx:alpine
tty: true
environment:
- VIRTUAL_HOST=test.site.com
- VIRTUAL_ROOT=/var/www/html
- VIRTUAL_PORT=80
# - VIRTUAL_PROTO=fastcgi
- LETSENCRYPT_HOST=test.site.com
- LETSENCRYPT_EMAIL=ficus.online@gmail.com
volumes:
# shared nginx default.conf between host and container
- ./nginx_default.conf:/etc/nginx/conf.d/default.conf
# shared the directory /var/www/html in php-fpm container
- ./html/laravel-auth:/var/www/html
# shared the directory /var/www/html in phpmysql-fpm container
- ./html/phpmyadmin:/var/www/html/phpmyadmin
external_links:
- nginx-proxy-letsencrypt
restart: always
networks:
proxy-tier:
ipv4_address: 172.18.0.6
# php-fpm-laravel
php-fpm-laravel:
container_name: php-fpm-laravel
build:
context: ./docker_files
dockerfile: php7.2-fpm-alpine-laravel
tty: true
expose:
- "9000"
ports:
- 8000:8000
volumes:
# for laravel php framework
- ./html:/var/www/html
depends_on:
- laravel-mariadb
restart: always
networks:
proxy-tier:
ipv4_address: 172.18.0.7
# phpmyadmin-fpm
phpmyadmin:
container_name: phpmyadmin-fpm
build:
context: ./docker_files
dockerfile: phpmyadmin-alpine
tty: true
expose:
- "9000"
environment:
- PMA_HOST=laravel-mariadb
- PMA_PORT=3306
- PMA_ABSOLUTE_URI=http://localhost/phpmyadmin
volumes:
- ./html/phpmyadmin:/var/www/html
- /sessions
depends_on:
- laravel-mariadb
restart: always
networks:
proxy-tier:
ipv4_address: 172.18.0.8
networks:
proxy-tier:
external:
name: br0
volumes:
shared:
external: true
3. Create Dockerfile
Create docker files to customise the default docker image to extend functions required for Laravel.
Dockerfile for phpmyadmin:
$ mkdir docker_files
$ cd docker_files
$ nano phpmyadmin-alpine
FROM phpmyadmin/phpmyadmin:fpm-alpine
RUN apk add --no-cache bash nano \
&& docker-php-ext-install mysqli \
&& docker-php-ext-enable mysqli
Dockerfile for Laravel:
$ nano php7.2-fpm-alpine-laravel
FROM php:7.2-fpm-alpine
# Set working directory
WORKDIR /var/www/html
RUN apk add --no-cache bash nano libpng-dev freetype-dev libjpeg-turbo-dev zip libxml2-dev icu-dev nodejs-current npm \
&& docker-php-ext-install mysqli \
&& docker-php-ext-enable mysqli \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd pdo pdo_mysql zip \
&& docker-php-ext-enable gd pdo pdo_mysql zip \
&& docker-php-ext-install intl \
&& docker-php-ext-enable intl
# Install Composer and Laravel
COPY composer_installer.sh /var/www/html
RUN ./composer_installer.sh && mv composer.phar /usr/local/bin/composer
RUN chown -R www-data:www-data /var/www/html
RUN composer global require laravel/installer \
&& ln -s /root/.composer/vendor/laravel/installer/bin/laravel /usr/local/bin/laravel
Create the composer install script for Laravel. Also refer to the following.
https://ficus-forum.myvnc.com/t/composer/216?u=tk-fuse
$ nano composer_installer.sh
#!/bin/sh
EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
then
>&2 echo 'ERROR: Invalid installer checksum'
rm composer-setup.php
exit 1
fi
php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
exit $RESULT
4. Install laravel-auth
Implement "git clone" command in html directory(the directory includes docker-compose) of the host machine for downloading laravel-auth.
$ git clone https://github.com/jeremykenedy/laravel-auth.git laravel-auth
Change derectory to laravel-auth, and create .env file.
$ cd laravel-auth
$ cp .env.example .env
Configure the database and SMTP mail server in .env file. In advance prepare for these requirements.
DB_CONNECTION=mysql
DB_HOST=mariadb
DB_PORT=3306
DB_DATABASE=laravelAuth
DB_USERNAME=your_user_name
DB_PASSWORD=your_password
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=xxxxxxxxxxxxxx
MAIL_PASSWORD=xxxxxxxxxxxxxx
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=from@example.com
MAIL_FROM_NAME="${APP_NAME}"
Start docker containers.
$ docker-compose up -d
Move into Laravel container
$ docker exec -ti php-fpm-laravel bash
Implement the following commands in laravel-auth directory.
# cd laravel-auth
# composer update
# php artisan vendor:publish --tag=laravelroles && php artisan vendor:publish --tag=laravel2step
# chmod -R 755 ../laravel-auth
# php artisan key:generate
# php artisan migrate
# composer dump-autoload
# php artisan db:seed
# npm install
# npm run dev
or
#npm run production
Start laravel-auth by php artisan serve command.
# php artisan serve --host 172.18.0.9
Laravel development server started: http://172.18.0.9:8000
PHP 7.2.24 Development Server started at Fri Apr 3 00:13:36 2020
Confirm the default page like the below by putting down the address: http://127.0.0.1:8000
php artisan serve inside docker
https://stackoverflow.com/questions/52369664/how-to-use-php-artisan-serve-inside-docker-container
Docker PHP-Core-Extensions Document
https://github.com/docker-library/docs/tree/master/php#php-core-extensions
About modified and additional codes, describe in the content of Vol.2