diff --git a/Dockerfile b/Dockerfile index f08101f..8581ca0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,20 +76,36 @@ RUN mkdir -p /build/web/photos /build/web/accounts /build/web/auth /build/web/ca FROM cloudron/base:5.0.0@sha256:04fd70dbd8ad6149c19de39e35718e024417c3e01dc9c6637eaf4a41ec4e596c -# Install necessary packages for both Go and Node.js +# Install necessary packages (excluding golang as we'll install it manually) RUN apt-get update && \ - apt-get install -y curl git nodejs npm golang libsodium23 libsodium-dev pkg-config nginx && \ + apt-get install -y curl git nodejs npm libsodium23 libsodium-dev pkg-config nginx && \ npm install -g yarn serve && \ apt-get clean && apt-get autoremove && \ rm -rf /var/cache/apt /var/lib/apt/lists +# Install Go 1.22.2 +RUN curl -L https://go.dev/dl/go1.22.2.linux-amd64.tar.gz -o go.tar.gz && \ + rm -rf /usr/local/go && \ + tar -C /usr/local -xzf go.tar.gz && \ + rm go.tar.gz && \ + ln -sf /usr/local/go/bin/go /usr/local/bin/go && \ + ln -sf /usr/local/go/bin/gofmt /usr/local/bin/gofmt + # Set up directory structure RUN mkdir -p /app/code /app/data/config /app/web WORKDIR /app/code # Clone the ente repository during build (for the Museum server) -RUN git clone --depth=1 https://github.com/ente-io/ente.git . +RUN git clone --depth=1 https://github.com/ente-io/ente.git . && \ + sed -i 's/go 1.23/go 1.22.2/' server/go.mod + +# Set Go environment variables +ENV GOTOOLCHAIN=local +ENV GO111MODULE=on +ENV GOFLAGS="-mod=mod" +ENV PATH="/usr/local/go/bin:${PATH}" +ENV GOSUMDB=off # Copy the web app built files from the first stage COPY --from=web-builder /build/web/photos /app/web/photos diff --git a/start.sh b/start.sh index e129920..53087f3 100644 --- a/start.sh +++ b/start.sh @@ -352,8 +352,8 @@ cd "$SERVER_DIR" # Set Go module cache to a writable location export GOPATH=/app/data/go export GO111MODULE=on -# Use auto toolchain to allow downloading required version -export GOTOOLCHAIN=auto +# Use local toolchain to avoid downloading required version +export GOTOOLCHAIN=local # Override version requirements and force module mode export GOFLAGS="-mod=mod -modcacherw" # Create a temporary directory for Go module cache and build in writable area @@ -434,8 +434,8 @@ elif [ -d "$SERVER_DIR/cmd/museum" ]; then # Instead of modifying go.mod, set environment variables for compatibility echo "==> Setting Go environment variables for compatibility" export GOFLAGS="-mod=mod -modcacherw" - # Use auto toolchain to allow downloading required version - export GOTOOLCHAIN=auto + # Use local toolchain to avoid downloading required version + export GOTOOLCHAIN=local # For Wasabi specific settings if [[ "${S3_ENDPOINT}" == *"wasabi"* ]]; then @@ -514,7 +514,7 @@ else # Instead of trying to modify go.mod, set environment variables for compatibility echo "==> Setting Go environment variables for compatibility" export GOFLAGS="-mod=mod -modcacherw" - export GOTOOLCHAIN=go1.22.2 + export GOTOOLCHAIN=local echo "==> Running main.go with Go" /usr/local/bin/gosu cloudron:cloudron go run -mod=mod main.go --port 8000 \