wnt-dev-deploy is a Vagrant virtual machine to provide on a very simple Docker based local deployment.
This virtual machine uses the following elements:
You will need to install Virtualbox and Vagrant.
Versions are set in infrastructure/vagrant/vagrant.dist.json for consistency across all developpers. However, you can create a copy nammed vagrant.json to edit your local settings.
{
"node": 1, # Only one VM is created"system": {
"box":"debian/buster64", # Guest OS"memory": 2048, # RAM allowed to this VM"cpus": 1, # CPU allowed"gui": false, # Run a headless VirtualBox VM"name":"wnt-dev-deploy", # Name of your VN"hostname":"wnt-dev-deploy"# Hostname
},
"shared_folder": {
"host": "default", # ~/vagrant/wnt-dev-deploy"guest": "default"# /home/vagrant/data
},
"network": {
"private_ip":"10.192.168.12", # Guest private IP. Useful for DNS resolutions."private_tld":"wnt"# Local TLD. Ex: my-project.wnt
}
}Then you can start the VM.
cd to the directory where you see the Vagrantfile
vagrant up # Starts the VM
vagrant ssh # SSH access
vagrant halt # Stops the VMDNSMasq is running by default and resolves all *.wnt to the VM.
However, you will have to add the resolver to your host machine.
Example on macOS
sudo tee /etc/resolver/wnt >/dev/null <<EOFnameserver 10.192.168.12EOFThen you can test with a simple ping
ping foo.bar.wntDocker installed and readdy for your deployments.
Tip : You can modify shared_folder in vagrant.dist.json to share a folder from your respositories to the VM. It will be easier to use docker commands.
Traefik is a Docker aware reverse proxy.
To launch portainer :
# From the host machine
vagrant ssh
# From the guest machinecd /home/vagrant/infrastructure/docker/traefik
docker-compose up -dNow Traefik is up and the dashboard is accessible at traefik.wnt
It is advised to create a docker-compose.yaml on your project to connect its container to Traefik.
Example with a simple NGINX container and a PHP app.
File :
docker-compose.yaml
version: '3'services:
app:
build:
context: ./dockerfile: ./docker/dockerfiles/app.dockerfilerestart: alwaysworking_dir: /var/wwwvolumes:
- <YOUR_LOCAL_STORAGE>:/var/wwwnetworks:
- private_networklabels:
- "traefik.enable=false"web:
image: nginx:latestrestart: alwaysworking_dir: /var/wwwvolumes:
- <YOUR_LOCAL_STORAGE>:/var/wwwnetworks:
- private_network
- traefik_networklabels:
- "traefik.enabled=true"
- "traefik.port=80"
- "traefik.docker.network=traefik_network"
- "traefik.backend=web"
- "traefik.frontend.rule=Host:nginx-exemple.wnt"networks:
private_network:
external: falsetraefik_network:
external: trueFile :
app.dockerfile
FROM php:7.3.6-fpm-stretch
RUN apt-get update && apt-get install -y libmcrypt-dev \
&& pecl install mcrypt-1.0.2 \
&& docker-php-ext-enable mcrypt
RUN usermod -u 1000 www-dataNow you can run it
From the host : vagrant ssh
Once you're in the VM : cd /home/vagrant/data && docker-compose up
The app will be accessible at https://nginx-exemple.wnt from your host machine.
Sometimes, it's easier to have a UI to manage Docker.
To launch Portainer :
# From the host machine
vagrant ssh
# From the guest machinecd /home/vagrant/infrastructure/docker/portainer
docker-compose up -dNow Portainer is accessible at portainer.wnt.