Add 64bit Docker image for Raspberry Pi #109 (PR #207)

* Inital work for raspberrypi arm64 docker container #109

* Add aarch64 docker container to build tensorflow

* Add tensorflow for aarch64

* Add docker compose for raspberrypi running on 64bit kernel
This commit is contained in:
Guy Sheffer 2020-01-19 22:30:44 +02:00 committed by Michael Mayer
parent ab369eb75e
commit 6e5be73f9c
6 changed files with 268 additions and 0 deletions

View file

@ -0,0 +1,121 @@
FROM ubuntu:18.04
LABEL maintainer="Michael Mayer <michael@liquidbytes.net>"
ARG BUILD_TAG
ENV DEBIAN_FRONTEND noninteractive
# Configure apt-get
RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry
RUN echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/80recommends
RUN echo 'APT::Install-Suggests "false";' > /etc/apt/apt.conf.d/80suggests
RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/80forceyes
RUN echo 'APT::Get::Fix-Missing "true";' > /etc/apt/apt.conf.d/80fixmissin
# Install dev / build dependencies
RUN apt-get update && apt-get upgrade && \
apt-get install \
build-essential \
curl \
chrpath \
libssl-dev \
libxft-dev \
libfreetype6 \
libfreetype6-dev \
libfontconfig1 \
libfontconfig1-dev \
libhdf5-serial-dev \
libpng-dev \
libzmq3-dev \
pkg-config \
software-properties-common \
rsync \
unzip \
zip \
g++ \
gcc \
libc6-dev \
gpg-agent \
apt-utils \
make \
nano \
wget \
git \
mysql-client \
tzdata \
gconf-service \
chromium-browser \
firefox \
libheif-examples \
exiftool
# Install RAW to JPEG converter
RUN add-apt-repository ppa:pmjdebruijn/darktable-release && \
apt-get update && \
apt-get install darktable && \
apt-get upgrade && \
apt-get dist-upgrade
# Install & configure TensorFlow for C
#
# Please use other build if processor does not support AVX2:
# https://dl.photoprism.org/tensorflow/linux/
#
ENV LD_LIBRARY_PATH /root/.local/lib:/usr/local/lib:/usr/lib:/lib
ENV TF_CPP_MIN_LOG_LEVEL 0
RUN curl -L \
"http://unofficialpi.org/photoprisim/libtensorflow-aarch64-1.14.0.tar.gz" | \
tar -C "/usr" -xz
RUN ldconfig
# Install NodeJS
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get update && \
apt-get install nodejs && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install and configure NodeJS Package Manager (npm)
ENV NODE_ENV production
RUN npm install --unsafe-perm=true --allow-root -g npm testcafe chromedriver
RUN npm config set cache ~/.cache/npm
# Install Go
ENV GOLANG_VERSION 1.13.6
RUN set -eux; \
\
url="https://golang.org/dl/go${GOLANG_VERSION}.linux-arm64.tar.gz"; \
wget -O go.tgz "$url"; \
echo "0a18125c4ed80f9c3045cf92384670907c4796b43ed63c4307210fe93e5bbca5 *go.tgz" | sha256sum -c -; \
tar -C /usr/local -xzf go.tgz; \
rm go.tgz; \
export PATH="/usr/local/go/bin:$PATH"; \
go version
# Configure Go environment
ENV GOPATH /go
ENV GOBIN $GOPATH/bin
ENV PATH $GOBIN:/usr/local/go/bin:/root/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV GO111MODULE on
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
# Download TensorFlow model and test files
RUN rm -rf /tmp/* && mkdir -p /tmp/photoprism
RUN wget "https://dl.photoprism.org/tensorflow/nsfw.zip?${BUILD_TAG}" -O /tmp/photoprism/nsfw.zip
RUN wget "https://dl.photoprism.org/tensorflow/nasnet.zip?${BUILD_TAG}" -O /tmp/photoprism/nasnet.zip
RUN wget "https://dl.photoprism.org/fixtures/testdata.zip?${BUILD_TAG}" -O /tmp/photoprism/testdata.zip
# Install goimports and richgo (colorizes "go test" output)
RUN env GO111MODULE=off /usr/local/go/bin/go get -u golang.org/x/tools/cmd/goimports
RUN env GO111MODULE=off /usr/local/go/bin/go get -u github.com/kyoh86/richgo
RUN echo "alias go=richgo" > /root/.bash_aliases
# Set up project directory
WORKDIR "/go/src/github.com/photoprism/photoprism"
# Expose HTTP port 2342 plus 4000 for TiDB and 9515 for chromedriver
EXPOSE 2342 4000 9515
# Keep container running (services can be started manually using a terminal)
CMD tail -f /dev/null

View file

@ -0,0 +1,44 @@
version: '3.3'
# Example docker-compose config file for production use
# Container image on Docker Hub: https://hub.docker.com/r/photoprism/photoprism/
# To keep photoprism running, add "restart: always"
#
# Usage: docker-compose up
services:
photoprism:
security_opt:
- seccomp:unconfined
image: guysoft/photoprisimpi:latest
ports:
- 2342:2342 # [local port]:[container port]
environment: # Run "photoprism help" and "photoprism config" too see all config options and current values
PHOTOPRISM_URL: "https://demo.photoprism.org/"
PHOTOPRISM_TITLE: "PhotoPrism"
PHOTOPRISM_SUBTITLE: "Browse your life"
PHOTOPRISM_DESCRIPTION: "Personal Photo Management powered by Go and Google TensorFlow. Free and open-source."
PHOTOPRISM_AUTHOR: "Anonymous"
PHOTOPRISM_TWITTER: "@browseyourlife"
PHOTOPRISM_IMPORT_PATH: "/home/photoprism/Pictures/Import"
PHOTOPRISM_EXPORT_PATH: "/home/photoprism/Pictures/Export"
PHOTOPRISM_ORIGINALS_PATH: "/home/photoprism/Pictures/Originals"
PHOTOPRISM_UPLOAD_NSFW: "true"
PHOTOPRISM_HIDE_NSFW: "false"
PHOTOPRISM_EXPERIMENTAL: "false"
PHOTOPRISM_DEBUG: "false"
PHOTOPRISM_READONLY: "false"
PHOTOPRISM_PUBLIC: "false"
PHOTOPRISM_ADMIN_PASSWORD: "photoprism"
volumes:
- "~/Pictures/Originals:/home/photoprism/Pictures/Originals" # [local path]:[container path]
- "~/Pictures/Import:/home/photoprism/Pictures/Import" # [local path]:[container path] (optional)
- "~/Pictures/Export:/home/photoprism/Pictures/Export" # [local path]:[container path] (optional)
- "photoprism-cache:/home/photoprism/.cache/photoprism" # keep thumbnail cache
- "photoprism-database:/home/photoprism/.local/share/photoprism/resources/database" # keep database files
volumes: # keep this
photoprism-cache:
driver: local
photoprism-database:
driver: local

View file

@ -0,0 +1,65 @@
FROM ubuntu:18.04
LABEL maintainer="Michael Mayer <michael@liquidbytes.net>"
ENV DEBIAN_FRONTEND noninteractive
ENV TMP /tmp
ENV EXTRA_BAZEL_ARGS "--host_javabase=@local_jdk//:jdk"
# Configure apt-get
RUN echo 'Acquire::Retries "10";' > /etc/apt/apt.conf.d/80retry
RUN echo 'APT::Install-Recommends "false";' > /etc/apt/apt.conf.d/80recommends
RUN echo 'APT::Install-Suggests "false";' > /etc/apt/apt.conf.d/80suggests
RUN echo 'APT::Get::Assume-Yes "true";' > /etc/apt/apt.conf.d/80forceyes
RUN echo 'APT::Get::Fix-Missing "true";' > /etc/apt/apt.conf.d/80fixmissin
# Install dev / build dependencies
RUN apt-get update && apt-get upgrade && \
apt-get install \
ca-certificates \
build-essential \
autoconf \
automake \
libtool \
g++-4.8 \
gcc-4.8 \
libc6-dev \
zlib1g-dev \
libssl-dev \
curl \
chrpath \
pkg-config \
unzip \
zip \
make \
nano \
wget \
git \
libtool \
python3 \
python3-git \
openjdk-8-jdk
# Use GCC 4.8 and Python 3 as default
# See https://www.tensorflow.org/install/source#tested_build_configurations
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 10 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 10 && \
update-alternatives --install /usr/bin/python python /usr/bin/python3.6 10
# Download Bazel & TensorFlow
WORKDIR "/home/tensorflow"
RUN wget https://github.com/tensorflow/tensorflow/archive/v1.14.0.tar.gz
RUN tar -xzf v1.14.0.tar.gz
# Install Bazel
# RUN wget https://github.com/bazelbuild/bazel/releases/download/0.24.1/bazel-0.24.1-linux-x86_64
RUN wget https://github.com/guysoft/bazel-bin/raw/master/bazel-0.24.1-aarch64
RUN mv bazel-0.24.1-aarch64 /usr/local/bin/bazel && chmod 755 /usr/local/bin/bazel
# Configure TensorFlow
WORKDIR "/home/tensorflow/tensorflow-1.14.0"
COPY ./*.sh ./
COPY ./*.diff ./
COPY ./tf_configure.bazelrc .tf_configure.bazelrc
COPY ./Makefile.aarch64 Makefile
RUN make patch

View file

@ -0,0 +1,21 @@
TF_VERSION=1.14.0
all: libtensorflow static archive
patch:
git apply tensorflow-$(TF_VERSION).diff
libtensorflow:
bazel build --jobs 2 --config=opt //tensorflow:libtensorflow.so
static:
env JOB_COUNT=2 ARCH=armv8-a ./build_static.sh
archive:
rm -rf tmp
mkdir -p tmp/lib/
mkdir -p tmp/include/tensorflow/c/eager/
cp bazel-bin/tensorflow/libtensorflow.so.$(TF_VERSION) tmp/lib/libtensorflow.so
cp bazel-bin/tensorflow/libtensorflow_framework.so.$(TF_VERSION) tmp/lib/libtensorflow_framework.so
cp tensorflow/c/eager/c_api.h tmp/include/tensorflow/c/eager/
cp tensorflow/c/c_api.h tensorflow/c/c_api_experimental.h LICENSE tmp/include/tensorflow/c/
#(cd tmp && tar -czf ../libtensorflow-nvidia-jetson-nano-$(TF_VERSION).tar.gz .)
#du -h libtensorflow-nvidia-jetson-nano-$(TF_VERSION).tar.gz
guy@golem4:/tmp/photoprism/docker/tensorflow$

View file

@ -0,0 +1,3 @@
#!/bin/bash
time bazel build --jobs 2 --config=opt //tensorflow:libtensorflow.so

View file

@ -0,0 +1,14 @@
version: '3.6'
services:
build:
build:
context: .
dockerfile: Dockerfile.aarch64
container_name: tensorflow-build
tty: true
restart: always
volumes:
- ./out:/output