Refactor Dockerfile
- Use debian:bullseye instad for newer packages - Only install necessary dependencies for targeted arch - Make it work with libheif
This commit is contained in:
parent
93d6962a35
commit
b59ba20bd1
41
Dockerfile
41
Dockerfile
|
@ -20,34 +20,17 @@ COPY ui /app
|
|||
RUN npm run build -- --public-url $UI_PUBLIC_URL
|
||||
|
||||
### Build API ###
|
||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.15-buster AS api
|
||||
FROM --platform=${BUILDPLATFORM:-linux/amd64} debian:bullseye-slim AS api
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
# Use latest unstable packages for libheif
|
||||
RUN echo 'deb http://deb.debian.org/debian bullseye main' >> /etc/apt/sources.list.d/sources.list
|
||||
|
||||
# Install G++/GCC cross compilers
|
||||
RUN dpkg --add-architecture arm64 && dpkg --add-architecture armhf
|
||||
RUN apt-get update && apt-get install -t buster -y \
|
||||
g++-aarch64-linux-gnu \
|
||||
libc6-dev-arm64-cross \
|
||||
g++-arm-linux-gnueabihf \
|
||||
libc6-dev-armhf-cross \
|
||||
# Install go-face dependencies
|
||||
libdlib-dev libdlib-dev:arm64 libdlib-dev:armhf \
|
||||
libblas-dev libblas-dev:arm64 libblas-dev:armhf \
|
||||
liblapack-dev liblapack-dev:arm64 liblapack-dev:armhf \
|
||||
libjpeg62-turbo-dev libjpeg62-turbo-dev:arm64 libjpeg62-turbo-dev:armhf \
|
||||
# Install libheif for HEIF media decoding
|
||||
&& apt-get install -t bullseye -y libheif-dev/bullseye libheif-dev:arm64/bullseye libheif-dev:armhf/bullseye \
|
||||
# Cleanup
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
COPY docker/install_build_dependencies.sh /tmp/
|
||||
RUN chmod +x /tmp/install_build_dependencies.sh && /tmp/install_build_dependencies.sh
|
||||
|
||||
COPY docker/go_wrapper.sh /go/bin/go
|
||||
RUN chmod +x /go/bin/go
|
||||
|
||||
ENV CGO_ENABLED 1
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
RUN go env
|
||||
|
||||
RUN mkdir -p /app
|
||||
|
@ -58,7 +41,7 @@ COPY api/go.mod api/go.sum /app/
|
|||
RUN go mod download
|
||||
|
||||
# Patch go-face
|
||||
RUN sed -i 's/-march=native//g' /go/pkg/mod/github.com/!kagami/go-face*/face.go
|
||||
RUN sed -i 's/-march=native//g' /root/go/pkg/mod/github.com/!kagami/go-face*/face.go
|
||||
|
||||
# Build dependencies that use CGO
|
||||
RUN go install \
|
||||
|
@ -70,27 +53,19 @@ COPY api /app
|
|||
RUN go build -v -o photoview .
|
||||
|
||||
### Copy api and ui to production environment ###
|
||||
FROM debian:buster
|
||||
FROM debian:bullseye-slim
|
||||
ARG TARGETPLATFORM
|
||||
WORKDIR /app
|
||||
|
||||
COPY api/data /app/data
|
||||
|
||||
# Use latest unstable packages for libheif
|
||||
RUN echo 'deb http://deb.debian.org/debian bullseye main' >> /etc/apt/sources.list.d/sources.list
|
||||
|
||||
RUN apt-get update \
|
||||
# Required dependencies
|
||||
&& apt-get install -t buster -y curl gpg libdlib19 ffmpeg \
|
||||
&& apt-get install -t bullseye -y libheif1
|
||||
&& apt-get install -y curl gpg libdlib19 ffmpeg libheif1
|
||||
|
||||
# Install Darktable if building for a supported architecture
|
||||
RUN if [ "${TARGETPLATFORM}" = "linux/amd64" ] || [ "${TARGETPLATFORM}" = "linux/arm64" ]; then \
|
||||
echo 'deb http://download.opensuse.org/repositories/graphics:/darktable/Debian_10/ /' | tee /etc/apt/sources.list.d/graphics:darktable.list \
|
||||
&& curl -fsSL https://download.opensuse.org/repositories/graphics:darktable/Debian_10/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/graphics_darktable.gpg > /dev/null \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y darktable; \
|
||||
fi
|
||||
apt-get install -y darktable; fi
|
||||
|
||||
# Remove build dependencies and cleanup
|
||||
RUN apt-get purge -y curl gpg \
|
||||
|
|
|
@ -166,6 +166,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
|
|||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/strukturag/libheif v1.3.2 h1:NXft6czPSJiBeGc6hchNgczIY9aRPxsIcNIlVlDm2IY=
|
||||
github.com/strukturag/libheif v1.3.2/go.mod h1:E/PNRlmVtrtj9j2AvBZlrO4dsBDu6KfwDZn7X1Ce8Ks=
|
||||
github.com/strukturag/libheif v1.11.0 h1:HaWu5re98INSXNq7C8o5AwLcv2qD8+U7a+jVCpGWemI=
|
||||
github.com/strukturag/libheif v1.11.0/go.mod h1:E/PNRlmVtrtj9j2AvBZlrO4dsBDu6KfwDZn7X1Ce8Ks=
|
||||
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
|
||||
|
|
|
@ -104,4 +104,4 @@ if [ -z "$GOBIN" ] && [ -n "$GOPATH" ] && [ -n "$GOARCH" ] && [ -n "$GOOS" ]; th
|
|||
export PATH=${GOPATH}/bin/${GOOS}_${GOARCH}:${PATH}
|
||||
fi
|
||||
|
||||
exec /usr/local/go/bin/go "$@"
|
||||
exec /usr/bin/go "$@"
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ "$TARGETPLATFORM" == "linux/arm64" ]; then
|
||||
dpkg --add-architecture arm64
|
||||
DEBIAN_ARCH='arm64'
|
||||
elif [ "$TARGETPLATFORM" == "linux/arm/v6" ] || [ "$TARGETPLATFORM" == "linux/arm/v7" ]; then
|
||||
dpkg --add-architecture armhf
|
||||
DEBIAN_ARCH='armhf'
|
||||
else
|
||||
DEBIAN_ARCH='amd64'
|
||||
fi
|
||||
|
||||
apt-get update
|
||||
|
||||
# Install Golang
|
||||
apt-get install -y ca-certificates golang
|
||||
|
||||
# Install G++/GCC cross compilers
|
||||
apt-get install -y \
|
||||
g++-aarch64-linux-gnu \
|
||||
libc6-dev-arm64-cross \
|
||||
g++-arm-linux-gnueabihf \
|
||||
libc6-dev-armhf-cross
|
||||
|
||||
# Install go-face dependencies
|
||||
apt-get install -y \
|
||||
libdlib-dev:$DEBIAN_ARCH \
|
||||
libblas-dev:$DEBIAN_ARCH \
|
||||
liblapack-dev:$DEBIAN_ARCH \
|
||||
libjpeg62-turbo-dev:$DEBIAN_ARCH \
|
||||
|
||||
# Install libheif for HEIF media decoding
|
||||
apt-get install -y \
|
||||
libheif-dev:$DEBIAN_ARCH
|
||||
|
||||
# Cleanup
|
||||
apt-get clean
|
||||
rm -rf /var/lib/apt/lists/*
|
Loading…
Reference in New Issue