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

WIP: Feature/docker setup #3

Merged
merged 13 commits into from
Mar 10, 2019
Merged

WIP: Feature/docker setup #3

merged 13 commits into from
Mar 10, 2019

Conversation

pinboro
Copy link
Contributor

@pinboro pinboro commented Mar 7, 2019

Introduce a simple Docker / docker-compose setup for local environment.

Copy link
Owner

@r3c r3c left a comment

Choose a reason for hiding this comment

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

npm protection is a good thing and shouldn't be worked around IMO, configure script is expected to work fine without the need for root account.

@pinboro
Copy link
Contributor Author

pinboro commented Mar 7, 2019

I am considering running the script with Apache user.

@pinboro
Copy link
Contributor Author

pinboro commented Mar 7, 2019

@r3c Updated.

Copy link
Owner

@r3c r3c left a comment

Choose a reason for hiding this comment

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

Thanks! I'll checkout your change locally to try it, as I'm clearly missing knowledge about Docker :)

.gitignore Outdated Show resolved Hide resolved
INSTALL.md Show resolved Hide resolved
INSTALL.md Show resolved Hide resolved
setup/docker/initdb.php Show resolved Hide resolved
docker-compose.yml Show resolved Hide resolved
setup/docker/entrypoint.sh Show resolved Hide resolved
Copy link
Owner

@r3c r3c left a comment

Choose a reason for hiding this comment

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

I got stuck when trying to run yAronet using this Docker setup because no locale was configured. I believe something like this in the Dockerfile should do the trick:

apt-get install -y locales # can be added to your existing apt-get command
sed -ri 's/# (en_US.UTF-8 UTF-8)/\1/' /etc/locale.gen
locale-gen

There are other stuff missing but they're bugs in my code rather than related to this review, so I'll quickly fix them :) (RewriteBase is incorrect in .htaccess files, configuration of static directory seems invalid, and website logo doesn't display properly)

@pinboro
Copy link
Contributor Author

pinboro commented Mar 9, 2019

Oh, yeah, I was sticking to 'C' locale, which you need to input on the install.php page. But let's adjust to your default one.

RewriteBase needs at least one argument, which is "/" in my case. Could you update the default to be "/" please?

@r3c
Copy link
Owner

r3c commented Mar 9, 2019

Yes you're right about RewriteBase being broken, let me fix that :)

@pinboro
Copy link
Contributor Author

pinboro commented Mar 10, 2019

Default locale changed to en_US.UTF-8

@pinboro
Copy link
Contributor Author

pinboro commented Mar 10, 2019

Added a retry loop for db connection to not fail hard when db container is not ready yet.

@r3c
Copy link
Owner

r3c commented Mar 10, 2019

Almost there! It's mostly working now, the only remaining issue I can't get around for now is parser.php not being generated. When I run sudo docker-compose up command, following message appears in the log:

{ [Error: EACCES: permission denied, open 'src/parser.php']
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: 'src/parser.php' }

I don't know if it's related to root user or something else and will continue to investigate. Thanks for all your new changes!

[update] Grant permissions on setup/module to www-data from the entrypoint.sh script does the trick, although I'm not sure this is a really clean way of dealing with the issue as it's visible from host point of view.

Now this is done I'm having errors when web host tries to mount, saying it cannot resolve the DB hostname 😕

@pinboro
Copy link
Contributor Author

pinboro commented Mar 10, 2019

Can you share the entire log?

@pinboro
Copy link
Contributor Author

pinboro commented Mar 10, 2019

Also, this is good to do to be able to run docker command with being root.

https://docs.docker.com/install/linux/linux-postinstall/#manage-docker-as-a-non-root-user

@r3c
Copy link
Owner

r3c commented Mar 10, 2019

That's not the same: your link describes how to configure Docker to avoid entering sudo docker on every command. What I was referring to is the chown call made on source files to switch them to www-data user, which I understand is needed for Apache to serve development files that are supposedly owned by current user instead. However this makes them impossible to update from host system anyway, which is not a desirable effect. I'll search how to avoid this in a further commit.

Here is the log, seems something is going wrong with the SQL setup, I'll try to see what exactly:

Creating network "yaronet_default" with the default driver
Creating yaronet_db_1 ... 
Creating yaronet_db_1 ... done
Creating yaronet_web_1 ... 
Creating yaronet_web_1 ... done
Attaching to yaronet_db_1, yaronet_web_1
db_1   | Initializing database
db_1   | 2019-03-10T10:32:01.699366Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
db_1   | 2019-03-10T10:32:01.704379Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
db_1   | 2019-03-10T10:32:01.704398Z 0 [ERROR] Aborting
db_1   | 
yaronet_db_1 exited with code 1
web_1  | audited 4435 packages in 6.823s
web_1  | found 1 low severity vulnerability
web_1  |   run `npm audit fix` to fix them, or `npm audit` for details
web_1  | built src/parser.php
web_1  | audited 2 packages in 0.855s
web_1  | found 0 vulnerabilities
web_1  | 
web_1  | 
web_1  | Warning: mysqli::__construct(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | Warning: mysqli::__construct(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: No address associated with hostname
web_1  | Retrying...(9)
web_1  | 
web_1  | Warning: mysqli::__construct(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | Warning: mysqli::__construct(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: No address associated with hostname
web_1  | Retrying...(8)
web_1  | 
web_1  | Warning: mysqli::__construct(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | Warning: mysqli::__construct(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: No address associated with hostname
web_1  | Retrying...(7)
web_1  | 
web_1  | Warning: mysqli::__construct(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | Warning: mysqli::__construct(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: No address associated with hostname
web_1  | Retrying...(6)
web_1  | 
web_1  | Warning: mysqli::__construct(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | Warning: mysqli::__construct(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: No address associated with hostname
web_1  | Retrying...(5)
web_1  | 
web_1  | Warning: mysqli::__construct(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | Warning: mysqli::__construct(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: No address associated with hostname
web_1  | Retrying...(4)
web_1  | 
web_1  | Warning: mysqli::__construct(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | Warning: mysqli::__construct(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: No address associated with hostname
web_1  | Retrying...(3)
web_1  | 
web_1  | Warning: mysqli::__construct(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | Warning: mysqli::__construct(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: No address associated with hostname
web_1  | Retrying...(2)
web_1  | 
web_1  | Warning: mysqli::__construct(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | Warning: mysqli::__construct(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: No address associated with hostname
web_1  | Retrying...(1)
web_1  | 
web_1  | Warning: mysqli::__construct(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | Warning: mysqli::__construct(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: No address associated with hostname in /yaronet/setup/docker/initdb.php on line 12
web_1  | 
web_1  | MySQL Connection Error: (2002) php_network_getaddresses: getaddrinfo failed: No address associated with hostname
yaronet_web_1 exited with code 1```

@pinboro
Copy link
Contributor Author

pinboro commented Mar 10, 2019

I know it is not the same, just sharing for removing you some pain:)

@r3c
Copy link
Owner

r3c commented Mar 10, 2019

Ah OK :)

[edit] Removed the "tmp" folder, now it's booting. Let's wait and see :)

@r3c
Copy link
Owner

r3c commented Mar 10, 2019

Working! Here is the only change I applied to your latest patch:

$ git diff
diff --git a/setup/docker/entrypoint.sh b/setup/docker/entrypoint.sh
index bb47fc3..f0aaf9b 100755
--- a/setup/docker/entrypoint.sh
+++ b/setup/docker/entrypoint.sh
@@ -10,7 +10,7 @@ ln -s ${APP_HOME}/src /var/www/html
 
 # Install dependencies
 cd ${APP_HOME}
-chown -R www-data:www-data src /var/www
+chown -R www-data:www-data setup/module src /var/www
 npm install
 su -s setup/configure.sh www-data

How do you feel about applying this change and merging your patch into master? Seems a good baseline :)

@pinboro
Copy link
Contributor Author

pinboro commented Mar 10, 2019

I am good!
Let’s push a first baseline.

There are improvement points around the entrypoint, and permissions, but they are not critical for a local environment.

@r3c r3c merged commit fe368d1 into r3c:master Mar 10, 2019
@r3c
Copy link
Owner

r3c commented Mar 10, 2019

Done! Thanks a lot for your contribution and help! 👍

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