Next, we are going to create the services for our application. Before we start to build our Docker development environment, we need to set up a directory structure for the project.
The Directory Structure
First, create a directory to contain your project. In this series, this folder will be called myproject.
Inside the myproject directory, create the following folder structure:
Since we now have a basic directory structure, let’s create a file called docker-compose.yml in your myproject directory.
In this file add:
version: '2' services:
The compose file is a YAML file that defines the services, networks, and volumes that we want to build and run. We will build out this file as we add our container services. So, you may want to keep this open.
Next, create a file called .env in your myproject directory. Docker Compose will use this configuration file. Here is the contents of this file:
# The type of application. # Determines which nginx conf file is used # Valid values: symfony or drupal8 APPLICATION_TYPE=symfony # Project Information # This will be the directory that the code is stored in. # If you change this value, you also need to change the location in the logstash.conf file PROJECT_NAME=project # Domains. Connect to the server using these domain names. DOMAIN_NAME=project.local PHPMYADMIN_DOMAIN_NAME=phpmyadmin.local # The name of the directory where web files are stored. # Symfony usually is 'web' and Drupal is 'public' WEBSITE_DIR=web # The HTTP and HTTPS ports that will be used to connect to the sites. HTTP_PORT=8080 HTTPS_PORT=4343 # MYSQL Settings MYSQL_ROOT_PASSWORD=root MYSQL_DATABASE=project MYSQL_USER=docker MYSQL_PASSWORD=docker MYSQL_PORT=33060 CHAR_SET_SERVER=utf8 COLLATION_SERVER=utf8_unicode_ci DEFAULT_CHAR_SET=utf8 # XDEBUG Settings XDEBUG_IDE_KEY=PHPSTORM XDEBUG_REMOTE_PORT=9000 # PHP-FPM. This should be different from xdebug PHP_FPM_PORT=9001 # Timezone to use. i.e. Europe/Berlin TIME_ZONE=US/Central # SSH Port for clients to connect to SSH_PUBLIC_PORT=2222
Now that we have a basic directory structure setup for our Docker development environment, our next step is to set up a MySQL container.