Skip to content

Commit 2443c5e

Browse files
committed
Add initial vscode devcontainer support
1 parent 25d2142 commit 2443c5e

File tree

3 files changed

+61
-3
lines changed

3 files changed

+61
-3
lines changed

.devcontainer/devcontainer.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "TensorFlow-addons",
3+
"dockerFile": "../tools/docker/gpu_tests.Dockerfile",
4+
"context": "..",
5+
"extensions": [
6+
"ms-python.python",
7+
"ms-vscode.cpptools"
8+
],
9+
10+
// Uncomment to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-in-docker.
11+
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
12+
13+
// To connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
14+
"remoteUser": "vscode",
15+
16+
// Uncomment when using a ptrace-based debugger like C++, Go, and Rust
17+
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ],
18+
19+
// Set *default* container specific settings.json values on container create.
20+
"settings": {
21+
"terminal.integrated.shell.linux": null
22+
},
23+
"build": {
24+
"target": "interactive_dev",
25+
}
26+
}

tools/docker/gpu_tests.Dockerfile

+34-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM tensorflow/tensorflow:2.1.0-custom-op-gpu-ubuntu16
1+
FROM tensorflow/tensorflow:2.1.0-custom-op-gpu-ubuntu16 as base
22

33
COPY tools/install_deps/tensorflow.txt ./
44

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

13-
13+
FROM base as gpu_tests
1414
COPY ./ /addons
1515
WORKDIR addons
1616
CMD ["bash", "tools/testing/addons_gpu.sh"]
17+
18+
FROM base as interactive_dev
19+
# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser"
20+
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs
21+
# will be updated to match your local UID/GID (when using the dockerFile property).
22+
# See https://aka.ms/vscode-remote/containers/non-root-user for details.
23+
ARG USERNAME=vscode
24+
ARG USER_UID=1000
25+
ARG USER_GID=$USER_UID
26+
27+
# Set to false to skip installing zsh and Oh My ZSH!
28+
ARG INSTALL_ZSH="false"
29+
30+
# Location and expected SHA for common setup script - SHA generated on release
31+
ARG COMMON_SCRIPT_SOURCE="https://github.com/raw/microsoft/vscode-dev-containers/master/script-library/common-debian.sh"
32+
ARG COMMON_SCRIPT_SHA="dev-mode"
33+
34+
RUN apt-get update \
35+
&& apt-get install -y --no-install-recommends apt-utils dialog wget ca-certificates \
36+
#
37+
# Verify git, common tools / libs installed, add/modify non-root user, optionally install zsh
38+
&& wget -q -O /tmp/common-setup.sh $COMMON_SCRIPT_SOURCE \
39+
&& if [ "$COMMON_SCRIPT_SHA" != "dev-mode" ]; then echo "$COMMON_SCRIPT_SHA /tmp/common-setup.sh" | sha256sum -c - ; fi \
40+
&& /bin/bash /tmp/common-setup.sh "$INSTALL_ZSH" "$USERNAME" "$USER_UID" "$USER_GID" \
41+
&& rm /tmp/common-setup.sh \
42+
&& apt-get clean -y \
43+
&& rm -rf /var/lib/apt/lists/*
44+
45+
RUN install -d -m 770 -o vscode -g vscode /home/vscode/.ssh/ && ssh-keyscan -t rsa github.com >> /home/vscode/.ssh/known_hosts
46+
47+
# Switch back to dialog for any ad-hoc use of apt-get
48+
ENV DEBIAN_FRONTEND=dialog

tools/run_gpu_tests.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ if [ "$DOCKER_BUILDKIT" == "" ]; then
99
export DOCKER_BUILDKIT=1
1010
fi
1111

12-
docker build -f tools/docker/gpu_tests.Dockerfile -t tfa_gpu_tests ./
12+
docker build -f tools/docker/gpu_tests.Dockerfile --target gpu_tests -t tfa_gpu_tests ./
1313
docker run --rm -t --runtime=nvidia tfa_gpu_tests

0 commit comments

Comments
 (0)