ZEND SERVER IN DOCKER SWARM: DEPLOYMENT AND MORE Jan Burkl Solution Consulting Manager Rogue Wave Software ZendCon 2017, Las Vegas, October 26th 2017
DOCKER
DOCKERFILE (PROD) FROM php:7.0-fpm RUN apt-get update && apt-get install -y git libcurl4-gnutls-dev && git clone -b php7 https://github.com/phpredis/phpredis.git / && docker-php-ext-install redis \ && apt-get autoremove && apt-get autoclean \ && rm -rf /var/lib/apt/lists/* -----------------------------# App sources -----------------------------COPY . /app/
DOCKERFILE (DEV) FROM janatzend/particulum-mobile-backend WORKDIR / ADD http://www.zend.com/en/download/4843?start true /zend RUN \ echo zend extension /zend-debugger/ZendDebugger-linux-x8 echo zend debugger.allow from all 1 /usr/local/etc/php/p
REDIS CONTAINER docker run -d --name redis redis:3.2.7-alpine
PHP CONTAINER docker run -d --name php \ -v " PWD:/app" \ --link redis:redis \ particulummobile-dev/backend
NGINX CONTAINER docker run -d --name nginx \ -v " PWD:/app" \ -v " conf" \ --link php:php \ -p 8888:80 \ particulummobile-dev/backend-nginx
DOCKER COMPOSE
version: "3" services: -----------------------------# Nginx -----------------------------nginx: build: context: " {PROJECTS PATH}/ {BACKEND APP DIR}" dockerfile: Dockerfile.nginx image: particulummobile-dev/backend-nginx volumes: - " {PROJECTS PATH}/ {BACKEND APP DIR}/etc/nginx.site - " {PROJECTS PATH}/ {BACKEND APP DIR}:/app" networks: backend-net:
RUN docker-compose up docker-compose -d -p (PROJECT) -f (DOCKER COMPOSE DE
SCALING docker-compose up -d --scale php 5 docker-compose scale php 5 Load Balancer?
DOCKER SWARM (MODE) “Current versions of Docker include swarm mode for natively managing a cluster of Docker Engines called a swarm. Use the Docker CLI to create a swarm, deploy application services to a swarm, and manage swarm behavior.”
CLOUD.DOCKER.COM Beta Service Provider AWS Azure On Premise
PLAY-WITH-DOCKER.COM
MY LOCAL SETUP VirtualBox Vagrant 3 Nodes Ubuntu 16.04
INIT / MANAGER docker swarm init --advertise-addr 192.168.99.121
Swarm initialized: current node (ww4nime7fbh9twrzzl7o2t31f) To add a worker to this swarm, run the following command: docker swarm join \ --token SWMTKN-1-2aps743f7wzjz6xp3vnlicpkim9ge2ykwvx 192.168.33.101:2377 To add a manager to this swarm, run 'docker swarm join-token
NETWORKING
ROUTING MESH “The routing mesh enables each node in the swarm to accept connections on published ports for any service running in the swarm, even if there’s no task running on the node.”
INGRESS NETWORK https://docs.docker.com/engine/swarm/ingress/
SERVICES
EXAMPLE: DOCKER SWARM VISUALIZER alizer
CREATE SERVICE docker service create \ --name viz \ --publish 8080:8080/tcp \ --constraint node.role manager \ --mount type bind,src /var/run/docker.sock,dst /var/run/d dockersamples/visualizer
BUILDING IMAGES
MAKEFILE
CI AAS Codehip Wercker Codefresh etc.
APP SERVICES DOCKER COMPOSE V3
INSTALL AND UPDATE docker stack deploy --compose-file stack.yml pm
ZEND SERVER https://github.com/5square/docker-zendserver
HELPERS /run.sh source /shell functions.rc trap "remove from cluster; exit" SIGINT SIGTERM SIGHUP
WEB API ./etc/shell functions.rc WEB API KEY docker WEB API SECRET (cat /webapi/secret) ZS MANAGE /usr/local/zend/bin/zs-manage
CONFIG IMPORT (BUILD TIME) ZS CLIENT A configurationImport \ --configFile "/zs config.zip" \ --output-format "kv"
JOINING CLUSTER ZS MANAGE server-add-to-cluster \ -n HOSTNAME \ -i IP \ -o DB HOST:3306 -u DB USER -p DB PASS -d DB NAME \ -N WEB API KEY -K WEB API SECRET -s
LEAVING CLUSTER ZS MANAGE cluster-disable-server \ SERVER ID -N WEB API KEY -K WEB API SECRET -s ZS MANAGE cluster-remove-server \ SERVER ID -N WEB API KEY -K WEB API SECRET -f
SESSION CLUSTERING
SESSION CLUSTERING ZS MANAGE store-directive \ -d 'session.save handler' -v 'cluster' \ -N WEB API KEY -K WEB API SECRET
HEALTH CHECK ZS CLIENT clusterGetServerStatus \ --servers (cat /usr/local/zend/etc/conf.d/ZendGlobalDirective --zsurl "http://localhost:10081" \ --zskey WEB API KEY --zssecret WEB API SECRET \ --output-format kv \ grep status grep OK exit 1
INGRESS NETWORK - UI ISSUES https://docs.docker.com/engine/swarm/ingress/
UPDATES
ZEND SERVER DEPLOYMENT?
UPDATE docker service update pm-zs php --help Usage: docker service update [OPTIONS] SERVICE Update a service Options: --args command Service command args --config-add config Add or update a config file on --config-rm list Remove a configuration file --constraint-add list Add or update a placement co --constraint-rm list Remove a constraint --container-label-add list Add or update a container la --container-label-rm list Remove a container label by --credential-spec credential-spec Credential spec for man -d, --detach Exit immediately instead of wait
UPDATE docker service update pm-zs php \ --image janatzend/particulum-mobile-backend-zendserver:upd
OR. UI (PORTAINER)
BENEFITS
CONTAINERS SELF-CONTAINED Everything in VCS Running in every Docker env
DOCKER COMPOSE Stack Deployment via YAML file
DANKESCHÖN bitbucket.org/account/user/5squarerw/projects/PM Slides: 5square.de/talks Contact me: jan.burkl [at] roguewave.com Follow me: @janatzend
ZEND SERVER IN DOCKER SWARM: DEPLOYMENT AND MORE Jan Burkl Solution Consulting Manager, Las Vegas, October 26th 2017 Rogue Wave Software ZendCon 2017. DOCKER. DOCKERFILE (PROD) FROM php:7.0-fpm RUN apt-get update && apt-get install -y git libcurl4-gnutls-dev zlib1g-dev libicu-dev g libxml2-dev libpq-dev \
Docker images and lauch Docker containers. Docker engine has two different editions: the community edition (Docker CE) and the enterprise edition (Docker EE). Docker node/host is a physical or virtual computer on which the Docker engine is enabled. Docker swarm cluster is a group of connected Docker nodes.
By default, Docker Swarm is disabled, so to run Docker in swarm mode, you will need to either join an existing cluster or create a new swarm. To create a new swarm and activate it in your system, you use the swarm init command shown here: docker swarm init This will create a new single-node swarm cluster on the node you are currently working on.
2.2 Installing the Zend Server on the SPS Server This section shows how to install the Zend server on the SPS server. To install the Zend Server on the SPS Server: 1. Copy the Zend installation file to a temporary directory on the SPS server. 2. Run the Zend server installation file ZendServer-6.3.-php-5.3.28-Windows_x86.exe.
Docker Quickstart Terminal Docker Quickstart Terminal Docker . 2. docker run hello-world 3. . Windows Docker : Windows 7 64 . Windows Linux . 1.12.0 Docker Windows Hyper-V Linux 1.12 VM . docker . 1. Docker for Windows 2. . 3. . 1.11.2 1.11 Linux VM Docker, VirtualBox Linux Docker Toolbox .
Exercise: How to use Docker States of a Docker application: – Dockerfile Configuration to create a Docker Image. – Docker Image Image can be loaded by Docker and is used to create Docker Container. – Docker Container Instance of a Docker Image. Dockerfile – Build a Docker Image from Dockerfile wi
3.Install the Docker client and daemon: yum install docker-engine. 4.Start the Docker daemon: service docker start 5.Make sure the Docker daemon will be restarted on reboot: chkconfig docker on 6. Add the users who will use Docker to the docker group: usermod -a -G docker user .
o The Docker client and daemon communicate using a RESTAPI, over UNIX sockets or a network interface. Docker Daemon(dockerd) listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes. Docker Client(docker) is the primary way that many Docker users interact with Docker. When docker run
Introduction to Containers and Docker 11 docker pull user/image:tag docker run image:tag command docker run -it image:tag bash docker run image:tag mpiexec -n 2 docker images docker build -t user/image:tag . docker login docker push user/image:tag