Fix Go version compatibility issues and prevent automatic toolchain downloads
This commit is contained in:
parent
6050c4564a
commit
aaf0dc0ca3
22
Dockerfile
22
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
|
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 && \
|
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 && \
|
npm install -g yarn serve && \
|
||||||
apt-get clean && apt-get autoremove && \
|
apt-get clean && apt-get autoremove && \
|
||||||
rm -rf /var/cache/apt /var/lib/apt/lists
|
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
|
# Set up directory structure
|
||||||
RUN mkdir -p /app/code /app/data/config /app/web
|
RUN mkdir -p /app/code /app/data/config /app/web
|
||||||
|
|
||||||
WORKDIR /app/code
|
WORKDIR /app/code
|
||||||
|
|
||||||
# Clone the ente repository during build (for the Museum server)
|
# 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 the web app built files from the first stage
|
||||||
COPY --from=web-builder /build/web/photos /app/web/photos
|
COPY --from=web-builder /build/web/photos /app/web/photos
|
||||||
|
10
start.sh
10
start.sh
@ -352,8 +352,8 @@ cd "$SERVER_DIR"
|
|||||||
# Set Go module cache to a writable location
|
# Set Go module cache to a writable location
|
||||||
export GOPATH=/app/data/go
|
export GOPATH=/app/data/go
|
||||||
export GO111MODULE=on
|
export GO111MODULE=on
|
||||||
# Use auto toolchain to allow downloading required version
|
# Use local toolchain to avoid downloading required version
|
||||||
export GOTOOLCHAIN=auto
|
export GOTOOLCHAIN=local
|
||||||
# Override version requirements and force module mode
|
# Override version requirements and force module mode
|
||||||
export GOFLAGS="-mod=mod -modcacherw"
|
export GOFLAGS="-mod=mod -modcacherw"
|
||||||
# Create a temporary directory for Go module cache and build in writable area
|
# 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
|
# Instead of modifying go.mod, set environment variables for compatibility
|
||||||
echo "==> Setting Go environment variables for compatibility"
|
echo "==> Setting Go environment variables for compatibility"
|
||||||
export GOFLAGS="-mod=mod -modcacherw"
|
export GOFLAGS="-mod=mod -modcacherw"
|
||||||
# Use auto toolchain to allow downloading required version
|
# Use local toolchain to avoid downloading required version
|
||||||
export GOTOOLCHAIN=auto
|
export GOTOOLCHAIN=local
|
||||||
|
|
||||||
# For Wasabi specific settings
|
# For Wasabi specific settings
|
||||||
if [[ "${S3_ENDPOINT}" == *"wasabi"* ]]; then
|
if [[ "${S3_ENDPOINT}" == *"wasabi"* ]]; then
|
||||||
@ -514,7 +514,7 @@ else
|
|||||||
# Instead of trying to modify go.mod, set environment variables for compatibility
|
# Instead of trying to modify go.mod, set environment variables for compatibility
|
||||||
echo "==> Setting Go environment variables for compatibility"
|
echo "==> Setting Go environment variables for compatibility"
|
||||||
export GOFLAGS="-mod=mod -modcacherw"
|
export GOFLAGS="-mod=mod -modcacherw"
|
||||||
export GOTOOLCHAIN=go1.22.2
|
export GOTOOLCHAIN=local
|
||||||
|
|
||||||
echo "==> Running main.go with Go"
|
echo "==> Running main.go with Go"
|
||||||
/usr/local/bin/gosu cloudron:cloudron go run -mod=mod main.go --port 8000 \
|
/usr/local/bin/gosu cloudron:cloudron go run -mod=mod main.go --port 8000 \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user