user411103
user411103

Reputation:

Edit source code in Docker

I am running on my local machine a Drupal site with its MySQL database, and the source code is split into many Github repositories (one for each module).

As making the website running on a new machine is very time-consuming for all the repositories and migrating the database, I was thinking if Docker can help. A couple of questions:

Upvotes: 1

Views: 1917

Answers (2)

Mark O'Connor
Mark O'Connor

Reputation: 78021

The following compose file can be used to run Drupal. You can adapt it by changing the directory volume mappings.

docker-compose.yml

db:
  image: mysql
  environment:
    - MYSQL_ROOT_PASSWORD=letmein
    - MYSQL_DATABASE=drupal
    - MYSQL_USER=drupal
    - MYSQL_PASSWORD=drupal
  volumes:
    - /var/lib/mysql
web:
  image: drupal
  links:
    - db:mysql
  ports:
    - "8080:80"
  volumes:
    - /var/www/html/sites
    - /var/www/private

Upvotes: 0

f1nn
f1nn

Reputation: 7057

Can Docker encapsulate the entire drupal site, including the database with some data already there?

Yes. When stating a container, use option -v $ext_source:$int_source to mount volume from host machine to VM. Example:

docker run ... -v ~/sql/mysite:/srv/sql -v ~/dev/mysite:/srv/code ... Arturo/mysite.dev:0.1

This will mount two directories from you localhost to VM, you just need to point DB inside Docker container to use mounted data.

BTW, mounted directories can be edited in real-time. So, if you mount a source code directory inside your container and then edit the code on host machine, your changes are available inside container.

Upvotes: 2

Related Questions