Skip to content

Commit

Permalink
enh: images published on Docker Hub are now tagged with release versions
Browse files Browse the repository at this point in the history
  • Loading branch information
helmut-hoffer-von-ankershoffen committed Sep 10, 2019
1 parent 2aced5f commit 9575c6d
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 37 deletions.
32 changes: 16 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ ml-base-build-and-test: ## Build, push and test ml base image for Docker on Jets
workflow/deploy/tools/container-structure-test ml-base

ml-base-publish: ## Publish latest ml base image on Jetson device to Docker Hub given credentials in .docker-hub.auth
workflow/deploy/tools/publish ml-base $(shell sed '1q;d' .docker-hub.auth) $(shell sed '2q;d' .docker-hub.auth)
workflow/deploy/tools/publish ml-base $(shell sed '1q;d' .docker-hub.auth) $(shell sed '2q;d' .docker-hub.auth) $(filter-out $@,$(MAKECMDGOALS))


device-query-build-and-test: ## Build and test device-query
Expand Down Expand Up @@ -258,7 +258,7 @@ device-query-dev-docker-hub-parent: ## Enter build, deploy, tail, watch cycle fo
cd workflow/deploy/device-query && skaffold dev -p docker-hub-parent

device-query-publish: ## Publish latest device query image on Jetson device to Docker Hub given credentials in .docker-hub.auth
workflow/deploy/tools/publish device-query $(shell sed '1q;d' .docker-hub.auth) $(shell sed '2q;d' .docker-hub.auth)
workflow/deploy/tools/publish device-query $(shell sed '1q;d' .docker-hub.auth) $(shell sed '2q;d' .docker-hub.auth) $(filter-out $@,$(MAKECMDGOALS))

device-query-delete: ## Delete device query deployment
cd workflow/deploy/device-query && skaffold delete
Expand Down Expand Up @@ -298,7 +298,7 @@ jupyter-dev-docker-hub-parent: ## Enter build, deploy, tail, watch cycle for jup
cd workflow/deploy/jupyter && skaffold dev -p docker-hub-parent

jupyter-publish: ## Publish latest jupyter image on Jetson device to Docker Hub given credentials in .docker-hub.auth
workflow/deploy/tools/publish jupyter $(shell sed '1q;d' .docker-hub.auth) $(shell sed '2q;d' .docker-hub.auth)
workflow/deploy/tools/publish jupyter $(shell sed '1q;d' .docker-hub.auth) $(shell sed '2q;d' .docker-hub.auth) $(filter-out $@,$(MAKECMDGOALS))

jupyter-delete: ## Delete jupyter deployment
cd workflow/deploy/jupyter && skaffold delete
Expand All @@ -311,7 +311,7 @@ tensorflow-serving-base-build-and-test: ## Build, push and test ml tensorflow-se
workflow/deploy/tools/container-structure-test tensorflow-serving-base

tensorflow-serving-base-publish: ## Publish latest tensorflow-serving base image on Jetson device to Docker Hub given credentials in .docker-hub.auth
workflow/deploy/tools/publish tensorflow-serving-base $(shell sed '1q;d' .docker-hub.auth) $(shell sed '2q;d' .docker-hub.auth)
workflow/deploy/tools/publish tensorflow-serving-base $(shell sed '1q;d' .docker-hub.auth) $(shell sed '2q;d' .docker-hub.auth) $(filter-out $@,$(MAKECMDGOALS))



Expand Down Expand Up @@ -368,7 +368,7 @@ tensorflow-serving-dev-docker-hub-parent: ## Enter build, deploy, tail, watch cy
cd workflow/deploy/jupyter && skaffold dev -p docker-hub-parent

tensorflow-serving-publish: ## Publish latest tensorflow-serving image on Jetson device to Docker Hub given credentials in .docker-hub.auth
workflow/deploy/tools/publish tensorflow-serving $(shell sed '1q;d' .docker-hub.auth) $(shell sed '2q;d' .docker-hub.auth)
workflow/deploy/tools/publish tensorflow-serving $(shell sed '1q;d' .docker-hub.auth) $(shell sed '2q;d' .docker-hub.auth) $(filter-out $@,$(MAKECMDGOALS))

tensorflow-serving-delete: ## Delete tensorflow-serving deployment
cd workflow/deploy/tensorflow-serving && skaffold delete
Expand All @@ -394,20 +394,20 @@ l4t-dev: ## Enter cross-build, deploy, tail, watch cycle for l4t
cd workflow/deploy/l4t && skaffold dev

l4t-publish: ## Publish latest lt4 image on Jetson device to Docker Hub given credentials in .docker-hub.auth
workflow/deploy/tools/publish l4t $(shell sed '1q;d' .docker-hub.auth) $(shell sed '2q;d' .docker-hub.auth)
workflow/deploy/tools/publish l4t $(shell sed '1q;d' .docker-hub.auth) $(shell sed '2q;d' .docker-hub.auth) $(filter-out $@,$(MAKECMDGOALS))

l4t-delete: ## Delete l4t deployment
cd workflow/deploy/l4t && skaffold delete
kubectl delete namespace jetson-l4t || true

publish-all: ## Publish all images to DockerHub
make ml-base-publish
make device-query-publish
make jupyter-publish
make tensorflow-serving-base-publish
make tensorflow-serving-publish
JETSON_MODEL=xavier make ml-base-publish
JETSON_MODEL=xavier make device-query-publish
JETSON_MODEL=xavier make jupyter-publish
JETSON_MODEL=xavier make tensorflow-serving-base-publish
JETSON_MODEL=xavier make tensorflow-serving-publish
JETSON_MODEL=nano make ml-base-publish $(filter-out $@,$(MAKECMDGOALS))
JETSON_MODEL=nano make device-query-publish $(filter-out $@,$(MAKECMDGOALS))
JETSON_MODEL=nano make jupyter-publish $(filter-out $@,$(MAKECMDGOALS))
JETSON_MODEL=nano make tensorflow-serving-base-publish $(filter-out $@,$(MAKECMDGOALS))
JETSON_MODEL=nano make tensorflow-serving-publish $(filter-out $@,$(MAKECMDGOALS))
JETSON_MODEL=xavier make ml-base-publish $(filter-out $@,$(MAKECMDGOALS))
JETSON_MODEL=xavier make device-query-publish $(filter-out $@,$(MAKECMDGOALS))
JETSON_MODEL=xavier make jupyter-publish $(filter-out $@,$(MAKECMDGOALS))
JETSON_MODEL=xavier make tensorflow-serving-base-publish $(filter-out $@,$(MAKECMDGOALS))
JETSON_MODEL=xavier make tensorflow-serving-publish $(filter-out $@,$(MAKECMDGOALS))
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Hints:
- [x] optional: Semi-automatically setup USB 3.0 / **SSD boot drive** given existing installation on micro SD card on Jetson Nanos
- [ ] optional: Automatically **[cross-build](https://engineering.docker.com/2019/04/multi-arch-images/) arm64 Docker images on macOS** for Jetson devices using [**buildkit**](https://github.com/moby/buildkit) and [**buildx**](https://github.com/docker/buildx)
- [ ] optional: Automatically setup **firewall** on host using [`ufw`](https://wiki.ubuntu.com/UncomplicatedFirewall) for basic security
- [x] community: Publish images on [**Docker Hub**](https://hub.docker.com/u/helmuthva) and provide Skaffold profiles to pull from there instead of having to build before deploy
- [x] community: Publish versioned images on [**Docker Hub**](https://hub.docker.com/u/helmuthva) per release and provide Skaffold profiles to pull from Docker Hub instead of having to build images before deploy in Kubernetes cluster
- [ ] community: Author a series of **blog** posts explaining how to set up ML in Kubernetes on Jetson devices based on this starter
- [ ] ml: Deploy **Polarize.AI** ml training and inference tiers on Jetson nodes (separate project)

Expand Down
1 change: 0 additions & 1 deletion workflow/deploy/device-query/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apiVersion: skaffold/v1beta11
kind: Config
build:
local: {}
tagPolicy:
sha256: {}
artifacts:
Expand Down
6 changes: 6 additions & 0 deletions workflow/deploy/device-query/src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ FROM ${FROM}

MAINTAINER Helmut Hoffer von Ankershoffen <[email protected]>

# Inc on updates of base image
ENV BUMP=1

# Build and install device query
RUN cd /usr/local/cuda/samples/1_Utilities/deviceQuery && \
make clean && \
Expand All @@ -12,3 +15,6 @@ RUN cd /usr/local/cuda/samples/1_Utilities/deviceQuery && \

# Execute deviceQuery to validate cuda and driver access on boot than sleep
CMD exec /bin/bash -c "trap : TERM INT; /app/deviceQuery; echo \"Sleeping until terminated so you can see the log - press ctrl+c...\"; sleep infinity & wait"

RUN mkdir -p /meta && \
date +"%FT%T%Z" > /meta/device-query.build
1 change: 0 additions & 1 deletion workflow/deploy/jupyter/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apiVersion: skaffold/v1beta11
kind: Config
build:
local: {}
tagPolicy:
sha256: {}
artifacts:
Expand Down
6 changes: 6 additions & 0 deletions workflow/deploy/jupyter/src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ FROM ${FROM}

MAINTAINER Helmut Hoffer von Ankershoffen <[email protected]>

# Inc on updates of base image
ENV BUMP=1

# Install Jupyter
RUN conda install -y jupyter && \
conda install -y ipywidgets
Expand Down Expand Up @@ -30,3 +33,6 @@ CMD ["jupyter", "notebook", "--allow-root", "--no-browser" ]
# Expose jupyter and tensorboard
EXPOSE 8888
EXPOSE 6006

RUN mkdir -p /meta && \
date +"%FT%T%Z" > /meta/jupyter.build
1 change: 0 additions & 1 deletion workflow/deploy/ml-base/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apiVersion: skaffold/v1beta11
kind: Config
build:
local: {}
tagPolicy:
sha256: {}
artifacts:
Expand Down
7 changes: 6 additions & 1 deletion workflow/deploy/ml-base/src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ MAINTAINER Helmut Hoffer von Ankershoffen <[email protected]>
# Set non interactive frontend during build
ENV DEBIAN_FRONTEND=noninteractive

# Simulate runlevel 1 needed on installing some packagess
ENV RUNLEVEL=1

# Set locale and lang
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
Expand All @@ -22,7 +25,6 @@ ENV LD_LIBRARY_PATH="/usr/local/cuda-10.0/lib64:${LD_LIBRARY_PATH}"
ENV LD_LIBRARY_PATH="/usr/local/lib/:${LD_LIBRARY_PATH}"
ENV LD_LIBRARY_PATH="/opt/archiconda3/lib:${LD_LIBRARY_PATH}"

#
ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn

# Setup capabilties for cuda
Expand Down Expand Up @@ -157,3 +159,6 @@ RUN pip install --no-cache-dir https://developer.download.nvidia.com/compute/red

# Remove repository reference so child images do not have to bind-mount again
RUN rm /etc/apt/sources.list.d/cuda.list

RUN mkdir -p /meta && \
date +"%FT%T%Z" > /meta/ml-base.build
1 change: 0 additions & 1 deletion workflow/deploy/tensorflow-serving-base/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apiVersion: skaffold/v1beta11
kind: Config
build:
local: {}
tagPolicy:
sha256: {}
artifacts:
Expand Down
11 changes: 9 additions & 2 deletions workflow/deploy/tensorflow-serving-base/src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
ARG FROM=max-one.local:5001/jetson/nano/ml-base
FROM ${FROM}

MAINTAINER Helmut Hoffer von Ankershoffen <[email protected]>

# Inc on updates of base image
ENV BUMP=1

# Number of parallel jobs when building TensorFlow serving
ARG JOBS=1

# CUDA capabilities of Jetson (Nano, TX1, TX2 and Xavier)
ARG TF_CUDA_COMPUTE_CAPABILITIES
ENV TF_CUDA_COMPUTE_CAPABILITIES ${TF_CUDA_COMPUTE_CAPABILITIES:-5.3,6.2,7.2}

# JETSON_MODEL used in .bazelrc
ARG JETSON_MODEL
ENV JETSON_MODEL ${JETSON_MODEL:-nano}

MAINTAINER Helmut Hoffer von Ankershoffen <[email protected]>

# Install supervisord
RUN apt-get update && \
apt-get install -y supervisor && \
Expand Down Expand Up @@ -105,4 +109,7 @@ EXPOSE 8500
# rest
EXPOSE 8501

RUN mkdir -p /meta && \
date +"%FT%T%Z" > /meta/tensorflow-serving-base.build

CMD ["/usr/bin/supervisord"]
1 change: 0 additions & 1 deletion workflow/deploy/tensorflow-serving/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
apiVersion: skaffold/v1beta11
kind: Config
build:
local: {}
tagPolicy:
sha256: {}
artifacts:
Expand Down
7 changes: 7 additions & 0 deletions workflow/deploy/tensorflow-serving/src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ FROM ${FROM}

MAINTAINER Helmut Hoffer von Ankershoffen <[email protected]>

# Inc on updates of base image
ENV BUMP=1

# Install application server
RUN pip install \
fastapi \
Expand All @@ -22,6 +25,7 @@ COPY /models/testdata/saved_model_half_plus_two_mkl /models/half_plus_two
# Install testdata
COPY /models/testdata /testdata

# Workdir is root
WORKDIR /

# Expose ports
Expand All @@ -31,3 +35,6 @@ EXPOSE 80
EXPOSE 8500
# rest
EXPOSE 8501

RUN mkdir -p /meta && \
date +"%FT%T%Z" > /meta/tensorflow-serving.build
11 changes: 6 additions & 5 deletions workflow/deploy/tools/builder
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# Regular builder
# Regular remote builder

## Project to build
project=$1
Expand All @@ -20,16 +20,15 @@ shift; shift; shift
options="$@"

cd $(dirname "$0")/../$project
echo "Building $IMAGES for project $project and Jetson model ${model} with FROM=from and $options ..."
echo "Building $IMAGES for project $project and Jetson model $model with FROM=$from and $options ..."

## Sync src from development machine to device
echo "Synching from development machine to ${model} for project $project ..."
echo "Synching from development machine to build@${model}-one.local for project $project ..."
rsync -rlptza --delete -P src/ build@${model}-one.local:~/$project

## Build Docker image on device
ssh build@${model}-one.local << EOF
echo "Building Docker image on ${model} for project $project ..."
if [ -z "$2" ]; then
if [ -z "$from" ]; then
echo "Executing on build@${model}-one.local: docker build -t $project ~/$project $options"
docker build -t $project ~/$project $options
else
Expand All @@ -47,6 +46,8 @@ do
echo "Pushing $image for project $project..."
ssh build@${model}-one.local "docker push $image"
fi
# echo "Pulling $image on host ..."
# docker pull $image
done

echo "Building $IMAGES for project $project done."
8 changes: 5 additions & 3 deletions workflow/deploy/tools/builderx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# Builder using buildx for bind-mounting during build
# Remote builder using buildx for bind-mounting during build
## Project to build
project=$1

Expand All @@ -15,10 +15,10 @@ shift; shift
options="$@"

cd $(dirname "$0")/../$project
echo "Building $IMAGES for project $project and Jetson model ${model} ..."
echo "Building $IMAGES for project $project and Jetson model $model ..."

## Sync src from development machine to device
echo "Synching from development machine to ${model} for project $project ..."
echo "Synching from development machine to build@${model}-one.local for project $project ..."
rsync -rlptza --delete --exclude=host -P src/ build@${model}-one.local:~/$project

## Sync directories on host into Docker build context for later bind-mounting during build
Expand Down Expand Up @@ -72,4 +72,6 @@ do
echo "Pushing $image for project $project..."
ssh build@${model}-one.local "docker push $image"
fi
# echo "Pulling $image on host ..."
# docker pull $image
done
20 changes: 16 additions & 4 deletions workflow/deploy/tools/publish
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@

## Project to build
project=$1

# Login at DockerHub
user=$2
password=$3
cd $(dirname "$0")/../$project

## Jetson model
# Jetson model
if [[ -z "${JETSON_MODEL}" ]]; then
JETSON_MODEL="nano"
model="nano"
else
model=${JETSON_MODEL}
fi
model=${4:-${JETSON_MODEL}}

# Optional tag
tag=$4

cd $(dirname "$0")/../$project

# Publish
echo "Publish latest Docker image available found on ${model} to Docker Hub"
Expand All @@ -20,4 +27,9 @@ ssh build@${model}-one.local << EOF
echo "Publishing latest image of project $project to Docker Hub as $user/jetson-$model-$project:latest ..."
docker tag $project $user/jetson-$model-$project:latest
docker push $user/jetson-$model-$project:latest
if [[ ! -z "${tag}" ]]; then
echo "Additionally publish with as $user/jetson-$model-$project:$tag ..."
docker tag $project $user/jetson-$model-$project:$tag
docker push $user/jetson-$model-$project:$tag
fi
EOF

0 comments on commit 9575c6d

Please sign in to comment.