To simplify the development I tried docker for building the runtime environment. Here are the major steps to get it running.
Prerequisites
The docker installation is straight forward as described on the docker home page:
un-install old version
aptitude remove docker docker-engine docker.io
add reporitory
aptitude update
aptitude install apt-transport-https ca-certificates curl gnupg2 software-properties-common
add docker official key
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
check fingerprint
apt-key fingerprint 0EBFCD88
add repository
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
aptitude update
install docker from repo
aptitude install docker-ce
check if everything works
docker run hello-world
install docker compose
curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
and check everything works
docker-compose --version
Docker Cheat Sheet
## List Docker CLI commands
docker
docker container –help
## Display Docker version and info
docker –version
docker version
docker info
## Execute Docker image
docker run hello-world
## List Docker images
docker image ls
## List Docker containers (running, all, all in quiet mode)
docker container ls
docker container ls –all
docker container ls -aq
Development Environment
create folder for docker environment
mkdir dockerproject
create yaml file for docker compose
vi docker-compose.yaml
At least the following sections should be available:
- app
- web
- database
main application configuration
Webserver configuration is required
database configuration is required
and here comes an exmaple
version: '3'
services:
app:
build:
context: ./
dockerfile: app.dockerfile
working_dir: /var/www
volumes:
- ./../laravel:/var/www
environment:
- "DB_PORT=3306"
- "DB_HOST=database"
web:
build:
context: ./
dockerfile: web.dockerfile
working_dir: /var/www
volumes:
- ./../laravel:/var/www
ports:
- 8080:80
database:
image: mysql:5.6
volumes:
- dbdata:/var/lib/mysql
environment:
- "MYSQL_DATABASE=homestead"
- "MYSQL_USER=homestead"
- "MYSQL_PASSWORD=secret"
- "MYSQL_ROOT_PASSWORD=secret"
ports:
- "33061:3306"
volumes:
dbdata:
and now the app configuration
FROM php:7.1.3-fpm
RUN apt-get update
RUN apt-get install -y libmcrypt-dev
RUN apt-get install -y mysql-client
RUN apt-get install -y libmagickwand-dev --no-install-recommends
RUN pecl install imagick
RUN docker-php-ext-enable imagick
RUN docker-php-ext-install mcrypt pdo_mysql
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
RUN php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
RUN php composer-setup.php
RUN php -r "unlink('composer-setup.php');"
RUN mv composer.phar /usr/local/bin/composer
RUN apt-get install -y git
RUN apt-get update && apt-get install -y zlib1g-dev
RUN docker-php-ext-install zip
the web configuration
FROM nginx:1.10
ADD vhost.conf /etc/nginx/conf.d/default.conf