Skip to content

Commit 6552d57

Browse files
authored
Publish dev container (#1888)
* Add dev container build * Add docker upload on commit push * Modify pre-commit to work in dev container
1 parent 0701713 commit 6552d57

8 files changed

+73
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
set -x -e
4+
5+
df -h
6+
docker info
7+
# to get more disk space
8+
rm -rf /usr/share/dotnet &
9+
10+
tools/build_dev_container.sh

.github/workflows/release.yml

+12-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ jobs:
8282
py-version: ['3.5', '3.6', '3.7', '3.8']
8383
tf-version: ['2.3.0']
8484
fail-fast: false
85+
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'release'
8586
steps:
8687
- uses: actions/download-artifact@v1
8788
with:
@@ -92,7 +93,17 @@ jobs:
9293
ls -la dist/
9394
sha256sum dist/*.whl
9495
- uses: pypa/[email protected]
95-
if: (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'release'
9696
with:
9797
user: __token__
9898
password: ${{ secrets.pypi_token }}
99+
upload-dev-container:
100+
name: Upload dev container to DockerHub
101+
needs: [release-wheel, test-with-bazel]
102+
runs-on: ubuntu-18.04
103+
if: (github.event_name == 'push' && github.ref == 'refs/heads/master')
104+
steps:
105+
- run: |
106+
set -e -x
107+
docker login --username ${{ secrets.DOCKER_USER }} --password ${{ secrets.DOCKER_PW }}
108+
bash bash .github/workflows/github_build_dev_container.sh
109+
docker push tfaddons/dev_container:latest-cpu

CONTRIBUTING.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ to install any additional tools.
274274

275275
CPU Docker:
276276
```bash
277-
docker run --rm -it -v ${PWD}:/addons -w /addons tensorflow/tensorflow:2.1.0-custom-op-ubuntu16
277+
docker run --rm -it -v ${PWD}:/addons -w /addons tfaddons/dev_container:latest-cpu
278278
```
279279

280280
GPU Docker:
@@ -296,6 +296,7 @@ python3 -m pip install -r tools/install_deps/pytest.txt
296296

297297
Compile the custom ops
298298
```bash
299+
export TF_NEED_CUDA=1 # If GPU is to be used
299300
bash tools/install_so_files.sh
300301
```
301302

tools/build_dev_container.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
3+
set -x -e
4+
5+
DOCKER_BUILDKIT=1 docker build \
6+
-f tools/docker/dev_container.Dockerfile \
7+
--build-arg TF_VERSION=2.2.0 \
8+
--build-arg TF_PACKAGE=tensorflow-cpu \
9+
--target dev_container_cpu \
10+
-t tfaddons/dev_container:latest-cpu ./

tools/docker/dev_container.Dockerfile

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#syntax=docker/dockerfile:1.1.5-experimental
2+
FROM tensorflow/tensorflow:2.1.0-custom-op-ubuntu16 as dev_container_cpu
3+
ARG TF_PACKAGE
4+
ARG TF_VERSION
5+
6+
# Temporary until custom-op container is updated
7+
RUN ln -sf /usr/bin/python3 /usr/bin/python
8+
RUN ln -sf /usr/local/bin/pip3 /usr/local/bin/pip
9+
RUN pip install --default-timeout=1000 $TF_PACKAGE==$TF_VERSION
10+
11+
COPY tools/install_deps /install_deps
12+
COPY requirements.txt /tmp/requirements.txt
13+
RUN pip install -r /install_deps/black.txt \
14+
-r /install_deps/flake8.txt \
15+
-r /install_deps/pytest.txt \
16+
-r /install_deps/typedapi.txt \
17+
-r /tmp/requirements.txt
18+
19+
RUN bash /install_deps/buildifier.sh
20+
RUN bash /install_deps/clang-format.sh
21+
22+
ENV ADDONS_DEV_CONTAINER="1"
23+
24+
# Clean up
25+
RUN apt-get autoremove -y \
26+
&& apt-get clean -y \
27+
&& rm -rf /var/lib/apt/lists/*

tools/install_deps/clang-format.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616

1717

1818
wget -O /usr/local/bin/clang-format-9 https://github.com/DoozyX/clang-format-lint-action/raw/master/clang-format/clang-format9
19-
chmod +x /usr/local/bin/clang-format-9
19+
chmod +x /usr/local/bin/clang-format-9
20+
ln -s /usr/local/bin/clang-format-9 /usr/local/bin/clang-format

tools/pre-commit.sh

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#!/usr/bin/env bash
22
# usage: bash tools/pre-commit.sh
3-
# by default uses docker buildkit.
4-
# to disable it:
5-
# DOCKER_BUILDKIT=0 bash tools/pre-commit.sh
63

74

85
set -e
96

10-
export DOCKER_BUILDKIT=1
11-
docker build -t tf_addons_formatting -f tools/docker/pre-commit.Dockerfile .
7+
if [ -z "${ADDONS_DEV_CONTAINER}" ]; then
8+
export DOCKER_BUILDKIT=1
9+
docker build -t tf_addons_formatting -f tools/docker/pre-commit.Dockerfile .
1210

13-
export MSYS_NO_PATHCONV=1
14-
docker run --rm -t -v "$(pwd -P):/addons" tf_addons_formatting
11+
export MSYS_NO_PATHCONV=1
12+
docker run --rm -t -v "$(pwd -P):/addons" tf_addons_formatting
13+
else
14+
python tools/format.py
15+
fi

tools/update_release_version.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ sed -ri "s/(TF_VERSION=|tensorflow(-cpu)*(~|=)=|tf-version: \[')[0-9]+[a-zA-Z0-9
2323
tools/docker/cpu_tests.Dockerfile \
2424
tools/install_deps/tensorflow-cpu.txt \
2525
tools/install_deps/tensorflow.txt \
26-
tools/run_gpu_tests.sh
26+
tools/run_gpu_tests.sh \
27+
tools/build_dev_container.sh

0 commit comments

Comments
 (0)