Presented by
Space allocated by
Web Apps Experts
Steven Rosato, B. Ing
President & Founder @ Solutions Majisti
Steven Rosato
Small company near Montreal (Boisbriand) focussed on development with Symfony and React/Redux.
/solutions.majisti
The developers you wish you had hired first!
New meetup name!
17h30 - 19h00 Networking
19h00 - 20h00 Presentation
After... Pub Victoria
??
a Boob
a Guru
Don't be a boob
Hey the testing phase should be automated too by the way!!
Vagrant local environment
VCS
CI Tool (and deploy tool for now)
VPS Cloud Provider / Docker Host
Hosted on
Pulls from
Psst... Guru tip #1
Your project will need maintenance
Guru tip #2
Your client's needs will evolve
No trans fat I swear
Docker Compose
And if I don't??
You will have an easier (or harder) time with
$ sudo apt-get install npm
$ sudo apt-get install php5 apache2
$ npm install -g gulp
$ gulp watch
$ php app/console awesome:command
Wait and there is so much more!!
Behat | Gulp | NodeJs | PHP | Apache / Nginx |
Ruby | FPM | XDebug | PECL | Python |
Bzip2 | g++ | libicu-dev | MySQL | ... |
From
To
$ docker-compose run --rm php php -v
$ docker-compose run --rm node npm install
$ docker-compose run --rm node gulp watch
dev.majisti.com
staging.majisti.com
majisti.com #1
Developer #1
Developer #2
Developer #n ...
majisti.com #2
majisti.com #n ...
...
It lets you have the same environment no matter where you are and that unlocks the power to do CI/CD that is maintainable without hassle
FROM php:7.1.0RC6-fpm
# Environment variable
ENV APCU_VERSION 5.1.2
ENV APCU_BC_VERSION 1.0.0
# Dependencies
RUN apt-get update \
&& apt-get install -y \
libpq-dev \
libicu-dev \
zlib1g-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng12-dev \
git \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install intl mbstring pgsql pdo_pgsql zip gd \
&& apt-get clean \
&& rm -r /var/lib/apt/lists/*
# Xdebug
RUN pecl install -o -f xdebug-2.5.0 \
&& rm -rf /tmp/pear
# Configuration
COPY php.ini /usr/local/etc/php/php.ini
COPY xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
nginx:
image: 'nginx:1.9'
volumes:
- ./docker/nginx/app.conf:/etc/nginx/conf.d/default.conf:ro
volumes_from:
- data
links:
- fpm
environment:
VIRTUAL_HOST: majisti.boilerplate
fpm:
build: 'docker/fpm'
volumes_from:
- data
node:
build: 'docker/node'
volumes_from:
- data
php:
build: 'docker/php'
volumes_from:
- data
data:
image: busybox
volumes:
- .:/var/www/html
- ~/.composer:/var/www/.composer
DC=docker-compose
PHP=$(DC) run --rm php
NODE=$(DC) run --rm node
COMPOSER=$(PHP) php -n -d extension=zip.so /usr/local/bin/composer
ci: all code-fix test
all: configure start vendors-install node-install assets
restart: stop start
test: test-prepare test-integration test-acceptance
start:
$(DC) up -d
stop:
$(DC) kill
$(DC) rm -vf
node-install:
$(NODE) npm install
assets:
$(NODE) bin/gulp
vendors-install:
$(COMPOSER) install --no-interaction --prefer-dist
vendors-update:
$(COMPOSER) update
code-fix:
$(PHP) php -n bin/php-cs-fixer fix --no-interaction
$ docker run -p 8080:8080 -p 50000:50000 -v /your/home:/var/jenkins_home jenkins
You will need to install the Digital Ocean Jenkins plugin. We have forked the repo and added support for volume mapping (more on that later)
Or however you want to install it.
Download Jenkins Plugin here:
Fork available here:
Installing Docker Compose
sudo apt-get install -y curl
curl -L https://github.com/docker/compose/releases/download/1.8.0/docker-compose-`uname -s`-`uname -m` \
> /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose -v #verify version
Attaching the volume
# list available volumes
ls -l /dev/disk/by-id/
# outputs
lrwxrwxrwx 1 root root 9 Feb 20 17:01 scsi-0DO_Volume_jenkins-data -> ../../sda
# modify /etc/fstab
/dev/disk/by-id/scsi-0DO_Volume_jenkins-data /mnt/jenkins-data ext4 defaults,nofail,discard 0 0
Modify Docker home directory
vi /etc/default/docker
#locate this line and change the directory
DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4 -g /mnt/jenkins-data/docker"
You can now create a snapshot and destroy the droplet
This way, docker image will not be built each time an instance of the VM is created
$ make ci
That's it for the CI aspect!
The plugin automatically destroys Droplets after the build, which is what saves costs
That's it for the CD aspect!
$ make restart
$ git commit -am"Some code!!"
Once satisfied we either have automatic staging/prod release or manually triggered by the CI build with one button click.
This is called parametrized builds
Read us ranting
Come blog with us
Web Apps Experts