eZ Launchpad
A tool that will help you build an eZ Platform project on top of Docker in less than 5 minutes.
You will end up with a full Docker stack where the source-code is on your host for you to start coding right away!
Demo
This is a demo of an initialization. Starting from scratch you will get everything ready to code, commit and push!
This is a demo of a creation. Starting from a git repository you will get everything ready to code, commit and push!
Installation
Requirements:
- PHP and PHP-CURL extension. PHP version 7.2+
- Docker 1.17+
- Docker Compose 1.16+
If you have curl installed:
$ curl -LSs https://ezsystems.github.io/launchpad/install.bash | bash
If you have wget installed:
$ wget -O - "https://ezsystems.github.io/launchpad/install.bash" | bash
Usage
When you have installed eZ Launchpad (~/ez) you can start enjoying the feature.
eZ Launchpad provides 2 main features:
- Initialization of a brand new eZ Platform Stack (on top of Docker)
- Create the Docker Stack related to the current directory.
If you are using Blackfire.io, then don't forget to export your credentials before to run the following commands.
$ export BLACKFIRE_CLIENT_ID=xxxx-xxxx-xxxx-xxxx-xxxxx
export BLACKFIRE_CLIENT_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
export BLACKFIRE_SERVER_ID=xxxx-xxxx-xxxx-xxxx-xxxxx
export BLACKFIRE_SERVER_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Initialization
That is the from scratch installation. You need to do that when you have nothing and you want to start a new project with eZ Platform.
$ ~/ez init
From here eZ Launchpad will ask you a bunch of question to configure your project.
Mac OS X users will have a wizard to set up NFS.
At the end of the procedure those steps will be done for you:
- Configuration of your project locally.
- Download (pull) the correct image on your Docker Daemon.
- Set up an eZ compliant docker-compose.yml.
- Create and start the containers required (depending of the choices you made).
- Install Composer in the Engine container (where PHP is executed in your stack).
- Install eZ Platform through Composer inside the stack.
Once the Initialization is finished, the project is up, you can check doing:
$ ~/ez ps
You are now ready to dump the database and storage, git commit and push to share the project to your teams.
$ ~/ez dumpdata; git init; git add .; git commit -m "First Initial Commit"
$ git remote add origin https://gitorigin.com/xxx/xxxx-xxx.git; git push -u origin master
eZ Platform Enterprise
content.usage.init.end.finished.entreprise
$ ~/ez init ezsystems/ezplatform-ee
When eZ Launchpad will ask you about HTTP-BASIC, then you have to provide the Installation Key and the Token.
Create
In this context you have already a project somewhere, someone already did a ~/ez init
Then it most likely that you did
$ git clone https://SOMETHING.git
If you want to know if your project is eZ Launchpad ready, you can just check the existance of .ezlaunchpad.yml at the root directory of your project.
To create the local stack the command is then
$ ~/ez create
Here eZ Launchpad will pull the images, create the containers of your stack as well a importing the database/storage.
Deployment
eZ Launchpad can help you to deploy as well. Even if it is optional and you can deploy the way you want we wanted to provide simplifications.
Setup
Platform.sh is a PaaS (Platform
as a
Service).
With Platform.sh there is no real deployment process to run manually. Platform.sh will just create and synchronize environments based on your git repository!
eZ Launchpad provides you a way to set up your eZ Project to be Platform.sh ready.
$ ~/ez platformsh:setup
This command will create and generate files required by Platform.sh. Because eZ Launchpad knows your project and the services you need it will adapt the Plaftorm.sh configuration files to it.
Here is the list of files that are going to be created.
.platform/services.yaml
.platform/routes.yaml
.platform.app.yaml
ezplatform/app/config/env/platformsh.php
Because you will need to initialize the database and the storage on Platform.sh (the first time), eZ Launchpad will also create a dump.
Deploy
As mentioned there is not real "deployment" process, this command will just display some documentation.
$ ~/ez platformsh:deploy
Coming soon...
Stack
At any time you can get information on your stack by running
$ ~/ez info
Depending on the initialization, you might have more or less services, but here is the most common stack.
LEMP: Linux Nginx Mysql/MariaDB PHP-FPM
Common Commands
eZ Launchpad was made to help you with a local Docker stack.
To do so, here are the commands available to you:
$ ~/ez
Usage:
command [options] [arguments]
Available commands:
help Displays help for a command
list Lists commands
self-update Self Update
docker
docker:build [build] Build all the services (or just one).
docker:clean [docker:down|clean|down] Clean all the services.
docker:comprun [comprun] Run Composer command in the engine.
docker:create [create] Create all the services.
docker:dumpdata [dumpdata] Dump Database and Storage.
docker:enter [enter|docker:exec|exec] Enter in a container.
docker:importdata [importdata] Import Database and Storage.
docker:initialize [docker:init|initialize|init] Initialize the project and all the services.
docker:logs [logs|log] Display the logs.
docker:sfrun [sfrun] Run a Symfony command in the engine.
docker:start [start] Start all the services (or just one).
docker:status [docker:ps|docker:info|ps|info] Obtaining the project information.
docker:stop [stop] Stop all the services (or just one).
docker:up [up] Up all the services (or just one).
docker:update Update to last images.
platformsh
platformsh:deploy [psh:deploy] Deploy with Platformsh integration.
platformsh:setup [psh:setup] Set up the Platformsh integration.
When you want to provide extra arguments to a Symfony command, you have to wrap everything (command + arguments) inside quotes:
$ ~/ez sfrun "cache:clear --env=prod"
Global configuration
Because every project can share stuff and because you might want the same configuration everywhere, eZ Launchpad reads a configuration file in your HOME directory.
This configuration file is ~/ezlaunchpad/ez.yml. Here is a full example:
docker:
host_machine_mapping: "/Users/bob/MyProjects:/data/MYPROJECTS"
host_composer_cache_dir: "/data/MYPROJECTS/.composer_cache"
provisioning:
folder_name: "myprovisioningfoldername"
composer:
http_basic:
hostname:
host: www.hostname.com
login: login
password: pass
token:
github:
host: github.com
value: tokenvalue
Note that this configuration is global and won't be included in the project (i.e. in the CVS repository). But it will be including in your local stack.
docker section is described in the next section.
macOS - Tips
When it comes to share a folder from the Host (your Mac) to containers, Docker for Mac is slow (at least for now). To manage this performance issue, there is a workaround: NFS! Yes, it might be odd, but NFS is faster than the default mount. Before the last version of Docker for Mac, we were using D4M, but since Docker for Mac 18.03 we can directly mount the host as a volume from the container.
Webpack and Watching your changes
As your files are on the Host and the watch is in the container, watch will not work due to, again, the tricks we do for performances.
Therefore you can by pass that problem adding this in your webpack configuration:
module.exports = {
//...
watchOptions: {
poll: 1000
}
};
Update to Catalina
Catalina brings a new weird comlexity with Mac OS that has been handled in eZ Launchpad but when you migrate you might want to know more.
Actually, that pretty simple, /Users/$USER is not really /Users/$USER it is /System/Volumes/Data/Users/$USER
eZ Launchpad will detect automatically if your NFS export file has been updated, but depending on the situation and specificities of your project you might also need to set a Shared Folder in the daemon configuration.
/System/Volumes/Data/Users/$USER
Note that $USER must be replaced with your Username.
Update from D4M-NFS
First you need to add an option to your /etc/exports, spot the -alldirs:
$ cat /etc/exports
/Users/plopix -mapall=plopix:staff -alldirs localhost
Second you need to update the version of docker-compose in your provisioning/dev/docker-compose.yml file to 2.1. And you need to create a new file named provisioning/dev/docker-compose-osx.yml with this content:
$ cat provisioning/dev/docker-compose-osx.yml
version: '2.1'
services:
engine:
volumes:
- "nfsmount:${PROJECTMAPPINGFOLDER}"
volumes:
nfsmount:
driver: local
driver_opts:
type: nfs
o: addr=host.docker.internal,lock
device: ":${PROJECTCOMPOSEPATH}/"
Once the setup is up-to-date, you can dumpdata (to backup), clean, and re-create the project again:
$ ~/ez dumpdata; ~/ez clean; ~/ez create
If you were using a special mapping, fix it:
docker:
host_machine_mapping: "/Users/plopix:/Users/plopix"
host_composer_cache_dir: "/Users/plopix/.composer_cache
That is it!
Store cache in the container
Even with D4M and the NFS mount, performances can be optimized. The following is clearly a trick. But a trick that works pretty well!
Here is the magic, in your env you have this line:
# provisioning/dev/docker-compose.yml
engine:
environment:
- "SYMFONY_TMP_DIR=/tmp/ezplatformcache/"
If you want the cache to be generated on your host for PHPStorm for instance, just remove that line:
$ ~/ez up; ~/ez stop; ~/ez start
Enjoy!