Skip to content

Commit

Permalink
Add a non root user
Browse files Browse the repository at this point in the history
  • Loading branch information
bhack committed Sep 10, 2021
1 parent 6cf8b34 commit 57376a6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
18 changes: 16 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
FROM python:3.9

# https://code.visualstudio.com/docs/remote/containers-advanced#_creating-a-nonroot-user
ARG USERNAME=keras-vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& apt-get update \
&& apt-get install -y sudo bash \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

# Install Bazel
RUN apt update
RUN apt install curl gnupg -y
Expand All @@ -8,5 +23,4 @@ RUN mv bazel.gpg /etc/apt/trusted.gpg.d/
RUN echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list
RUN apt update && apt install bazel -y

# Override the entrypoint
CMD ["bash"]
USER $USERNAME
15 changes: 13 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
{
"dockerFile": "Dockerfile",
"postCreateCommand": "pip install -r requirements.txt && pip uninstall keras-nightly -y",
"extensions": ["ms-python.python"]
}
"extensions": ["ms-python.python"],
"settings": {
"files.watcherExclude": {
"**/bazel-*/**": true
},
"search.exclude": {

"**/bazel-*/**": true
},
"terminal.integrated.defaultProfile.linux": "bash",
},
"remoteUser": "keras-vscode"
}

0 comments on commit 57376a6

Please sign in to comment.