BEAR application Docker development environment construction example (docker-sync, Mutagen)

Introduction

Docker is becoming the mainstream backend development environment [^ 1]. I like to install and use PHP directly on my local PC, but there are many cases where this is not the case. The BEAR.Sunday application has a lot of I/O for auto-generated files, so performance is an issue in the Mac Docker environment. As an example of the solution, gamu1012 posted an article last year Use docker \ -sync when developing with Docker \ + BEAR \ .Sunday. Also, in another article, I learned that the file synchronization that docker-sync does can also be achieved with Mutagen. [^ 2] In this article, I will write about building the BEAR development environment using docker-sync and Mutagen, respectively, both having the same performance and speed, and the usability.

Verification environment

--macOS Catalina Processor 1.4GHz Memory 16 GB

docker-sync, Mutagen environment construction example

Mutagen setting location

docker-compose.mutagen.yml

version: '3'

services:
  app:
    build:
      context: .
      dockerfile: docker/php/Dockerfile
    expose:
      - '9000'
    volumes:
      - source-con-sun:/var/www/html/

  web:
    build: docker/nginx/
    ports:
      - '1758:80'
    volumes:
      - source-con-sun:/var/www/html/
    links:
      - app
    depends_on:
      - app

volumes:
  source-con-sun:

x-mutagen:
  sync:
    defaults:
      ignore:
        vcs: true
    source-con-sun:
      alpha: "."
      beta: "volume://source-con-sun"
      mode: "two-way-resolved"
      ignore:
        paths:
          - var/log/hal-app/last.logref.log
      configurationBeta:
        permissions:
          defaultFileMode: 0666
          defaultDirectoryMode: 0777

--Volume mount settings --Added x-mutagen field

BEAR app performance results by environment

BEAR installation default index.php response time:

Environment Time
Default Docker 1.10 sec
Docker + docker-sync 117 ms
Docker + Mutagen 162 ms

--Specified context: hal-app --Refer to the above repository for details on measurement procedures, etc.

As you can see, docker-sync and Mutagen are about the same and faster.

Problems when using Mutagen

――I was stressed that Mutagen had to wait for about 1 minute at startup. It may be possible to improve by the setting method, but it has not been investigated. Also, since a synchronization error will occur with a symbolic link that includes an absolute path, it was necessary to set exclusions. [^ 3]

At the end

From the above issues, I wondered if docker-sync would still be good for Mac Docker at this time. This is the article of BEAR \ .Sunday Advent Calendar 2020 12/22. Wish you a good year! : dolphin:

Reference article

-Use Mutagen to speed up Docker, which is a heavy development environment, by 3 times \ | GRIPHONE ENGINEER'S BLOG -Recently \ (2020/08 ) Docker for Mac file access slow problem memo -Qiita

* Note: docker-sync installation procedure with homebrew

Although it is irrelevant to the main subject, it took a lot of time to install docker-sync in my environment, so I will describe the solution.

brew install eugenmayer/dockersync/unox

Occasionally the following error occurred (Python 3.8 environment).

The version of Python to use with the virtualenv in the `eugenmayer/dockersync/unox` formula\ncannot be guessed automatically because a recognised Python dependency could not be found.
If you are using a non-standard Python depedency, please add 
`:using => \"[email protected]\"` to\n`virtualenv_install_with_resources` to resolve the issue manually.

brew edit unox As After rewriting depends_on "python @ 3" to depends_on "python @ 3.8 ", the installation was completed. [^ 4]

[^ 1]: What is Docker? -EY \ -Office

[^ 2]: Abandon Docker for Mac, which significantly reduces DX, and get the fastest Docker environment for Mac -Qiita

Recommended Posts

BEAR application Docker development environment construction example (docker-sync, Mutagen)
Rails application development environment construction with Docker [Docker, Rails, Puma, Nginx, MySQL]
Laravel development environment construction with Docker (Mac)
Sapper × Go (echo) × Docker development environment construction
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
Spring Boot + Docker Java development environment construction
Docker environment construction
[Jakarta EE 8 application development with Gradle] 1. Environment construction
A reminder of Docker and development environment construction
Wordpress local environment construction & development procedure with Docker
Rails Docker environment construction
java development environment construction
Rails6 development environment construction [Mac]
WSL2 + VSCode + Docker development environment
MySQL 5.7 (Docker) environment construction memo
Redmine (Docker) environment construction memo
[Docker] Rails 5.2 environment construction with docker
Docker × Spring Boot environment construction
[Docker] postgres, pgadmin4 environment construction
React environment construction with Docker
Web application development environment construction in Java (for inexperienced people)
Java web application development environment construction with VS Code (struts2)
Rails + MySQL environment construction with Docker
Node.js environment construction with Docker Compose
Ruby on Rails --From environment construction to simple application development on WSL2
Environment construction with Docker for beginners
Ruby on Rails development environment construction with Docker + VSCode (Remote Container)
Laravel + Docker Laradock usage environment construction
[Unity] Android development environment construction procedure
Procedure for building a Rails application development environment with Docker [Rails, MySQL, Docker]
Rails on Docker environment construction procedure
PostgreSQL environment construction with Docker (from setup to just before development)
[Environment construction with Docker] Rails 6 & MySQL 8
Build Unity development environment on docker
Creating a java web application development environment with docker for mac part1
I tried to build a Firebase application development environment with Docker in 2020
Create a java web application development environment with docker for mac part2
SQL statement learning ~ Environment construction ~ Docker + MySQL
CentOS8 + Anaconda + Django development environment construction procedure
GPU environment construction with Docker [October 2020 version]
[Processing x Java] Construction of development environment
Rails environment construction with Docker (personal apocalypse)
Build a PureScript development environment with Docker
Universal Robotics UR Caps development environment construction
Java development environment construction memo on Mac
Environment construction with Docker (Ubuntu20.04) + Laravel + nginx
Create Spring Boot-gradle-mysql development environment with Docker
Laravel + MySQL + phpMyadmin environment construction with Docker
Build a Wordpress development environment with Docker
Build an Ultra96v2 development environment on Docker 1
Lightweight PHP 7.4 development environment created with Docker
Java application development environment created in VM environment
Build a simple Docker + Django development environment
[For beginners] Laravel Docker AWS (EC2) How to easily deploy Web application (PHP) from 0 (free) ②-Docker development environment construction-
Spring Boot environment construction with Docker (January 2021 version)
Build a development environment for Docker + Rails6 + Postgresql
Docker + DynamoDB local + C ++ environment construction and practice
Environment construction command memo with Docker on AWS
Build a WordPress development environment quickly with Docker
Kaggle environment construction using official Docker and vscode
Rails6 [API mode] + MySQL5.7 environment construction with Docker