|  | 
|  | 1 | +FROM ubuntu:21.04 | 
|  | 2 | + | 
|  | 3 | +ARG USERNAME=alex | 
|  | 4 | +ARG USER_UID=1000 | 
|  | 5 | +ARG USER_GID=$USER_UID | 
|  | 6 | + | 
|  | 7 | +# Create the user | 
|  | 8 | +RUN groupadd --gid $USER_GID $USERNAME \ | 
|  | 9 | +    && useradd --uid $USER_UID --gid $USER_GID -m $USERNAME | 
|  | 10 | + | 
|  | 11 | +# Update packages list & install missing packages | 
|  | 12 | +RUN apt-get update \ | 
|  | 13 | +    && export DEBIAN_FRONTEND=noninteractive \ | 
|  | 14 | +    # install missing packages | 
|  | 15 | +    && apt-get install -y sudo git curl wget make procps \ | 
|  | 16 | +    python3-pip unzip nodejs npm vim dos2unix apt-transport-https ca-certificates \ | 
|  | 17 | +    gnupg lsb-release | 
|  | 18 | + | 
|  | 19 | +# Finish setting up $USERNAME (sudo, no password etc ...) | 
|  | 20 | +RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ | 
|  | 21 | +    && chmod 0440 /etc/sudoers.d/$USERNAME | 
|  | 22 | + | 
|  | 23 | +# Install Docker CLI | 
|  | 24 | +RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg | 
|  | 25 | + | 
|  | 26 | +RUN echo \ | 
|  | 27 | +  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ | 
|  | 28 | +  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | 
|  | 29 | + | 
|  | 30 | +RUN  apt-get update \ | 
|  | 31 | +      && apt-get install -y docker-ce-cli | 
|  | 32 | + | 
|  | 33 | +# Python things: update pip | 
|  | 34 | +RUN python3 -m pip install pip --upgrade | 
|  | 35 | + | 
|  | 36 | +# Install required librairies | 
|  | 37 | +COPY ./requirements.txt /home/$USERNAME/ | 
|  | 38 | + | 
|  | 39 | +RUN pip install -r /home/$USERNAME/requirements.txt | 
|  | 40 | + | 
|  | 41 | +# Set $USERNAME as default user | 
|  | 42 | +USER $USERNAME | 
|  | 43 | + | 
|  | 44 | +# Add custom bashrc | 
|  | 45 | +COPY --chown=$USERNAME:$USERNAME ./bashrc /home/$USERNAME/.bashrc_extension | 
|  | 46 | +RUN echo "source ~/.bashrc_extension" >> ~/.bashrc && dos2unix ~/.bashrc_extension | 
|  | 47 | + | 
|  | 48 | +# Back to default shell | 
|  | 49 | +SHELL ["/bin/bash", "-c"] | 
|  | 50 | + | 
|  | 51 | +CMD [ "sleep", "infinity" ] | 
0 commit comments