Hello everyone, a couple of developers are using ...
# docker
s
Hello everyone, a couple of developers are using Linux desktop systems with multiple user accounts. Their own is never UID 1000. It seems that docker/sdk makes a mistake here or has hardcoded values for UID 1000. If I start our project on such a system with a user who has UID 1001, directory permissions are incorrectly set to UID 1000, which makes loggers and caches unable to write their files, docker/sdk Version 1.23 How can we get this resolved? Any ideas? PS: This can easily be replicated by setting up a VM and giving your user a different UID than 1000.
šŸ‘ 1
h
It worked fine for me with any UID on my Linux. However docker can have some cross-platform problems. I am not aware of it. docker/sdk currently bakes UID when building docker images, so spryker user becomes with the UID of your user on host.
Could you run this one (name of image can be different based on your deploy.y,l) ?
Copy code
docker run -it spryker_cli:dev id
s
Ok, first thing's first:
Copy code
problems@failwhale:~/shop$ id
uid=1001(problems) gid=1001(problems) groups=1001(problems),997(docker)
problems@failwhale:~/shop$ docker run -it anon_dev_cli:dev id
uid=1001(spryker) gid=82(www-data) groups=82(www-data)
problems@failwhale:~/shop$ docker/sdk cli id
-->  DEVELOPMENT MODE   
uid=1001(spryker) gid=82(www-data) groups=82(www-data)
Starting docker/sdk works just fine, BUT when I reach the point where the demo data gets initialized, a log is trying to get written and that fails:
Copy code
Command propel-copy-schema [vendor/bin/console propel:schema:copy] (In progress...)
Store: DE | Environment: docker
Clean schema directory
Copy and merge schema files
UnexpectedValueException - Exception: There is no existing directory at "/var/log/spryker/DE/ZED" and it could not be created: Permission denied 
in /data/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php (172)

Command: vendor/bin/console propel:schema:copy

Trace: 
#0 /data/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php(100): Monolog\Handler\StreamHandler->createDir()
#1 /data/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(42): Monolog\Handler\StreamHandler->write(Array)
...
The interesting thing here is the "Permission denied". If I have a peak into the log directory, this is how it's looking like:
Copy code
problems@failwhale:~/shop$ docker/sdk cli
-->  DEVELOPMENT MODE   

ā”Œā”€ā”€ā”€ā”€ā”           ā”Œā”€ā”            ā”Œā”€ā”€ā”€ā”¬ā”€ā” ā”Œā”€ā”€ā”€ā”
│ ───┼───┬─┬─┬─┬─┤ ā”œā”€ā”¬ā”€ā”€ā”€ā”¬ā”€ā”¬ā”€ā”  │ ā”Œā”€ā”¤ │ └│ ā”‚ā”˜
ā”œā”€ā”€ā”€ │ ┼ │ ā”Œā”€ā”¤ │ │───┤ ┼─┤ ā”Œā”€ā”˜  │ └─┤ └─┬│ │┐
└────┤  ā”Œā”“ā”€ā”˜ ā”œā”€ā” ā”œā”€ā”“ā”€ā”“ā”€ā”€ā”€ā”“ā”€ā”˜    ā””ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”˜
     ā””ā”€ā”€ā”˜    ā””ā”€ā”€ā”€ā”˜

╭─/data | Store: DE | Env: docker | Debug: (.) | Testing: (.)
╰─$ ls -la /var/log/spryker
total 12
drwxr-xr-x 2 1000 spryker 4096 Nov  4 21:22 .
drwxr-xr-x 1 root root    4096 Nov  4 21:19 ..
-rw-r--r-- 1 root root    1521 Nov  4 21:22 supervisord.log
This line is the interesting one:
Copy code
drwxr-xr-x 2 1000 spryker 4096 Nov  4 21:22 .
To me, it's looking like the image gets built properly but some process `chown`s that folder in a hardcoded process or something of that magnitude. Specs of what I'm testing with:
Copy code
problems@failwhale:~/shop$ docker --version
Docker version 19.03.13, build 4484c46d9d
problems@failwhale:~/shop$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.1 LTS
Release:	20.04
Codename:	focal
Any ideas?
@high-pencil-62400 ^
h
1. I would advise to use php://stderr for logs. 2. /var/log/spryker is a volume in docker-compose. It seems it is inited with 1000 UID.
s
/var/log/spryker is a volume in docker-compose. It seems it is inited with 1000 UID.
How can I change this behaviour? Again, this means docker/sdk is broken for this use case where the user does not have UID 1000.
h
I agree it is a problem we need to solve. Probably it is outside of docker/sdk responsibility as it is docker-compose side effect. However if you use php://stderr for logs docker/sdk works regardless UID. And that is the only proper way to do logging in containers. Files must not be used.
šŸ‘ 1
s
One more follow up question: How will I use docker/sdk logs then? What it normally does is to tail the logs.
h
There are 2 options: 1.
docker logs spryker_yves_1 -f
Using docker logs. 2. You can use dashboard service:
Copy code
dashboard:
        engine: dashboard
        endpoints:
            spryker.local:
There is a link to UI that shows logs from all containers.
We are thinking about extending docker/sdk logs to manage logs in more appropriate way