Skip to content
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

Docker support #34

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Docker support #34

wants to merge 4 commits into from

Conversation

filips123
Copy link

@filips123 filips123 commented Apr 3, 2019

I've added basic support for Docker. It is part of the fix for #27. That issue should still be opened because it is still not completed.

It is now possible to run the website with docker-compose up. It contains several containers for PHP, Ruby, SQL and Redis.


After cloning the repo, users should copy lib/config.docker.php to lib/config.php (and not edit it). That file loads config from environment variables.

Then, they should copy .env.sample to .env and provide configuration.

They can then start all containers with docker-compose up.


This has some problems.

The database is empty. Even if table schema is added at first run, tables will be empty. And this is a problem because the client_id would not be registered. There should be some admin website or console command to add clients.

Also, documentation is not finished. It needs to be finished after all other problems are fixed.

And all functionality needs to be tested because I didn't have time to do this completely.

@@ -0,0 +1,52 @@
<?php

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this self-defeating to make the values globally available twice?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only easy option.

You can't set static properties dynamically with function call so I have to first save them into constants.

But it may also work with normal variables instead of constants.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only easy option.

I think putting the argument in the connection utility fits better with a heroku + docker (12-factor) deployment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think putting the argument in the connection utility fits better with a heroku + docker (12-factor) deployment.

Can you explain this a bit more?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So instead of having config be the source for all things, you could instead build an interface and have multiple implementations that fulfil that interface to provide details.

A Lighter weight option that does similar would be using null coalesce operator, leaving the config as null, and Config::$value ?? ENV['ENV_VAR1'] ?? ENV['ENV_VAR2'];

http://sandbox.onlinephpfunctions.com/code/22d382de6f0128a63d11ba37b79a4c7d3faad57a is a trivial example

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is now setting properties directly from env vars. It doesn't need null coalesce operator, because env vars need to be set anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there has been confusion about my meaning.

Also blank string is not really the best option.

null specifically says "unknown"

@Lewiscowles1986
Copy link
Contributor

I've made a PR which I think explains what I think is a better approach to ENV based configuration. It was what I was trying to explain to you.

Basically there should be no need for Config in environments such as Docker

@aaronpk aaronpk changed the base branch from master to main November 26, 2020 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants