Develop: Update Go install script and related Dockerfiles

Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
Michael Mayer
2025-01-03 07:33:05 +01:00
parent 893d2327ae
commit 044fa4de08
23 changed files with 88 additions and 53 deletions

View File

@@ -172,7 +172,7 @@ install:
chmod -R $(INSTALL_MODE_BIN) $(DESTDIR)/bin $(DESTDIR)/lib chmod -R $(INSTALL_MODE_BIN) $(DESTDIR)/bin $(DESTDIR)/lib
@echo "PhotoPrism $(BUILD_TAG) has been successfully installed in \"$(DESTDIR)\".\nEnjoy!" @echo "PhotoPrism $(BUILD_TAG) has been successfully installed in \"$(DESTDIR)\".\nEnjoy!"
install-go: install-go:
sudo scripts/dist/install-go.sh sudo scripts/dist/install-go.sh latest
go build -v ./... go build -v ./...
install-tensorflow: install-tensorflow:
sudo scripts/dist/install-tensorflow.sh sudo scripts/dist/install-tensorflow.sh

View File

@@ -63,8 +63,8 @@ RUN echo 'APT::Acquire::Retries "3";' > /etc/apt/apt.conf.d/80retries && \
/scripts/install-libheif.sh && \ /scripts/install-libheif.sh && \
/scripts/install-tensorflow.sh && \ /scripts/install-tensorflow.sh && \
echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \
mkdir -p /etc/skel/.config/go && \ mkdir -p /etc/skel/.config/go/telemetry && \
echo 'off 2024-08-27' > '/etc/skel/.config/go/telemetry' && \ echo 'off 2025-01-03' > '/etc/skel/.config/go/telemetry/mode' && \
cp -r /etc/skel/.config /root/.config && \ cp -r /etc/skel/.config /root/.config && \
GOLANG_VERSION=go1.22.10 /scripts/install-go.sh && \ GOLANG_VERSION=go1.22.10 /scripts/install-go.sh && \
/scripts/install-go-tools.sh && \ /scripts/install-go-tools.sh && \

View File

@@ -72,8 +72,8 @@ RUN echo 'APT::Acquire::Retries "3";' > /etc/apt/apt.conf.d/80retries && \
/scripts/install-tensorflow.sh && \ /scripts/install-tensorflow.sh && \
/scripts/install-darktable.sh && \ /scripts/install-darktable.sh && \
echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \
mkdir -p /etc/skel/.config/go && \ mkdir -p /etc/skel/.config/go/telemetry && \
echo 'off 2024-08-27' > '/etc/skel/.config/go/telemetry' && \ echo 'off 2025-01-03' > '/etc/skel/.config/go/telemetry/mode' && \
cp -r /etc/skel/.config /root/.config && \ cp -r /etc/skel/.config /root/.config && \
GOLANG_VERSION=go1.22.10 /scripts/install-go.sh && \ GOLANG_VERSION=go1.22.10 /scripts/install-go.sh && \
/scripts/install-go-tools.sh && \ /scripts/install-go-tools.sh && \

View File

@@ -73,8 +73,8 @@ RUN echo 'APT::Acquire::Retries "3";' > /etc/apt/apt.conf.d/80retries && \
/scripts/install-libheif.sh && \ /scripts/install-libheif.sh && \
/scripts/install-chrome.sh && \ /scripts/install-chrome.sh && \
echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \
mkdir -p /etc/skel/.config/go && \ mkdir -p /etc/skel/.config/go/telemetry && \
echo 'off 2024-08-27' > '/etc/skel/.config/go/telemetry' && \ echo 'off 2025-01-03' > '/etc/skel/.config/go/telemetry/mode' && \
cp -r /etc/skel/.config /root/.config && \ cp -r /etc/skel/.config /root/.config && \
GOLANG_VERSION=go1.22.10 /scripts/install-go.sh && \ GOLANG_VERSION=go1.22.10 /scripts/install-go.sh && \
/scripts/install-go-tools.sh && \ /scripts/install-go-tools.sh && \

View File

@@ -74,10 +74,10 @@ RUN echo 'APT::Acquire::Retries "3";' > /etc/apt/apt.conf.d/80retries && \
/scripts/install-libheif.sh && \ /scripts/install-libheif.sh && \
/scripts/install-chrome.sh && \ /scripts/install-chrome.sh && \
echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \
mkdir -p /etc/skel/.config/go && \ mkdir -p /etc/skel/.config/go/telemetry && \
echo 'off 2024-08-27' > '/etc/skel/.config/go/telemetry' && \ echo 'off 2025-01-03' > '/etc/skel/.config/go/telemetry/mode' && \
cp -r /etc/skel/.config /root/.config && \ cp -r /etc/skel/.config /root/.config && \
GOLANG_VERSION=go1.22.10 /scripts/install-go.sh && \ /scripts/install-go.sh && \
/scripts/install-go-tools.sh && \ /scripts/install-go-tools.sh && \
echo 'alias go=richgo ll="ls -alh"' >> /etc/skel/.bashrc && \ echo 'alias go=richgo ll="ls -alh"' >> /etc/skel/.bashrc && \
echo 'export PS1="\u@$DOCKER_TAG:\w\$ "' >> /etc/skel/.bashrc && \ echo 'export PS1="\u@$DOCKER_TAG:\w\$ "' >> /etc/skel/.bashrc && \

View File

@@ -74,8 +74,8 @@ RUN echo 'APT::Acquire::Retries "3";' > /etc/apt/apt.conf.d/80retries && \
/scripts/install-libheif.sh && \ /scripts/install-libheif.sh && \
/scripts/install-chrome.sh && \ /scripts/install-chrome.sh && \
echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \ echo "ALL ALL=(ALL) NOPASSWD:SETENV: ALL" >> /etc/sudoers.d/all && \
mkdir -p /etc/skel/.config/go && \ mkdir -p /etc/skel/.config/go/telemetry && \
echo 'off 2024-08-27' > '/etc/skel/.config/go/telemetry' && \ echo 'off 2025-01-03' > '/etc/skel/.config/go/telemetry/mode' && \
cp -r /etc/skel/.config /root/.config && \ cp -r /etc/skel/.config /root/.config && \
GOLANG_VERSION=go1.22.10 /scripts/install-go.sh && \ GOLANG_VERSION=go1.22.10 /scripts/install-go.sh && \
/scripts/install-go-tools.sh && \ /scripts/install-go-tools.sh && \

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This installs the "duf" and "muffet" admin tools on Linux. # Installs the "duf" and "muffet" admin tools on Linux.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-admin-tools.sh) # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-admin-tools.sh)
# Abort if not executed as root.. # Abort if not executed as root..

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This installs the Caddy web server on Linux. # Installs the Caddy web server on Linux.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-caddy.sh) # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-caddy.sh)
set -e set -e

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This installs Google Chrome on Linux. # Installs Google Chrome on Linux.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-chrome.sh) # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-chrome.sh)
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH"

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This installs Darktable on Linux. # Installs Darktable on Linux.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-darktable.sh) # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-darktable.sh)
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH"

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This installs the DavFS filesystem driver on Linux. # Installs the DavFS filesystem driver on Linux.
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH"

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This installs Docker on Ubuntu Linux # Installs Docker on Ubuntu Linux
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-docker.sh) # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-docker.sh)
echo "Installing Docker..." echo "Installing Docker..."

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This installs the static FFmpeg build available at https://johnvansickle.com/ffmpeg/. # Installs the static FFmpeg build available at https://johnvansickle.com/ffmpeg/.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-ffmpeg.sh) # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-ffmpeg.sh)
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH"

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This installs a simple firewall on Ubuntu Linux that only allows incoming http, https and ssh connections. # Installs a simple firewall on Ubuntu Linux that only allows incoming http, https and ssh connections.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-firewall.sh) # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-firewall.sh)
# Install ufw package if needed: # Install ufw package if needed:

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This installs Go tools on Linux. # Installs development tools for Go on Linux.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-go-tools.sh) # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-go-tools.sh)
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:/usr/local/go/bin:/go/bin:$PATH" PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:/usr/local/go/bin:/go/bin:$PATH"

View File

@@ -1,24 +1,44 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This installs latest Go on Linux. # Downloads and installs the Go compiler on Linux.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-go.sh) # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-go.sh)
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH"
DESTDIR=$(realpath "${1:-/usr/local}") # Show usage information?
if [[ ${1} == "--help" ]]; then
echo "${0##*/} [version] [destdir] downloads and installs the Go compiler on Linux, for example:" 1>&2
echo "${0##*/}" 1>&2
echo "${0##*/} latest" 1>&2
echo "${0##*/} 1.23.4 /usr/local" 1>&2
exit 0
fi
# Query version. set -e
if [[ -z $GOLANG_VERSION ]]; then set +x
GOLANG_VERSION="go1.22.10"
elif [[ $GOLANG_VERSION == "latest" ]]; then # Check version to be installed:
GOLANG_VERSION=${1:-$GOLANG_VERSION}
if [[ -z $GOLANG_VERSION ]] || [[ $GOLANG_VERSION == "latest" ]]; then
GOLANG_VERSION=$(curl -fsSL https://go.dev/VERSION?m=text | head -n 1) GOLANG_VERSION=$(curl -fsSL https://go.dev/VERSION?m=text | head -n 1)
fi fi
echo "Installing ${GOLANG_VERSION} in \"${DESTDIR}\"..." GOLANG_VERSION=${GOLANG_VERSION#"go"}
set -e if [[ -z $GOLANG_VERSION ]]; then
echo "Go compiler version must be passed as first argument, e.g. 1.23.4" 1>&2
exit 1
fi
# Determine the system architecture. # Check destination directory:
DESTDIR=$(realpath "${2:-/usr/local}")
if [[ -z $DESTDIR ]] || [[ $DESTDIR == "default" ]]; then
DESTDIR="/usr/local"
fi
# Determine the system architecture:
if [[ $PHOTOPRISM_ARCH ]]; then if [[ $PHOTOPRISM_ARCH ]]; then
SYSTEM_ARCH=$PHOTOPRISM_ARCH SYSTEM_ARCH=$PHOTOPRISM_ARCH
else else
@@ -27,21 +47,22 @@ fi
DESTARCH=${BUILD_ARCH:-$SYSTEM_ARCH} DESTARCH=${BUILD_ARCH:-$SYSTEM_ARCH}
sudo mkdir -p "$DESTDIR" # Start installation:
echo "Installing Go ${GOLANG_VERSION} for ${DESTARCH^^} in \"${DESTDIR}\". Please wait."
set -eux; sudo mkdir -p "$DESTDIR"
case $DESTARCH in case $DESTARCH in
amd64 | AMD64 | x86_64 | x86-64) amd64 | AMD64 | x86_64 | x86-64)
URL="https://go.dev/dl/${GOLANG_VERSION}.linux-amd64.tar.gz" URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz"
;; ;;
arm64 | ARM64 | aarch64) arm64 | ARM64 | aarch64)
URL="https://go.dev/dl/${GOLANG_VERSION}.linux-arm64.tar.gz" URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-arm64.tar.gz"
;; ;;
arm | ARM | aarch | armv7l | armhf) arm | ARM | aarch | armv7l | armhf)
URL="https://go.dev/dl/${GOLANG_VERSION}.linux-armv6l.tar.gz" URL="https://go.dev/dl/go${GOLANG_VERSION}.linux-armv6l.tar.gz"
;; ;;
*) *)
@@ -50,18 +71,32 @@ case $DESTARCH in
;; ;;
esac esac
# Replace current installation in "/usr/local/go". # Replace current installation in "$DESTDIR/go":
echo "Installing Go for ${DESTARCH^^} from \"$URL\". Please wait." echo "Extracting \"${URL}\" to \"${DESTDIR}/go\"..."
sudo rm -rf /usr/local/go set -eux;
wget --inet4-only -c "$URL" -O - | sudo tar -xz -C /usr/local sudo rm -rf "${DESTDIR}/go"
wget --inet4-only -c "${URL}" -O - | sudo tar -xz -C "${DESTDIR}"
set +x
echo "Done."
# Add symlink to go binary. # Add symlink to go binary:
echo "Adding symbolic links for go and gofmt." echo "Adding symbolic links for \"${DESTDIR}/go/bin/go\" and \"${DESTDIR}/go/bin/gofmt\"..."
sudo ln -sf /usr/local/go/bin/go /usr/local/bin/go set -eux;
sudo ln -sf /usr/local/go/bin/gofmt /usr/local/bin/gofmt sudo ln -sf "${DESTDIR}/go/bin/go" /usr/local/bin/go
sudo ln -sf "${DESTDIR}/go/bin/gofmt" /usr/local/bin/gofmt
set +x
echo "Done."
# Test go command by showing installed Go version. Telemetry in Go >= 1.23 should be set to "off" in # Telemetry in Go >= 1.23 should be set to "off" in ~/.config/go/telemetry, see https://go.dev/doc/telemetry.
# ~/.config/go/telemetry, see https://go.dev/doc/telemetry. You can otherwise run "go telemetry off". # You can do this by running "go telemetry off":
echo "Disabling Go telemetry..."
set +e -x;
mkdir -p ~/.config/go
go telemetry off
set +x
# Test go command by showing installed Go version:
echo "Installed Go version:"
go version go version
echo "Done." echo "Enjoy!"

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This installs GPU drivers on Linux. # Installs GPU drivers on Linux.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-gpu.sh) # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-gpu.sh)
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH"

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This installs JPEG XL on Linux. # Installs JPEG XL on Linux.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-jxl.sh) # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-jxl.sh)
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH"

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This installs the heif-convert, heif-enc, heif-info, and heif-thumbnailer binaries on Linux. # Installs the heif-convert, heif-enc, heif-info, and heif-thumbnailer binaries on Linux.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-libheif.sh) # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-libheif.sh)
set -e set -e

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This installs MariaDB on Linux. # Installs MariaDB on Linux.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-mariadb.sh) # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-mariadb.sh)
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH"

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This installs NodeJS, NPM and TestCafe on Linux. # Installs NodeJS, NPM and TestCafe on Linux.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-nodejs.sh) # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-nodejs.sh)
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH"

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This installs the Nuclei Vulnerability Scanner on Linux. # Installs the Nuclei Vulnerability Scanner on Linux.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-nuclei.sh) # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-nuclei.sh)
# Abort if not executed as root.. # Abort if not executed as root..

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# This installs the TensorFlow libraries on Linux. # Installs the TensorFlow libraries on Linux.
# bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-tensorflow.sh) # bash <(curl -s https://raw.githubusercontent.com/photoprism/photoprism/develop/scripts/dist/install-tensorflow.sh)
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH" PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts:$PATH"