-
Notifications
You must be signed in to change notification settings - Fork 280
Use .env file for directory/db #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Using an environment file for directory/db has the advantage that the user does not need to specify the variables after each reboot. Added `.env` to gitignore list, to avoid that envirenment variables end up in repository. Created `moodle-start` for convenience. Imroved new readme. Closes #80 Closes #81
export MOODLE_DOCKER_DB=pgsql | ||
|
||
# Ensure customized config.php for the Docker containers is in place | ||
cp config.docker-template.php $MOODLE_DOCKER_WWWROOT/config.php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still seems necessary for someone to quick start?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoups your right. I added a create-moodle-config
script and updated the readme in the latest commit.
bin/moodle-start
Outdated
#!/usr/bin/env bash | ||
|
||
bin/moodle-docker-compose up -d | ||
bin/moodle-docker-wait-for-db |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
I'm not very convinced of the value of this
moodle-start
script. My 'philosophy' when originally designing this project was just to add the 'minimum helpers' to get by for convenience and scriptability, but encourage people to use the docker compose commands when necessary. This seems to abstracting what's going on under the hood more than I think this project should. For most people, doingmoodle-docker-compose up -d
will be enough for their workflow of development. -
I don't think this script is well named.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand your philosophy and removed the script.
I realise I just posted two negative comments - I think the rest of the |
Thank you. I also think using an |
Let people decide if they want to set the directory path in the terminal instead of the envirenment file. This also should make travis pass the tests.
Hi @iwasherefirst2, nice improvement! Would you mind, please, rebasing your commits on top of current master (I think you will face some minor conflicts to solve with that). And then proceed to squash current 6 commits, so everything can get the final review and, hopefully, land all-together? Ciao :-) |
Side comment about this patch, because for example it will affect some of my usual flows with moodle-docker. Maybe the Real example: I've here some wrappers over moodle-docker that are basically a couple of nested loops changing the PHP versions ( But, if I normally want to work with So, just guessing if we should consider "renaming" all this from "env" to "defaults" and provide that slightly different behavior. For people not switching often it will behave 100% the same. But for crazy-switchers will make life easier. Thoughts? BTW, another little idea, is that maybe the Up to you, only a couple of details that came to my brain when reviewing current proposed patch. Thanks for your contribution, much appreciated! Ciao :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think this add any value (besides the addition to the gitignore file).
If people want to save these variables they are free to create a .env file themselves and source it beforehand. This is also what every seasoned dev probably already does. Therefore adding the entry to the gitignore file seems like a good idea and mentioning that this can be done in the docs will not hurt either. However adjusting all the scripts etc does not really add any value IMO.
|
||
if [ -f .env ]; | ||
then | ||
source .env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not work as the variables are not exported (at least inside you sample env file)
Also applies to all following uses of source .env
4. Run `bin/create-moodle-config`. This copies the `config.php` into Moodle. | ||
You only have to call this command onces. | ||
4. Run `bin/moodle-docker-compose up -d` inside `moodle-docker` folder to create the container. | ||
5. You may have to call also `bin/moodle-docker-wait-for-db` if you use `oracle/mssql`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may have to -> You should (at least to my knowledge you always want to do this if you execute these commands directly after each other)
2. Rename `.env.example` to `.env` | ||
3. Specify Moodle directory and db driver in `.env` | ||
4. Run `bin/create-moodle-config`. This copies the `config.php` into Moodle. | ||
You only have to call this command onces. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to me like a more complicated setup than what was here previously.
# Set up path to Moodle code | ||
MOODLE_DOCKER_WWWROOT=/path/to/moodle/code | ||
# Choose a db server (Currently supported: pgsql, mariadb, mysql, mssql, oracle) | ||
MOODLE_DOCKER_DB=pgsql |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These need an export before them if you want to source them from the scripts. dotenv files like you know them from php, python etc will not work with shells.
I have used a bit different approach in #232 |
Using an environment file for directory/db
has the advantage that the user does not need
to specify the variables after each reboot.
Added
.env
to gitignore list, to avoidthat environment variables end up in repository.
Created
moodle-start
for convenience.Updated readme.
Closes #80
Closes #81