This document summarizes a presentation about using Docker for WordPress development and deployment. It discusses using Docker to create development environments for WordPress, building Docker images, and deploying WordPress containers to production using Docker Compose or Kubernetes. It also covers customizing configurations, using Traefik for proxy and SSL termination, backup strategies, and notes that Kubernetes is more complex than Docker for simple use cases.
8. Comandos.
$ docker start <container name>
$ docker stop <container name>
$ docker rm <container name>
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
NAMES
14649c5b7e9a mariadb:latest "/docker-entrypoint.s" 12 seconds ago Up 12 seconds
3306/tcp wordpressdb
$ docker exec -ti <container name> /bin/bash
$ (I’m inside!)
9. Dockerfile.
FROM php:5.6.30-fpm-alpine
RUN apk update && apk add build-base
RUN docker-php-ext-configure mysql
RUN curl -o wordpress.tar.gz http://wordpress.org/latest.tar.gz
RUN tar -xzvf wordpress.tar.gz --strip-components=1 --directory /var/www/html/
RUN rm wordpress.tar.gz
10. Docker build y run.
$ ls Dockerfile
Dockerfile
$ docker build -t "wordpress" .
...
Successfully built 0b388013905e
...
$ docker run -d -p 8080:80 -t wordpress
6da59c864d35bb0bb6043c09eb8b1128b2c1cb91f7fa456156df4a0a22f271b0
18. wp-local-docker: todo en 1.
- Wordpress y MSQL.
- Múltiples entornos.
- Extras: Memcached, Elasticsearch.
- Herramientas: wpsnapshots, wp-cli, phpmyadmin,
phpmemcachedadmin, mailcatcher.
19. wp-local-docker:
$ 10updocker create
What is the primary hostname for your site? (Ex: docker.test) meioliver.com
? Are there additional domains the site should respond to? No
? What version of PHP would you like to use? 7.2
? Do you need Elasticsearch No
? Do you want to install WordPress? Yes
? Select a WordPress installation type: Single Site
? Do you want to remove the default content? Yes
? Site Name meioliver.com
? Admin Username admin
? Admin Password password
? Admin Email admin@example.com
20. Ensuring global network exists
- Network exists
Ensuring global cache volume exists
- Creating Volume
Ensuring global services are running
Starting global_gateway_1 ... done
Starting global_mailcatcher_1 ... done
Starting global_dns_1 ... done
Starting global_mysql_1 ... done
Starting global_phpmyadmin_1 ... done
Waiting for mysql...
Copying required files...
Generating docker-compose.yml file...
done
Creating database
Locating project files for meioliver-com
Starting docker containers for meioliver-com
Creating network "meioliver-com_default" with the default driver
Creating meioliver-com_memcached_1 ... done
Creating meioliver-com_memcacheadmin_1 ... done
Creating meioliver-com_phpfpm_1 ... done
Creating meioliver-com_nginx_1 ... done
21. Downloading WordPress
Downloading WordPress 5.0.2 (en_US)...
Using cached file '/var/www/.wp-cli/cache/core/wordpress-5.0.2-en_US.tar.gz'...
Success: WordPress downloaded.
Configuring WordPress
Success: Generated 'wp-config.php' file.
Success: WordPress installed successfully.
Success: Rewrite rules flushed.
Success: Rewrite structure set.
Success: The site at 'http://meioliver.com' was emptied.
Deleted 'hello' plugin.
Deleted 'akismet' plugin.
Success: Deleted 2 of 2 plugins.
Warning: The 'twentyfifteen' theme could not be found.
Deleted 'twentysixteen' theme.
Success: Deleted 1 of 2 themes.
Success: Deleted 6 of 6 widgets.
Adding entry to hosts file
Added to hosts file successfully!
Successfully Created Site!
29. Copias de seguridad :).
mysql-backup:
container_name: mysql-backup
image: deitch/mysql-backup
volumes:
- ./mysql-backup:/db
networks:
- internal
links:
- mysql:db
environment:
DB_DUMP_TARGET: /db
DB_SERVER: db
DB_USER: XXXX
DB_PASS: XXXX
RUN_ONCE: “true”
30. Kubernetes.
- Orquestación sobre contenedores.
- Más funcionalidad, más complejidad.
- Posiblemente standard de despliegue de
aplicaciones en un futuro.
31. - Capa nueva de infraestructura.
- Kubernetes no es para todos:
- Alta disponibilidad.
- Alta carga.
- Multi-usuario.
Dificultades.
32. ¿Kubernetes fácil?.
- Kubernetes gestionado:
- GKE, EKS, AKS, DigitalOcean, etc.
- kompose, Helm facilitan el despliegue:
https://sysdig.com/blog/wordpress-kubernetes-perfect-setup/