Fix permission issues with go.mod by using a writable copy
This commit is contained in:
parent
5f1cf21ebb
commit
8b28d7eb39
@ -98,14 +98,18 @@ 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 . && \
|
||||
sed -i 's/go 1.23/go 1.24.1/' server/go.mod
|
||||
sed -i 's/go 1.23/go 1.24.1/' server/go.mod && \
|
||||
mkdir -p /app/data/go && \
|
||||
cp -r server/go.mod server/go.sum /app/data/go/ && \
|
||||
chmod 777 /app/data/go/go.mod /app/data/go/go.sum
|
||||
|
||||
# Set Go environment variables
|
||||
ENV GOTOOLCHAIN=local
|
||||
ENV GO111MODULE=on
|
||||
ENV GOFLAGS="-mod=mod"
|
||||
ENV GOFLAGS="-modfile=/app/data/go/go.mod -mod=mod"
|
||||
ENV PATH="/usr/local/go/bin:${PATH}"
|
||||
ENV GOSUMDB=off
|
||||
ENV GOMODCACHE="/app/data/go/pkg/mod"
|
||||
|
||||
# Copy the web app built files from the first stage
|
||||
COPY --from=web-builder /build/web/photos /app/web/photos
|
||||
|
18
start.sh
18
start.sh
@ -318,7 +318,7 @@ if [ -x "$(command -v go)" ]; then
|
||||
# Don't try to modify the go.mod file since filesystem is read-only
|
||||
# Instead, use environment variables to override version requirements
|
||||
echo "==> Setting Go flags to override version requirements"
|
||||
export GOFLAGS="-mod=mod"
|
||||
export GOFLAGS="-modfile=/app/data/go/go.mod -mod=mod"
|
||||
export GO111MODULE=on
|
||||
export GOTOOLCHAIN=local
|
||||
fi
|
||||
@ -354,8 +354,18 @@ export GOPATH=/app/data/go
|
||||
export GO111MODULE=on
|
||||
# Use local toolchain to avoid downloading required version
|
||||
export GOTOOLCHAIN=local
|
||||
|
||||
# Ensure go.mod is in the writable directory
|
||||
if [ ! -f "/app/data/go/go.mod" ] && [ -f "$SERVER_DIR/go.mod" ]; then
|
||||
echo "==> Copying go.mod and go.sum to writable location"
|
||||
mkdir -p /app/data/go
|
||||
cp -f "$SERVER_DIR/go.mod" "$SERVER_DIR/go.sum" /app/data/go/ || echo "==> Warning: Could not copy go.mod/go.sum"
|
||||
chmod 666 /app/data/go/go.mod /app/data/go/go.sum || echo "==> Warning: Could not set permissions"
|
||||
fi
|
||||
|
||||
# Override version requirements and force module mode
|
||||
export GOFLAGS="-mod=mod -modcacherw"
|
||||
export GOFLAGS="-modfile=/app/data/go/go.mod -mod=mod -modcacherw"
|
||||
|
||||
# Create a temporary directory for Go module cache and build in writable area
|
||||
export GOCACHE=/app/data/go/cache
|
||||
export GOMODCACHE=/app/data/go/modcache
|
||||
@ -433,7 +443,7 @@ 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"
|
||||
export GOFLAGS="-modfile=/app/data/go/go.mod -mod=mod -modcacherw"
|
||||
# Use local toolchain to avoid downloading required version
|
||||
export GOTOOLCHAIN=local
|
||||
|
||||
@ -513,7 +523,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 GOFLAGS="-modfile=/app/data/go/go.mod -mod=mod -modcacherw"
|
||||
export GOTOOLCHAIN=local
|
||||
|
||||
echo "==> Running main.go with Go"
|
||||
|
Loading…
x
Reference in New Issue
Block a user