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

Add uid and gid as Docker environment variables #396

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

Add uid and gid as Docker environment variables #396

wants to merge 2 commits into from

Conversation

platipo
Copy link
Contributor

@platipo platipo commented Oct 11, 2020

Reference: #388 (comment)

@platipo
Copy link
Contributor Author

platipo commented Oct 11, 2020

Hi @aaron-suarez, I added the dotenv orb an it seems working. Do you have any feedback?

Maybe using a variable for the group id is an overkill, what do you think?

@aaron-junot
Copy link
Member

Why is it 1000 sometimes and 5000 other times? Its not a problem I just don't understand what difference it makes

@platipo
Copy link
Contributor Author

platipo commented Oct 12, 2020

I wasn't sure if all was correct so I chose to set the environment default values to a different number if it had raised an error I would have confirmed that the variables weren't propagating correctly.

@platipo
Copy link
Contributor Author

platipo commented Oct 12, 2020

I can just set them all to 5000 if you want. Also do you want me to keep also the gid?

@aaron-junot
Copy link
Member

It's fine how it is if you just want to leave it. If you feel like removing the gid, you can as long as it still works

@platipo
Copy link
Contributor Author

platipo commented Oct 12, 2020

I'm ok with all the changes, do you prefer that Dockerfile default variables are 5000?

@aaron-junot
Copy link
Member

It's fine how it is. I'm mobile right now but when I get the chance to run it and make sure everything works, I'll approve and merge if nothing is broken. Thanks for this!

@platipo
Copy link
Contributor Author

platipo commented Oct 14, 2020

Hi @aaron-suarez, did you manage to try the changes?

@@ -23,7 +25,8 @@ RUN poetry install --no-dev --no-interaction --no-ansi

COPY . /src

RUN useradd --no-create-home --system -s /bin/false --uid 5000 uwsgi
RUN groupadd --gid $GID uwsgi \
&& useradd --no-create-home --system -s /bin/false --uid $UID --gid $GID uwsgi
Copy link
Member

Choose a reason for hiding this comment

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

When you exec into the container, it's a little weird not having a name. Maybe we should give it one?

$ docker exec -it a536b7b91577 /bin/bash
I have no name!@a536b7b91577:/src$ whoami
whoami: cannot find name for user ID 5000
I have no name!@a536b7b91577:/src$

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm very consufed by the missing name because both the uwsgi is specified as group and user name and in the container I just built the container and this is the output:

platipo:~/resources_api $ sudo docker run -p80:5000 -it --rm resources_api/uwsgi /bin/bash
uwsgi@e26da29e625a:/src$ whoami
uwsgi

Copy link
Member

Choose a reason for hiding this comment

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

I ran my container with make run, I wonder if that has something to do with it?

Copy link
Member

Choose a reason for hiding this comment

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

It does docker-compose run -p 5000:5000 resources-api flask run -h 0.0.0.0. If you do that, do you also find that you're missing the user?

${DOCKER_COMPOSE} run -p 5000:5000 ${RESOURCES_CONTAINER} ${FLASK} run -h 0.0.0.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried some solutions, but I have no clue how to solve this 😢

Copy link
Member

Choose a reason for hiding this comment

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

Ok when I have some time I'll see if I can solve it. Maybe it's worth merging and opening that as a separate issue... I'll want to give it one more good review before I determine that. Thanks for your patience on this

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