Improved Docker configuration
This commit is contained in:
parent
62f101e366
commit
1517afc1fd
9 changed files with 103 additions and 66 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -5,7 +5,7 @@
|
||||||
*.dylib
|
*.dylib
|
||||||
/*.zip
|
/*.zip
|
||||||
/photoprism
|
/photoprism
|
||||||
|
vendor/
|
||||||
# Test binary, build with `go test -c`
|
# Test binary, build with `go test -c`
|
||||||
*.test
|
*.test
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ services:
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- docker-compose -f docker-compose.travis.yml up --build -d
|
- docker-compose -f docker-compose.travis.yml up --build -d
|
||||||
- sleep 15
|
|
||||||
- docker-compose exec photoprism /usr/local/go/bin/go run cmd/photoprism/photoprism.go migrate-db
|
- docker-compose exec photoprism /usr/local/go/bin/go run cmd/photoprism/photoprism.go migrate-db
|
||||||
|
|
||||||
script:
|
script:
|
||||||
|
|
135
Dockerfile
135
Dockerfile
|
@ -1,32 +1,81 @@
|
||||||
FROM tensorflow/tensorflow
|
FROM ubuntu:18.04
|
||||||
|
|
||||||
|
LABEL maintainer="Michael Mayer <michael@liquidbytes.net>"
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
build-essential \
|
||||||
|
curl \
|
||||||
|
libfreetype6-dev \
|
||||||
|
libhdf5-serial-dev \
|
||||||
|
libpng-dev \
|
||||||
|
libzmq3-dev \
|
||||||
|
pkg-config \
|
||||||
|
python \
|
||||||
|
python-dev \
|
||||||
|
rsync \
|
||||||
|
software-properties-common \
|
||||||
|
unzip \
|
||||||
|
g++ \
|
||||||
|
gcc \
|
||||||
|
libc6-dev \
|
||||||
|
gpg-agent \
|
||||||
|
apt-utils \
|
||||||
|
make \
|
||||||
|
nano \
|
||||||
|
wget \
|
||||||
|
darktable \
|
||||||
|
git \
|
||||||
|
python3 \
|
||||||
|
python-setuptools \
|
||||||
|
python3-dev \
|
||||||
|
mysql-client \
|
||||||
|
&& \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN add-apt-repository ppa:pmjdebruijn/darktable-release
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
darktable \
|
||||||
|
&& \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN apt-get upgrade -y
|
||||||
|
|
||||||
|
RUN curl -O https://bootstrap.pypa.io/get-pip.py && \
|
||||||
|
python get-pip.py && \
|
||||||
|
rm get-pip.py
|
||||||
|
|
||||||
|
# Install TensorFlow CPU version from central repo
|
||||||
|
RUN pip --no-cache-dir install \
|
||||||
|
http://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.10.1-cp27-none-linux_x86_64.whl
|
||||||
|
|
||||||
|
RUN pip --no-cache-dir install --upgrade \
|
||||||
|
requests \
|
||||||
|
Pillow \
|
||||||
|
h5py \
|
||||||
|
ipykernel \
|
||||||
|
jupyter \
|
||||||
|
keras_applications \
|
||||||
|
keras_preprocessing \
|
||||||
|
matplotlib \
|
||||||
|
numpy \
|
||||||
|
pandas \
|
||||||
|
scipy \
|
||||||
|
sklearn \
|
||||||
|
&& \
|
||||||
|
python -m ipykernel.kernelspec
|
||||||
|
|
||||||
# Install TensorFlow C library
|
# Install TensorFlow C library
|
||||||
RUN curl -L \
|
RUN curl -L \
|
||||||
"https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.3.0.tar.gz" | \
|
"https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-1.10.1.tar.gz" | \
|
||||||
tar -C "/usr/local" -xz
|
tar -C "/usr/local" -xz
|
||||||
RUN ldconfig
|
RUN ldconfig
|
||||||
|
|
||||||
# Hide some warnings
|
# Hide some warnings
|
||||||
ENV TF_CPP_MIN_LOG_LEVEL 2
|
ENV TF_CPP_MIN_LOG_LEVEL 2
|
||||||
|
|
||||||
RUN curl -L "https://download.opensuse.org/repositories/graphics:darktable:stable/xUbuntu_16.04/Release.key" | apt-key add -
|
|
||||||
RUN sh -c "echo 'deb http://download.opensuse.org/repositories/graphics:/darktable:/stable/xUbuntu_16.04/ /' > /etc/apt/sources.list.d/darktable.list"
|
|
||||||
|
|
||||||
# Install Go
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
||||||
g++ \
|
|
||||||
gcc \
|
|
||||||
libc6-dev \
|
|
||||||
make \
|
|
||||||
pkg-config \
|
|
||||||
nano \
|
|
||||||
build-essential \
|
|
||||||
wget \
|
|
||||||
darktable \
|
|
||||||
git \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
RUN apt-get upgrade -y
|
|
||||||
|
|
||||||
# Install NPM (NodeJS)
|
# Install NPM (NodeJS)
|
||||||
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
|
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
|
||||||
RUN apt-get install -y nodejs
|
RUN apt-get install -y nodejs
|
||||||
|
@ -36,40 +85,21 @@ RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
|
||||||
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
|
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
|
||||||
RUN apt-get update && apt-get install yarn
|
RUN apt-get update && apt-get install yarn
|
||||||
|
|
||||||
ENV GOLANG_VERSION 1.10
|
ENV GOLANG_VERSION 1.11
|
||||||
RUN set -eux; \
|
RUN set -eux; \
|
||||||
\
|
\
|
||||||
dpkgArch="$(dpkg --print-architecture)"; \
|
url="https://golang.org/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz"; \
|
||||||
case "${dpkgArch##*-}" in \
|
|
||||||
amd64) goRelArch='linux-amd64'; goRelSha256='b5a64335f1490277b585832d1f6c7f8c6c11206cba5cd3f771dcb87b98ad1a33' ;; \
|
|
||||||
armhf) goRelArch='linux-armv6l'; goRelSha256='6ff665a9ab61240cf9f11a07e03e6819e452a618a32ea05bbb2c80182f838f4f' ;; \
|
|
||||||
arm64) goRelArch='linux-arm64'; goRelSha256='efb47e5c0e020b180291379ab625c6ec1c2e9e9b289336bc7169e6aa1da43fd8' ;; \
|
|
||||||
i386) goRelArch='linux-386'; goRelSha256='2d26a9f41fd80eeb445cc454c2ba6b3d0db2fc732c53d7d0427a9f605bfc55a1' ;; \
|
|
||||||
ppc64el) goRelArch='linux-ppc64le'; goRelSha256='a1e22e2fbcb3e551e0bf59d0f8aeb4b3f2df86714f09d2acd260c6597c43beee' ;; \
|
|
||||||
s390x) goRelArch='linux-s390x'; goRelSha256='71cde197e50afe17f097f81153edb450f880267699f22453272d184e0f4681d7' ;; \
|
|
||||||
*) goRelArch='src'; goRelSha256='f3de49289405fda5fd1483a8fe6bd2fa5469e005fd567df64485c4fa000c7f24'; \
|
|
||||||
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"; \
|
wget -O go.tgz "$url"; \
|
||||||
echo "${goRelSha256} *go.tgz" | sha256sum -c -; \
|
echo "b3fcf280ff86558e0559e185b601c9eade0fd24c900b4c63cd14d1d38613e499 *go.tgz" | sha256sum -c -; \
|
||||||
tar -C /usr/local -xzf go.tgz; \
|
tar -C /usr/local -xzf go.tgz; \
|
||||||
rm 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"; \
|
export PATH="/usr/local/go/bin:$PATH"; \
|
||||||
go version
|
go version
|
||||||
|
|
||||||
ENV GOPATH /go
|
ENV GOPATH /go
|
||||||
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
|
ENV GOBIN $GOPATH/bin
|
||||||
|
ENV PATH $GOBIN:/usr/local/go/bin:$PATH
|
||||||
|
# ENV GO111MODULE on
|
||||||
|
|
||||||
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
|
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
|
||||||
|
|
||||||
|
@ -84,9 +114,6 @@ RUN mkdir -p /model && \
|
||||||
unzip /model/inception.zip -d /model && \
|
unzip /model/inception.zip -d /model && \
|
||||||
chmod -R 777 /model
|
chmod -R 777 /model
|
||||||
|
|
||||||
# Doesn't work properly at the moment (wait for stable release)
|
|
||||||
# RUN go get -u github.com/kardianos/govendor
|
|
||||||
|
|
||||||
# Using dep for the moment...
|
# Using dep for the moment...
|
||||||
RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
||||||
RUN mkdir -m 777 /go/pkg/dep
|
RUN mkdir -m 777 /go/pkg/dep
|
||||||
|
@ -101,9 +128,11 @@ COPY . .
|
||||||
|
|
||||||
RUN cp config.example.yml ~/.photoprism
|
RUN cp config.example.yml ~/.photoprism
|
||||||
|
|
||||||
# RUN govendor sync
|
# Get dependencies and install
|
||||||
RUN dep ensure
|
RUN dep ensure
|
||||||
|
RUN go install cmd/photoprism/photoprism.go
|
||||||
|
|
||||||
# Build
|
EXPOSE 80
|
||||||
# RUN govendor install +local
|
|
||||||
RUN go build cmd/photoprism/photoprism.go
|
# Start PhotoPrism server
|
||||||
|
CMD photoprism start
|
2
Gopkg.lock
generated
2
Gopkg.lock
generated
|
@ -340,4 +340,4 @@
|
||||||
"github.com/urfave/cli",
|
"github.com/urfave/cli",
|
||||||
]
|
]
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
solver-version = 1
|
||||||
|
|
|
@ -59,6 +59,8 @@ func main() {
|
||||||
|
|
||||||
conf.CreateDirectories()
|
conf.CreateDirectories()
|
||||||
|
|
||||||
|
conf.MigrateDb()
|
||||||
|
|
||||||
fmt.Printf("Starting web server at port %d...\n", context.Int("port"))
|
fmt.Printf("Starting web server at port %d...\n", context.Int("port"))
|
||||||
|
|
||||||
server.Start(context.String("ip"), context.Int("port"), conf)
|
server.Start(context.String("ip"), context.Int("port"), conf)
|
||||||
|
|
17
config.go
17
config.go
|
@ -11,6 +11,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
@ -112,13 +113,23 @@ func (c *Config) ConnectToDatabase() error {
|
||||||
db, err := gorm.Open(c.DatabaseDriver, c.DatabaseDsn)
|
db, err := gorm.Open(c.DatabaseDriver, c.DatabaseDsn)
|
||||||
|
|
||||||
if err != nil || db == nil {
|
if err != nil || db == nil {
|
||||||
log.Fatal(err)
|
for i := 1; i <= 12; i++ {
|
||||||
|
time.Sleep(5 * time.Second)
|
||||||
|
|
||||||
|
db, err = gorm.Open(c.DatabaseDriver, c.DatabaseDsn)
|
||||||
|
|
||||||
|
if db != nil && err == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil || db == nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c.db = db
|
c.db = db
|
||||||
|
|
||||||
c.MigrateDb()
|
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ version: '3.3'
|
||||||
services:
|
services:
|
||||||
photoprism:
|
photoprism:
|
||||||
build: .
|
build: .
|
||||||
|
command: tail -f /dev/null
|
||||||
database:
|
database:
|
||||||
image: mysql:latest
|
image: mysql:latest
|
||||||
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=1024
|
command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --max-connections=1024
|
||||||
|
|
|
@ -2,12 +2,10 @@ version: '3.3'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
photoprism:
|
photoprism:
|
||||||
build: .
|
image: photoprism/photoprism
|
||||||
|
command: tail -f /dev/null
|
||||||
ports:
|
ports:
|
||||||
- 80:80
|
- 80:80
|
||||||
- 8080:8080
|
|
||||||
- 6006:6006
|
|
||||||
- 8888:8888
|
|
||||||
volumes:
|
volumes:
|
||||||
- .:/go/src/github.com/photoprism/photoprism
|
- .:/go/src/github.com/photoprism/photoprism
|
||||||
|
|
||||||
|
|
3
vendor/.gitignore
vendored
3
vendor/.gitignore
vendored
|
@ -1,3 +0,0 @@
|
||||||
*
|
|
||||||
!.gitignore
|
|
||||||
!vendor.json
|
|
Loading…
Reference in a new issue