Skip to content

Add initial vscode devcontainer support #1309

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "TensorFlow-addons",
"dockerFile": "../tools/docker/gpu_tests.Dockerfile",
"context": "..",
"extensions": [
"ms-python.python",
"ms-vscode.cpptools"
],

// Uncomment to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-in-docker.
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],

// To connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",

// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": null
},
"build": {
"target": "interactive_dev",
}
}
36 changes: 34 additions & 2 deletions tools/docker/gpu_tests.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM tensorflow/tensorflow:2.1.0-custom-op-gpu-ubuntu16
FROM tensorflow/tensorflow:2.1.0-custom-op-gpu-ubuntu16 as base

COPY tools/install_deps/tensorflow.txt ./

Expand All @@ -10,7 +10,39 @@ RUN python3 -m pip install -r requirements.txt
COPY tools/install_deps/finish_bazel_install.sh ./
RUN bash finish_bazel_install.sh


FROM base as gpu_tests
COPY ./ /addons
WORKDIR addons
CMD ["bash", "tools/testing/addons_gpu.sh"]

FROM base as interactive_dev
# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser"
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs
# will be updated to match your local UID/GID (when using the dockerFile property).
# See https://aka.ms/vscode-remote/containers/non-root-user for details.
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Set to false to skip installing zsh and Oh My ZSH!
ARG INSTALL_ZSH="false"

# Location and expected SHA for common setup script - SHA generated on release
ARG COMMON_SCRIPT_SOURCE="https://github.com/raw/microsoft/vscode-dev-containers/master/script-library/common-debian.sh"
ARG COMMON_SCRIPT_SHA="dev-mode"

RUN apt-get update \
&& apt-get install -y --no-install-recommends apt-utils dialog wget ca-certificates \
#
# Verify git, common tools / libs installed, add/modify non-root user, optionally install zsh
&& wget -q -O /tmp/common-setup.sh $COMMON_SCRIPT_SOURCE \
&& if [ "$COMMON_SCRIPT_SHA" != "dev-mode" ]; then echo "$COMMON_SCRIPT_SHA /tmp/common-setup.sh" | sha256sum -c - ; fi \
&& /bin/bash /tmp/common-setup.sh "$INSTALL_ZSH" "$USERNAME" "$USER_UID" "$USER_GID" \
&& rm /tmp/common-setup.sh \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*

RUN install -d -m 770 -o vscode -g vscode /home/vscode/.ssh/ && ssh-keyscan -t rsa github.com >> /home/vscode/.ssh/known_hosts

# Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=dialog
2 changes: 1 addition & 1 deletion tools/run_gpu_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ if [ "$DOCKER_BUILDKIT" == "" ]; then
export DOCKER_BUILDKIT=1
fi

docker build -f tools/docker/gpu_tests.Dockerfile -t tfa_gpu_tests ./
docker build -f tools/docker/gpu_tests.Dockerfile --target gpu_tests -t tfa_gpu_tests ./
docker run --rm -t --runtime=nvidia tfa_gpu_tests
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gabrieldemarmiesse Do you want to run this also on interactive_dev? Or do you want to docker run something different there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gabrieldemarmiesse An alternative is to execute bazel build --nobuild -- //tensorflow_addons/... if it is enough for testing interactive_dev.