From 6899309730e402fdafe2eb948bbbf2da9277a724 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Mon, 13 Jan 2020 16:17:42 +0000 Subject: [PATCH 1/6] Inital work for raspberrypi arm64 docker container #109 --- docker/development/Dockerfile.arm64 | 121 ++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 docker/development/Dockerfile.arm64 diff --git a/docker/development/Dockerfile.arm64 b/docker/development/Dockerfile.arm64 new file mode 100644 index 000000000..cc6a41b40 --- /dev/null +++ b/docker/development/Dockerfile.arm64 @@ -0,0 +1,121 @@ +FROM ubuntu:18.04 + +LABEL maintainer="Michael Mayer " + +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 \ + "https://dl.photoprism.org/tensorflow/linux/libtensorflow-linux-cpu-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 "512103d7ad296467814a6e3f635631bd35574cab3369a97a323c9a585ccaa569 *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 From faa3035456d3af253fa387090aa167ac73e1b6aa Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Tue, 14 Jan 2020 23:14:11 +0000 Subject: [PATCH 2/6] Add Dockerfile.aarch64 for tensorflow --- docker/tensorflow/Dockerfile.aarch64 | 65 ++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 docker/tensorflow/Dockerfile.aarch64 diff --git a/docker/tensorflow/Dockerfile.aarch64 b/docker/tensorflow/Dockerfile.aarch64 new file mode 100644 index 000000000..97e43c039 --- /dev/null +++ b/docker/tensorflow/Dockerfile.aarch64 @@ -0,0 +1,65 @@ +FROM ubuntu:18.04 + +LABEL maintainer="Michael Mayer " + +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 /docker/tensorflow/*.sh ./ +COPY /docker/tensorflow/*.diff ./ +COPY /docker/tensorflow/.tf_configure.bazelrc .tf_configure.bazelrc +COPY /docker/tensorflow/Makefile Makefile +RUN make patch From 3b18f8e8835270217630d751009497ed7fdb53aa Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Thu, 16 Jan 2020 07:25:07 +0000 Subject: [PATCH 3/6] Add aarch64 docker container to build tensorflow --- docker/tensorflow/Dockerfile.aarch64 | 8 ++++---- docker/tensorflow/Makefile.aarch64 | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 docker/tensorflow/Makefile.aarch64 diff --git a/docker/tensorflow/Dockerfile.aarch64 b/docker/tensorflow/Dockerfile.aarch64 index 97e43c039..fc376fa44 100644 --- a/docker/tensorflow/Dockerfile.aarch64 +++ b/docker/tensorflow/Dockerfile.aarch64 @@ -58,8 +58,8 @@ RUN mv bazel-0.24.1-aarch64 /usr/local/bin/bazel && chmod 755 /usr/local/bin/baz # Configure TensorFlow WORKDIR "/home/tensorflow/tensorflow-1.14.0" -COPY /docker/tensorflow/*.sh ./ -COPY /docker/tensorflow/*.diff ./ -COPY /docker/tensorflow/.tf_configure.bazelrc .tf_configure.bazelrc -COPY /docker/tensorflow/Makefile Makefile +COPY ./*.sh ./ +COPY ./*.diff ./ +COPY ./.tf_configure.bazelrc .tf_configure.bazelrc +COPY ./Makefile.aarch64 Makefile RUN make patch diff --git a/docker/tensorflow/Makefile.aarch64 b/docker/tensorflow/Makefile.aarch64 new file mode 100644 index 000000000..de6a43684 --- /dev/null +++ b/docker/tensorflow/Makefile.aarch64 @@ -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$ + From c536bdd0296842ead16e7eed7dcc50e5beeb0bf8 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Fri, 17 Jan 2020 14:10:23 +0000 Subject: [PATCH 4/6] Add tensorflow build for aarch64 --- docker/tensorflow/Dockerfile.aarch64 | 2 +- docker/tensorflow/build_dynamic.sh | 3 +++ docker/tensorflow/docker-compose-aarch64.yml | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 docker/tensorflow/build_dynamic.sh create mode 100644 docker/tensorflow/docker-compose-aarch64.yml diff --git a/docker/tensorflow/Dockerfile.aarch64 b/docker/tensorflow/Dockerfile.aarch64 index fc376fa44..689014b29 100644 --- a/docker/tensorflow/Dockerfile.aarch64 +++ b/docker/tensorflow/Dockerfile.aarch64 @@ -60,6 +60,6 @@ RUN mv bazel-0.24.1-aarch64 /usr/local/bin/bazel && chmod 755 /usr/local/bin/baz WORKDIR "/home/tensorflow/tensorflow-1.14.0" COPY ./*.sh ./ COPY ./*.diff ./ -COPY ./.tf_configure.bazelrc .tf_configure.bazelrc +COPY ./tf_configure.bazelrc .tf_configure.bazelrc COPY ./Makefile.aarch64 Makefile RUN make patch diff --git a/docker/tensorflow/build_dynamic.sh b/docker/tensorflow/build_dynamic.sh new file mode 100755 index 000000000..2928525f5 --- /dev/null +++ b/docker/tensorflow/build_dynamic.sh @@ -0,0 +1,3 @@ +#!/bin/bash +time bazel build --jobs 2 --config=opt //tensorflow:libtensorflow.so + diff --git a/docker/tensorflow/docker-compose-aarch64.yml b/docker/tensorflow/docker-compose-aarch64.yml new file mode 100644 index 000000000..d62fafc05 --- /dev/null +++ b/docker/tensorflow/docker-compose-aarch64.yml @@ -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 + + From 5ea4b0f5198246c175a5af2f9642bdd6b631d976 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sat, 18 Jan 2020 22:15:54 +0000 Subject: [PATCH 5/6] Add tensorflow, rename --- docker/development/{Dockerfile.arm64 => Dockerfile.aarch64} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename docker/development/{Dockerfile.arm64 => Dockerfile.aarch64} (94%) diff --git a/docker/development/Dockerfile.arm64 b/docker/development/Dockerfile.aarch64 similarity index 94% rename from docker/development/Dockerfile.arm64 rename to docker/development/Dockerfile.aarch64 index cc6a41b40..0be084777 100644 --- a/docker/development/Dockerfile.arm64 +++ b/docker/development/Dockerfile.aarch64 @@ -65,7 +65,7 @@ RUN add-apt-repository ppa:pmjdebruijn/darktable-release && \ ENV LD_LIBRARY_PATH /root/.local/lib:/usr/local/lib:/usr/lib:/lib ENV TF_CPP_MIN_LOG_LEVEL 0 RUN curl -L \ - "https://dl.photoprism.org/tensorflow/linux/libtensorflow-linux-cpu-1.14.0.tar.gz" | \ + "http://unofficialpi.org/photoprisim/libtensorflow-aarch64-1.14.0.tar.gz" | \ tar -C "/usr" -xz RUN ldconfig @@ -87,7 +87,7 @@ RUN set -eux; \ \ url="https://golang.org/dl/go${GOLANG_VERSION}.linux-arm64.tar.gz"; \ wget -O go.tgz "$url"; \ - echo "512103d7ad296467814a6e3f635631bd35574cab3369a97a323c9a585ccaa569 *go.tgz" | sha256sum -c -; \ + echo "0a18125c4ed80f9c3045cf92384670907c4796b43ed63c4307210fe93e5bbca5 *go.tgz" | sha256sum -c -; \ tar -C /usr/local -xzf go.tgz; \ rm go.tgz; \ export PATH="/usr/local/go/bin:$PATH"; \ From 4ea53a9ec84704a2efa11c260b31e45c0179eac6 Mon Sep 17 00:00:00 2001 From: Guy Sheffer Date: Sun, 19 Jan 2020 15:30:22 +0000 Subject: [PATCH 6/6] Add docker compose for raspberrypi running on 64bit kernel --- docker/photoprism/docker-compose-aarch64.yml | 44 ++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 docker/photoprism/docker-compose-aarch64.yml diff --git a/docker/photoprism/docker-compose-aarch64.yml b/docker/photoprism/docker-compose-aarch64.yml new file mode 100644 index 000000000..f6b2fb2af --- /dev/null +++ b/docker/photoprism/docker-compose-aarch64.yml @@ -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