diff --git a/DOCKER_TIPS.md b/DOCKER_TIPS.md index 690004f..a81b1b1 100644 --- a/DOCKER_TIPS.md +++ b/DOCKER_TIPS.md @@ -1,19 +1,19 @@ ## Typical Docker Commands ### Start all environments services > docker-compose up --build - + ### Restart a specific container > docker restart [service name] - + ### List all containers > docker ps -a - + ### List running containers > docker ps - + ### See used space > docker system df - + ### Remove un-used data > docker system prune @@ -21,11 +21,7 @@ ### PostgreSQL > username: postgres_user > password: postgres_pass - - ### MySql - > username: mysql_user - > password: mysql_pass - + ### MariaDB > username: mariadb_user > password: mariadb_pass @@ -33,10 +29,10 @@ ## Running Xdebug with PHPStorm alongside Docker. From Docker versions 18.03 and above, Docker creates a special DNS name that resolves -to the internal IP address used by the host. +to the internal IP address used by the host. Old logic (that has not updated to special DNS name) will need to point to the IP of `10.254.254.254`. ``` sudo ifconfig lo0 alias 10.254.254.254 -``` \ No newline at end of file +``` diff --git a/README.md b/README.md index c08d688..b030a20 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,22 @@ # Sourcetoad Internal Development Tools (SIDT) Sourcetoad Internal Development Tools includes a growing collection of tutorials -for managing IDEs, hooking up tools with Docker and any combination of those +for managing IDEs, hooking up tools with Docker and any combination of those things. -Additionally, this repository holds our data source services which is -a collection of databases and other services that projects will more than likely -need. It also provides a proxy setup via nginx-proxy so that multiple projects +Additionally, this repository holds our data source services which is +a collection of databases and other services that projects will more than likely +need. It also provides a proxy setup via nginx-proxy so that multiple projects can be run at the same time without the need for different ports. -This means docker configurations for each project only needs to worry about the +This means docker configurations for each project only needs to worry about the the language and other tools it may need, as the databases and other services are standardized in this project. Since most cloud providers provide managed versions of these services, you likely would not use a docker version of them in production. ## Docker -### devop-tools (data source services / domain tools) +### Required: data source services 1. Execute `git clone git@github.com:sourcetoad/DevopsToolKit.git devop-tools` 2. `cd devop-tools` 3. `cd ./docker/data-source-services/` @@ -24,10 +24,9 @@ of these services, you likely would not use a docker version of them in producti - If this fails, then manual configuration is necessary before compilation. Perform the following: 1. `docker network create nginx-proxy` 2. `docker network create st-mariadb-102` - 3. `docker network create st-mysql-56` - 4. `docker network create st-postgres-95` - 5. `docker network create st-redis-32` - 6. `docker network create st-internal` + 3. `docker network create st-postgres-95` + 4. `docker network create st-redis-32` + 5. `docker network create st-internal` 5. Execute `docker-compose up --build` - If you're in a Windows environment, then perform the following if your build fails: 1. Kill, and optionally disable, the `World Wide Web Publishing Service`. @@ -36,11 +35,26 @@ of these services, you likely would not use a docker version of them in producti 6. Wait for the terminal to complete executing. 7. You now have Sourcetoad data sources running and logging to the console. +### Optional: data source tools +1. Optionally included is the following tools: + * phpMyAdmin +2. `cd devop-tools` +3. `cd ./docker/data-source-tools/` +4. Execute `docker-compose up --build` +5. Wait for the terminal to complete executing. +6. You now have Sourcetoad data source tools running. + +## phpMyAdmin +If the optional tools are launched, you can find phpMyAdmin at: localhost:8080 + * It supports the following databases... + * mariadb102 + * mariadb103 + ## Examples Inside the `examples` folder you will find example Docker configurations for popular frameworks like Laravel and Yii2. -The examples make the assumption that any domain used for local development is +The examples make the assumption that any domain used for local development is already added to the `/etc/hosts` file. You can edit to add `127.0.0.1 domain.docker`. ## Docs @@ -48,4 +62,3 @@ already added to the `/etc/hosts` file. You can edit to add `127.0.0.1 domain.do * [Setting up PHP Testing in PHPStorm](docs/phpstorm-docker/README.md) * [Setting up Python Debugging in Pycharm](docs/pycharm-debugging/README.md) * [Building a new Upsource Project](docs/upsource/README.md) - diff --git a/docker/data-source-services/docker-compose.yml b/docker/data-source-services/docker-compose.yml index 54422d1..4785c83 100755 --- a/docker/data-source-services/docker-compose.yml +++ b/docker/data-source-services/docker-compose.yml @@ -16,6 +16,7 @@ services: - ./proxy_increase.conf:/etc/nginx/proxy.conf networks: - nginx-proxy + - st-internal postgres95: image: postgres:9.5 container_name: sourcetoad_postgres95 @@ -26,23 +27,35 @@ services: - POSTGRES_PASSWORD=postgres_pass networks: - st-postgres-95 + - st-internal command: "postgres -c logging_collector='on' -c log_directory='/var/log/postgresql' -c log_filename='%Y-%m-%d.log' -c log_line_prefix='%t %v ' -c log_statement='all'" - mysql56: - image: mysql:5.6 - container_name: sourcetoad_mysql56 + mariadb104: + image: mariadb:10.4 + container_name: sourcetoad_mariadb104 ports: - - "3356:3306" + - "33104:3306" environment: - MYSQL_ROOT_PASSWORD=root - - MYSQL_USER=mysql_user - - MYSQL_PASSWORD=mysql_pass + - MYSQL_USER=mariadb_user + - MYSQL_PASSWORD=mariadb_pass + networks: + - st-internal + mariadb103: + image: mariadb:10.3 + container_name: sourcetoad_mariadb103 + ports: + - "33103:3306" + environment: + - MYSQL_ROOT_PASSWORD=root + - MYSQL_USER=mariadb_user + - MYSQL_PASSWORD=mariadb_pass networks: - - st-mysql-56 + - st-internal mariadb102: image: mariadb:10.2 container_name: sourcetoad_mariadb102 @@ -54,6 +67,7 @@ services: - MYSQL_PASSWORD=mariadb_pass networks: - st-mariadb-102 + - st-internal redis32: image: redis:3.2-alpine command: redis-server --appendonly yes @@ -62,6 +76,7 @@ services: - "6332:6379" networks: - st-redis-32 + - st-internal networks: nginx-proxy: external: @@ -69,12 +84,12 @@ networks: st-postgres-95: external: name: st-postgres-95 - st-mysql-56: + st-internal: external: - name: st-mysql-56 + name: st-internal st-mariadb-102: external: name: st-mariadb-102 st-redis-32: external: - name: st-redis-32 \ No newline at end of file + name: st-redis-32 diff --git a/docker/data-source-services/network-creation.sh b/docker/data-source-services/network-creation.sh index 58a6c28..9664368 100755 --- a/docker/data-source-services/network-creation.sh +++ b/docker/data-source-services/network-creation.sh @@ -1,7 +1,2 @@ echo "Creating container networks:\n" docker network create st-internal -docker network create nginx-proxy -docker network create st-mariadb-102 -docker network create st-mysql-56 -docker network create st-postgres-95 -docker network create st-redis-32 diff --git a/docker/data-source-tools/docker-compose.yml b/docker/data-source-tools/docker-compose.yml new file mode 100644 index 0000000..9f70557 --- /dev/null +++ b/docker/data-source-tools/docker-compose.yml @@ -0,0 +1,17 @@ +version: '2' +services: + phpmyadmin: + image: phpmyadmin/phpmyadmin:latest + container_name: sourcetoad_phpmyadmin + ports: + - 8080:80 + networks: + - st-internal + environment: + PMA_HOSTS: mariadb102,mariadb103,mariadb104 + PMA_USER: root + PMA_PASSWORD: root +networks: + st-internal: + external: + name: st-internal diff --git a/examples/laravel5/Dockerfile b/examples/laravel/Dockerfile similarity index 96% rename from examples/laravel5/Dockerfile rename to examples/laravel/Dockerfile index 7ea8cd4..5646e6c 100644 --- a/examples/laravel5/Dockerfile +++ b/examples/laravel/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.2-fpm-stretch +FROM php:7.4 # System dependencies needed RUN apt-get update && apt-get install -y \ @@ -58,6 +58,6 @@ RUN sed -i -e "s/pm.max_spare_servers\s*=\s*[0-9]*/pm.max_spare_servers = 10/g" RUN sed -i -e "s/;pm.max_requests\s*=\s*[0-9]*/pm.max_requests = 500/g" /usr/local/etc/php-fpm.d/www.conf RUN sed -i -e "s/access.log/;access.log/g" /usr/local/etc/php-fpm.d/docker.conf -# Expose PHP and execute php-fpm +# Expose PHP and execute php-fpm EXPOSE 9000 -CMD ["php-fpm"] \ No newline at end of file +CMD ["php-fpm"] diff --git a/examples/laravel5/config/php.ini b/examples/laravel/config/php.ini similarity index 100% rename from examples/laravel5/config/php.ini rename to examples/laravel/config/php.ini diff --git a/examples/laravel5/config/vhost.conf b/examples/laravel/config/vhost.conf similarity index 100% rename from examples/laravel5/config/vhost.conf rename to examples/laravel/config/vhost.conf diff --git a/examples/laravel5/docker-compose.yml b/examples/laravel/docker-compose.yml similarity index 77% rename from examples/laravel5/docker-compose.yml rename to examples/laravel/docker-compose.yml index 537382d..4df0fa4 100644 --- a/examples/laravel5/docker-compose.yml +++ b/examples/laravel/docker-compose.yml @@ -14,7 +14,6 @@ services: - ./config/vhost.conf:/etc/nginx/conf.d/vhost.conf networks: - st-internal - - nginx-proxy # PHP Container # The environment variables allow Xdebug to work properly. # Networks much like above can be registered depending on what the application @@ -29,20 +28,9 @@ services: - ../:/code networks: - st-internal - - st-mariadb-102 # These are networks that you are leveraging from outside (external) locations. -# The dev-ops repo is already running, so these networks already exist. We tell -# docker which networks of the dev-ops repo we need. +# The dev-ops repo is already running, so that network (st-internal) exists. networks: st-internal: external: name: st-internal - nginx-proxy: - external: - name: nginx-proxy - st-redis-32: - external: - name: st-redis-32 - st-mariadb-102: - external: - name: st-mariadb-102 \ No newline at end of file diff --git a/examples/yii2/Dockerfile b/examples/yii2/Dockerfile index 1d81b8a..1a7b0d8 100644 --- a/examples/yii2/Dockerfile +++ b/examples/yii2/Dockerfile @@ -1,5 +1,5 @@ FROM php:7.0-fpm - + # System dependencies needed RUN apt-get update && apt-get install -y \ git \ @@ -44,6 +44,6 @@ RUN sed -i -e "s/;pm.max_requests\s*=\s*[0-9]*/pm.max_requests = 500/g" /usr/loc RUN sed -i -e "s/access.log/;access.log/g" /usr/local/etc/php-fpm.d/docker.conf RUN sed -i -e "s/^error_log.*/error_log = \/proc\/self\/fd\/2/" /usr/local/etc/php-fpm.d/www.conf -# Expose PHP and execute php-fpm +# Expose PHP and execute php-fpm EXPOSE 9000 CMD ["php-fpm"] diff --git a/examples/yii2/docker-compose.yml b/examples/yii2/docker-compose.yml index 350aa0e..1d4a43a 100644 --- a/examples/yii2/docker-compose.yml +++ b/examples/yii2/docker-compose.yml @@ -14,7 +14,6 @@ services: - ./config/vhost.conf:/etc/nginx/conf.d/vhost.conf networks: - st-internal - - nginx-proxy # PHP Container # The environment variables allow Xdebug to work properly. # Networks much like above can be registered depending on what the application @@ -29,21 +28,9 @@ services: - ../:/code networks: - st-internal - - st-mariadb-102 - - st-redis-32 # These are networks that you are leveraging from outside (external) locations. -# The dev-ops repo is already running, so these networks already exist. We tell -# docker which networks of the dev-ops repo we need. +# The dev-ops repo is already running, so that network (st-internal) exists. networks: st-internal: external: name: st-internal - nginx-proxy: - external: - name: nginx-proxy - st-redis-32: - external: - name: st-redis-32 - st-mariadb-102: - external: - name: st-mariadb-102 \ No newline at end of file