Skip to content

Commit

Permalink
fix composer data directory
Browse files Browse the repository at this point in the history
  • Loading branch information
lombax85 committed Oct 10, 2016
1 parent aa18806 commit 704bf04
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
4 changes: 3 additions & 1 deletion .env.composer
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ PROJECT_DIRECTORY=../
# if the project web/public directory is a subdir (like "public" in Laravel) declare here its name. If no subdir is used, leave this field empty
PROJECT_SUBDIRECTORY=public

# name of the directory containing the docker modules and docker files
# name of the directory containing the docker modules and docker files - default docker
DOCKER_DIRECTORY=docker
# name of the directory containing the docker data - default docker/data
DOCKER_DATA_DIRECTORY=../../docker_data

# environment variables for apache and mysql
# these ports are bind on your local host
Expand Down
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ PROJECT_DIRECTORY=project
# if the project web/public directory is a subdir (like "public" in Laravel) declare here its name. If no subdir is used, leave this field empty
PROJECT_SUBDIRECTORY=public

# name of the directory containing the docker modules and docker files
# name of the directory containing the docker modules and docker files - default docker
DOCKER_DIRECTORY=docker
# name of the directory containing the docker data - default docker/data
DOCKER_DATA_DIRECTORY=docker/data

# environment variables for apache and mysql
# these ports are bind on your local host
Expand Down
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ INSTALL
Depending on your project's structure, you can use different approaches.


### Existing project - composer dependency (EXPERIMENTAL - don't use in production and backup your data, look in the ISSUES section)
### Existing project - composer dependency (EXPERIMENTAL - test well before using in production and backup your data)
- In the "extra" section of your project's composer.json file, add
```
"extra": {
Expand Down Expand Up @@ -48,6 +48,11 @@ NOTE: Since docker-compose use the containing folder name as the prefix for its
```
replacing the "docker" folder with something unique in your system, like "docker-projectname"

EXTRA: add /docker and /docker_data in your project's .gitignore file

##WARNING
Informations about the data directory: in the .env.composer file, the data directory is configured to be inside "docker_data", placed in your main project's dir. The directory is created when you start your containers the first time. If you want to change this path, please don't place the directory inside the "docker" folder, since the folder is recreated every time you run "composer update" and you'll lost data.


### Alternative - Existing project - install in root directory
- Download this repository as zip
Expand Down Expand Up @@ -179,9 +184,9 @@ Go to these urls to see the results:

The test code is in ./project/routes/web.php

ISSUES
ACTUAL ISSUES
-----------------------
- including as a composer dependencies is, by now, only for testing and development machines. There is a known issue where the ./docker/data directory (the directory containing database data) is deleted if the package is updated via "composer update". This will be solved in a future release, if you plan to use this project in a production environment don't use composer, use other inclusion methods explained in the INSTALL section

- If you stop (ctrl+c) during "docker-compose up" during the first container startup, the content of /docker/data can became corrupt or not correctly initialized. In this case, for example, you won't be able to connect to MySQL.
To solve:

Expand All @@ -191,6 +196,10 @@ rm -Rf ./docker/data/mysql/*
```
NOTE: if you wipe MongoDB Data, don't forget to re-add the default user

FIXED ISSUES
-----------------------
- including as a composer dependencies is, by now, only for testing and development machines. There is a known issue where the ./docker/data directory (the directory containing database data) is deleted if the package is updated via "composer update". This will be solved in a future release, if you plan to use this project in a production environment don't use composer, use other inclusion methods explained in the INSTALL section. FIXED BY: now the data directory is created inside your main project's directory

TODO
-----------------------
- make the composer version reliable, maybe is good a simple script that stops containers, back-up data directory and then, after update, restore it? Or better to deny update until you have done a backup?
- create install.php install script to replace the post-install and post-update hooks
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ services:
volumes_data:
image: tianon/true
volumes:
- ./${DOCKER_DIRECTORY}/data/mysql:/var/lib/mysql
- ./${DOCKER_DIRECTORY}/data/memcached:/var/lib/memcached
- ./${DOCKER_DIRECTORY}/data/mongo:/data/db
- ./${DOCKER_DIRECTORY}/data/sessions:/sessions
- ./${DOCKER_DATA_DIRECTORY}/mysql:/var/lib/mysql
- ./${DOCKER_DATA_DIRECTORY}/memcached:/var/lib/memcached
- ./${DOCKER_DATA_DIRECTORY}/mongo:/data/db
- ./${DOCKER_DATA_DIRECTORY}/sessions:/sessions
# - ./data/postgres:/var/lib/postgresql/data
# - ./data/redis:/data
# - ./data/neo4j:/var/lib/neo4j/data
Expand Down

0 comments on commit 704bf04

Please sign in to comment.