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

Avoid hardcoded UID and GID in docker build #67

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Commits on Aug 3, 2021

  1. Avoid hardcoded UID and GID in docker build

    The [Dockerfile](https://github.com/nextstrain/docs.nextstrain.org/blob/1da467787db9a8f9b43724f3c41264fa30ff4db6/Dockerfile) uses `UID` and `GID` args to create a user inside the container. Files are then written during build on behalf of this user, to avoid permission problems.
    
    Mistakenly, these variables were both hardcoded to `1000`, which is fine for a single-user Linux host, bot not for macOS. 
    
    This PR passes `UID` and `GID` from the host system as build args, so that the files are written on behalf of the the current user.
    ivan-aksamentov committed Aug 3, 2021
    Configuration menu
    Copy the full SHA
    1ea65c1 View commit details
    Browse the repository at this point in the history
  2. Fix image name

    ivan-aksamentov committed Aug 3, 2021
    Configuration menu
    Copy the full SHA
    c5a1f11 View commit details
    Browse the repository at this point in the history

Commits on Aug 4, 2021

  1. Attempt to fix the error of existing group and/or user on mac

    The error was
    ```
    addgroup: The GID `20' is already in use
    ```
    
    Turns out nowadays Docker for Mac and Docker for Windows translate UID and GID automagically. And apparently it makes it so that the GID (and perhaps UID?) already exist in the container. This is not the case on Linux.
    
    All Dockerfiles relying on consistent UID and GID across platforms are now broken. And it's the only good way (not mentioning half-baked rootles mode that noone ever bothers to confugure) to get docker containers to not run as root and to not create bunch of root-owned files in volumes. What a wonderful decision!
    
    So maybe if we try to only create the group and the user if not already exist,  this will avoid errors? I cannot test it because I don't have a mac.
    
    See: https://stackoverflow.com/questions/43097341/docker-on-macosx-does-not-translate-file-ownership-correctly-in-volumes
    ivan-aksamentov committed Aug 4, 2021
    Configuration menu
    Copy the full SHA
    6118b1d View commit details
    Browse the repository at this point in the history