82 lines
2.9 KiB
Text
82 lines
2.9 KiB
Text
|
FROM tensorflow/tensorflow
|
||
|
|
||
|
# Install TensorFlow C library
|
||
|
RUN curl -L \
|
||
|
"https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.3.0.tar.gz" | \
|
||
|
tar -C "/usr/local" -xz
|
||
|
RUN ldconfig
|
||
|
# Hide some warnings
|
||
|
ENV TF_CPP_MIN_LOG_LEVEL 2
|
||
|
|
||
|
# Install Go (https://github.com/docker-library/golang/blob/221ee92559f2963c1fe55646d3516f5b8f4c91a4/1.9/stretch/Dockerfile)
|
||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||
|
g++ \
|
||
|
gcc \
|
||
|
libc6-dev \
|
||
|
make \
|
||
|
pkg-config \
|
||
|
wget \
|
||
|
git \
|
||
|
&& rm -rf /var/lib/apt/lists/*
|
||
|
|
||
|
ENV GOLANG_VERSION 1.9.1
|
||
|
RUN set -eux; \
|
||
|
\
|
||
|
dpkgArch="$(dpkg --print-architecture)"; \
|
||
|
case "${dpkgArch##*-}" in \
|
||
|
amd64) goRelArch='linux-amd64'; goRelSha256='07d81c6b6b4c2dcf1b5ef7c27aaebd3691cdb40548500941f92b221147c5d9c7' ;; \
|
||
|
armhf) goRelArch='linux-armv6l'; goRelSha256='65a0495a50c7c240a6487b1170939586332f6c8f3526abdbb9140935b3cff14c' ;; \
|
||
|
arm64) goRelArch='linux-arm64'; goRelSha256='d31ecae36efea5197af271ccce86ccc2baf10d2e04f20d0fb75556ecf0614dad' ;; \
|
||
|
i386) goRelArch='linux-386'; goRelSha256='2cea1ce9325cb40839601b566bc02b11c92b2942c21110b1b254c7e72e5581e7' ;; \
|
||
|
ppc64el) goRelArch='linux-ppc64le'; goRelSha256='de57b6439ce9d4dd8b528599317a35fa1e09d6aa93b0a80e3945018658d963b8' ;; \
|
||
|
s390x) goRelArch='linux-s390x'; goRelSha256='9adf03574549db82a72e0d721ef2178ec5e51d1ce4f309b271a2bca4dcf206f6' ;; \
|
||
|
*) goRelArch='src'; goRelSha256='a84afc9dc7d64fe0fa84d4d735e2ece23831a22117b50dafc75c1484f1cb550e'; \
|
||
|
echo >&2; echo >&2 "warning: current architecture ($dpkgArch) does not have a corresponding Go binary release; will be building from source"; echo >&2 ;; \
|
||
|
esac; \
|
||
|
\
|
||
|
url="https://golang.org/dl/go${GOLANG_VERSION}.${goRelArch}.tar.gz"; \
|
||
|
wget -O go.tgz "$url"; \
|
||
|
echo "${goRelSha256} *go.tgz" | sha256sum -c -; \
|
||
|
tar -C /usr/local -xzf go.tgz; \
|
||
|
rm go.tgz; \
|
||
|
\
|
||
|
if [ "$goRelArch" = 'src' ]; then \
|
||
|
echo >&2; \
|
||
|
echo >&2 'error: UNIMPLEMENTED'; \
|
||
|
echo >&2 'TODO install golang-any from jessie-backports for GOROOT_BOOTSTRAP (and uninstall after build)'; \
|
||
|
echo >&2; \
|
||
|
exit 1; \
|
||
|
fi; \
|
||
|
\
|
||
|
export PATH="/usr/local/go/bin:$PATH"; \
|
||
|
go version
|
||
|
|
||
|
ENV GOPATH /go
|
||
|
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
|
||
|
|
||
|
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
|
||
|
|
||
|
# Install dependencies
|
||
|
RUN go get github.com/tensorflow/tensorflow/tensorflow/go \
|
||
|
github.com/tensorflow/tensorflow/tensorflow/go/op \
|
||
|
github.com/julienschmidt/httprouter
|
||
|
|
||
|
# Download InceptionV3 model
|
||
|
RUN mkdir -p /model && \
|
||
|
wget "https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip" -O /model/inception.zip && \
|
||
|
unzip /model/inception.zip -d /model && \
|
||
|
chmod -R 777 /model
|
||
|
|
||
|
# Create user
|
||
|
RUN adduser --disabled-password --gecos '' api
|
||
|
USER api
|
||
|
|
||
|
# Set up project directory
|
||
|
WORKDIR "/go/src/tensorflowapi"
|
||
|
COPY . .
|
||
|
|
||
|
# Install the app
|
||
|
RUN go install -v ./...
|
||
|
|
||
|
# Run the app
|
||
|
CMD [ "tensorflowapi" ]
|