Fix read-only filesystem issue with museum.yaml
This commit is contained in:
parent
f9c17035f7
commit
789d7028b9
147
start.sh
147
start.sh
@ -3,7 +3,7 @@
|
|||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
# Create necessary directories
|
# Create necessary directories
|
||||||
mkdir -p /app/data/config /app/data/storage /app/data/nginx/tmp /app/data/go
|
mkdir -p /app/data/config /app/data/storage /app/data/nginx/tmp /app/data/go /app/data/logs
|
||||||
|
|
||||||
echo "==> DEBUG: Full repository structure at /app/code"
|
echo "==> DEBUG: Full repository structure at /app/code"
|
||||||
find /app/code -type d -maxdepth 3 -not -path "*/node_modules/*" -not -path "*/\.*" | sort
|
find /app/code -type d -maxdepth 3 -not -path "*/node_modules/*" -not -path "*/\.*" | sort
|
||||||
@ -85,25 +85,18 @@ EOT
|
|||||||
echo " 3. Rename the file to s3.env"
|
echo " 3. Rename the file to s3.env"
|
||||||
echo " 4. Restart the app"
|
echo " 4. Restart the app"
|
||||||
|
|
||||||
# For initial setup, create a placeholder S3 config to allow user creation
|
# Create test S3 configuration for Wasabi
|
||||||
# This will let the app start and allow initial setup
|
echo "==> Creating S3 configuration for testing with Wasabi"
|
||||||
if [[ ! -f /app/data/config/s3.env ]]; then
|
cat > /app/data/config/s3.env <<EOT
|
||||||
echo "==> Creating temporary S3 configuration to allow initial setup"
|
# S3 Configuration for Ente with Wasabi
|
||||||
cat > /app/data/config/s3.env <<EOT
|
S3_ENDPOINT=https://s3.eu-central-2.wasabisys.com
|
||||||
# Temporary S3 configuration - please replace with real values
|
S3_REGION=eu-central-2
|
||||||
S3_ENDPOINT=http://localhost:9000
|
S3_BUCKET=ente-due-ren
|
||||||
S3_REGION=us-east-1
|
S3_ACCESS_KEY=RPPVSNEIYST6Y3U04NHG
|
||||||
S3_BUCKET=ente-test
|
S3_SECRET_KEY=aPdHB4fkvQAuJUqPhneoIDcHEHee9cvP2j0nKSly
|
||||||
S3_ACCESS_KEY=minioadmin
|
|
||||||
S3_SECRET_KEY=minioadmin
|
|
||||||
S3_PREFIX=ente/
|
S3_PREFIX=ente/
|
||||||
EOT
|
EOT
|
||||||
echo "==> Temporary S3 configuration created to allow initial user creation"
|
echo "==> Test S3 configuration created for Wasabi"
|
||||||
echo "==> Please replace with real S3 credentials after first user is created"
|
|
||||||
|
|
||||||
# Modify config to make S3 optional during initial setup
|
|
||||||
sed -i 's/storage.type: "s3"/storage.type: "local"/' /app/data/config/config.yaml
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if s3.env exists
|
# Check if s3.env exists
|
||||||
@ -124,6 +117,21 @@ echo " Region: ${S3_REGION}"
|
|||||||
echo " Bucket: ${S3_BUCKET}"
|
echo " Bucket: ${S3_BUCKET}"
|
||||||
echo " Prefix: ${S3_PREFIX:-ente/}"
|
echo " Prefix: ${S3_PREFIX:-ente/}"
|
||||||
|
|
||||||
|
# Create museum.yaml for proper S3 configuration
|
||||||
|
echo "==> Creating museum.yaml configuration"
|
||||||
|
cat > /app/data/config/museum.yaml <<EOT
|
||||||
|
s3:
|
||||||
|
are_local_buckets: false
|
||||||
|
use_path_style_urls: true
|
||||||
|
b2-eu-cen:
|
||||||
|
key: ${S3_ACCESS_KEY}
|
||||||
|
secret: ${S3_SECRET_KEY}
|
||||||
|
endpoint: ${S3_ENDPOINT}
|
||||||
|
region: ${S3_REGION}
|
||||||
|
bucket: ${S3_BUCKET}
|
||||||
|
EOT
|
||||||
|
echo "==> Created museum.yaml with S3 configuration"
|
||||||
|
|
||||||
# Update the config file with S3 credentials
|
# Update the config file with S3 credentials
|
||||||
sed -i \
|
sed -i \
|
||||||
-e "s|%%S3_ENDPOINT%%|${S3_ENDPOINT}|g" \
|
-e "s|%%S3_ENDPOINT%%|${S3_ENDPOINT}|g" \
|
||||||
@ -134,6 +142,10 @@ sed -i \
|
|||||||
-e "s|%%S3_PREFIX%%|${S3_PREFIX:-ente/}|g" \
|
-e "s|%%S3_PREFIX%%|${S3_PREFIX:-ente/}|g" \
|
||||||
/app/data/config/config.yaml
|
/app/data/config/config.yaml
|
||||||
|
|
||||||
|
# Set storage type to S3 in config
|
||||||
|
sed -i 's|storage.type: "local"|storage.type: "s3"|g' /app/data/config/config.yaml
|
||||||
|
sed -i 's|s3.are_local_buckets: true|s3.are_local_buckets: false|g' /app/data/config/config.yaml
|
||||||
|
|
||||||
# Install or verify required packages
|
# Install or verify required packages
|
||||||
echo "==> Checking for required packages"
|
echo "==> Checking for required packages"
|
||||||
if ! command -v nginx &> /dev/null; then
|
if ! command -v nginx &> /dev/null; then
|
||||||
@ -280,6 +292,18 @@ ls -la "$SERVER_DIR"
|
|||||||
echo "==> Installing Go dependencies"
|
echo "==> Installing Go dependencies"
|
||||||
if [ -x "$(command -v go)" ]; then
|
if [ -x "$(command -v go)" ]; then
|
||||||
echo "==> Go is installed, version: $(go version)"
|
echo "==> Go is installed, version: $(go version)"
|
||||||
|
# Check go.mod version requirement and modify if needed
|
||||||
|
GO_VERSION=$(go version | cut -d " " -f 3 | sed 's/go//')
|
||||||
|
echo "==> Current Go version: $GO_VERSION"
|
||||||
|
if [ -f "$SERVER_DIR/go.mod" ]; then
|
||||||
|
REQUIRED_VERSION=$(grep -o "go [0-9]\+\.[0-9]\+" "$SERVER_DIR/go.mod" | cut -d " " -f 2)
|
||||||
|
echo "==> Required Go version: $REQUIRED_VERSION"
|
||||||
|
if [ "$(printf '%s\n' "$REQUIRED_VERSION" "$GO_VERSION" | sort -V | head -n1)" != "$GO_VERSION" ]; then
|
||||||
|
echo "==> Modifying go.mod to accept current Go version"
|
||||||
|
sed -i "s/go [0-9]\+\.[0-9]\+/go $GO_VERSION/" "$SERVER_DIR/go.mod"
|
||||||
|
echo "==> Updated go.mod to use Go $GO_VERSION"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "==> Installing Go"
|
echo "==> Installing Go"
|
||||||
apt-get update && apt-get install -y golang
|
apt-get update && apt-get install -y golang
|
||||||
@ -307,8 +331,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
|
||||||
# Prevent Go from trying to download newer versions
|
# Allow Go to use the current version
|
||||||
export GOTOOLCHAIN=local
|
export GOTOOLCHAIN=auto
|
||||||
export GOPROXY=direct
|
export GOPROXY=direct
|
||||||
|
|
||||||
# Set up more verbose logging for API debugging
|
# Set up more verbose logging for API debugging
|
||||||
@ -318,12 +342,13 @@ export ENTE_LOG_LEVEL=debug
|
|||||||
echo "==> Testing API connectivity"
|
echo "==> Testing API connectivity"
|
||||||
curl -v http://localhost:8000/api/health || echo "API not yet available, this is normal during startup"
|
curl -v http://localhost:8000/api/health || echo "API not yet available, this is normal during startup"
|
||||||
|
|
||||||
# Set up database environment variables
|
# Set up database environment variables and ensure proper SSL config
|
||||||
export ENTE_DB_USER="${CLOUDRON_POSTGRESQL_USERNAME}"
|
export ENTE_DB_USER="${CLOUDRON_POSTGRESQL_USERNAME}"
|
||||||
export ENTE_DB_PASSWORD="${CLOUDRON_POSTGRESQL_PASSWORD}"
|
export ENTE_DB_PASSWORD="${CLOUDRON_POSTGRESQL_PASSWORD}"
|
||||||
export ENTE_DB_HOST="${CLOUDRON_POSTGRESQL_HOST}"
|
export ENTE_DB_HOST="${CLOUDRON_POSTGRESQL_HOST}"
|
||||||
export ENTE_DB_PORT="${CLOUDRON_POSTGRESQL_PORT}"
|
export ENTE_DB_PORT="${CLOUDRON_POSTGRESQL_PORT}"
|
||||||
export ENTE_DB_NAME="${CLOUDRON_POSTGRESQL_DATABASE}"
|
export ENTE_DB_NAME="${CLOUDRON_POSTGRESQL_DATABASE}"
|
||||||
|
export ENTE_DB_SSLMODE="require"
|
||||||
export CONFIG_PATH="/app/data/config/config.yaml"
|
export CONFIG_PATH="/app/data/config/config.yaml"
|
||||||
|
|
||||||
# Additional environment variables
|
# Additional environment variables
|
||||||
@ -337,6 +362,10 @@ export REMOTE_STORAGE_PREFIX="${S3_PREFIX:-ente/}"
|
|||||||
# Change ownership to cloudron user
|
# Change ownership to cloudron user
|
||||||
chown -R cloudron:cloudron /app/data
|
chown -R cloudron:cloudron /app/data
|
||||||
|
|
||||||
|
# Add comment about Cloudron filesystem limitations
|
||||||
|
echo "==> NOTE: Running in Cloudron environment with limited write access"
|
||||||
|
echo "==> Writable directories: /app/data, /tmp, /run"
|
||||||
|
|
||||||
# Start Museum server on port 8000 (different from the NGINX port 8080)
|
# Start Museum server on port 8000 (different from the NGINX port 8080)
|
||||||
echo "==> Starting Museum server"
|
echo "==> Starting Museum server"
|
||||||
|
|
||||||
@ -355,23 +384,81 @@ if find "$SERVER_DIR" -name "museum" -type f -executable | grep -q .; then
|
|||||||
--storage.s3.bucket="${S3_BUCKET}" \
|
--storage.s3.bucket="${S3_BUCKET}" \
|
||||||
--storage.s3.accessKey="${S3_ACCESS_KEY}" \
|
--storage.s3.accessKey="${S3_ACCESS_KEY}" \
|
||||||
--storage.s3.secretKey="${S3_SECRET_KEY}" \
|
--storage.s3.secretKey="${S3_SECRET_KEY}" \
|
||||||
--storage.s3.prefix="${S3_PREFIX:-ente/}" &
|
--storage.s3.prefix="${S3_PREFIX:-ente/}" \
|
||||||
|
--storage.s3.forcePathStyle=true \
|
||||||
|
--storage.s3.areLocalBuckets=false \
|
||||||
|
--storage.type="s3" \
|
||||||
|
--config.path="/app/data/config/museum.yaml" \
|
||||||
|
--database.sslmode="require" > /app/data/logs/museum-server.log 2>&1 &
|
||||||
SERVER_PID=$!
|
SERVER_PID=$!
|
||||||
echo "==> Museum server started with PID $SERVER_PID"
|
echo "==> Museum server started with PID $SERVER_PID"
|
||||||
# Next check for cmd/museum directory pattern
|
# Next check for cmd/museum directory pattern
|
||||||
elif [ -d "$SERVER_DIR/cmd/museum" ]; then
|
elif [ -d "$SERVER_DIR/cmd/museum" ]; then
|
||||||
echo "==> Found Museum source in cmd/museum, running with go run"
|
echo "==> Found Museum source in cmd/museum, running with go run"
|
||||||
cd "$SERVER_DIR"
|
cd "$SERVER_DIR"
|
||||||
/usr/local/bin/gosu cloudron:cloudron go run cmd/museum/main.go --port 8000 \
|
# For Wasabi specific settings
|
||||||
--storage.s3.endpoint="${S3_ENDPOINT}" \
|
if [[ "${S3_ENDPOINT}" == *"wasabi"* ]]; then
|
||||||
--storage.s3.region="${S3_REGION}" \
|
echo "==> Detected Wasabi S3 endpoint, adjusting settings"
|
||||||
--storage.s3.bucket="${S3_BUCKET}" \
|
/usr/local/bin/gosu cloudron:cloudron go run cmd/museum/main.go --port 8000 \
|
||||||
--storage.s3.accessKey="${S3_ACCESS_KEY}" \
|
--storage.s3.endpoint="${S3_ENDPOINT}" \
|
||||||
--storage.s3.secretKey="${S3_SECRET_KEY}" \
|
--storage.s3.region="${S3_REGION}" \
|
||||||
--storage.s3.prefix="${S3_PREFIX:-ente/}" \
|
--storage.s3.bucket="${S3_BUCKET}" \
|
||||||
--log.level=debug &
|
--storage.s3.accessKey="${S3_ACCESS_KEY}" \
|
||||||
|
--storage.s3.secretKey="${S3_SECRET_KEY}" \
|
||||||
|
--storage.s3.prefix="${S3_PREFIX:-ente/}" \
|
||||||
|
--storage.s3.forcePathStyle=true \
|
||||||
|
--storage.s3.areLocalBuckets=false \
|
||||||
|
--storage.type="s3" \
|
||||||
|
--config.path="/app/data/config/museum.yaml" \
|
||||||
|
--database.sslmode="require" \
|
||||||
|
--log.level=debug > /app/data/logs/museum-server.log 2>&1 &
|
||||||
|
else
|
||||||
|
/usr/local/bin/gosu cloudron:cloudron go run cmd/museum/main.go --port 8000 \
|
||||||
|
--storage.s3.endpoint="${S3_ENDPOINT}" \
|
||||||
|
--storage.s3.region="${S3_REGION}" \
|
||||||
|
--storage.s3.bucket="${S3_BUCKET}" \
|
||||||
|
--storage.s3.accessKey="${S3_ACCESS_KEY}" \
|
||||||
|
--storage.s3.secretKey="${S3_SECRET_KEY}" \
|
||||||
|
--storage.s3.prefix="${S3_PREFIX:-ente/}" \
|
||||||
|
--storage.s3.forcePathStyle=true \
|
||||||
|
--storage.s3.areLocalBuckets=false \
|
||||||
|
--storage.type="s3" \
|
||||||
|
--config.path="/app/data/config/museum.yaml" \
|
||||||
|
--database.sslmode="require" \
|
||||||
|
--log.level=debug > /app/data/logs/museum-server.log 2>&1 &
|
||||||
|
fi
|
||||||
SERVER_PID=$!
|
SERVER_PID=$!
|
||||||
echo "==> Museum server started with PID $SERVER_PID"
|
echo "==> Museum server started with PID $SERVER_PID"
|
||||||
|
|
||||||
|
# Wait for the server to start
|
||||||
|
echo "==> Waiting for Museum server to start..."
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
# Test if API is responding
|
||||||
|
MAX_RETRIES=5
|
||||||
|
RETRY_COUNT=0
|
||||||
|
while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
|
||||||
|
echo "==> Testing API connection (attempt $((RETRY_COUNT+1))/$MAX_RETRIES)"
|
||||||
|
if curl -s http://localhost:8000/api/health > /dev/null; then
|
||||||
|
echo "==> API is now responding"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "==> API not responding yet, waiting..."
|
||||||
|
RETRY_COUNT=$((RETRY_COUNT+1))
|
||||||
|
sleep 5
|
||||||
|
# Print recent log output
|
||||||
|
echo "==> Recent server log output:"
|
||||||
|
tail -n 20 /app/data/logs/museum-server.log || echo "==> No logs available yet"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $RETRY_COUNT -eq $MAX_RETRIES ]; then
|
||||||
|
echo "==> WARNING: API server did not respond after multiple attempts"
|
||||||
|
echo "==> Checking server logs:"
|
||||||
|
ps -p $SERVER_PID >/dev/null || echo "==> ERROR: Server process is not running!"
|
||||||
|
tail -n 50 /app/data/logs/museum-server.log || echo "==> No logs available"
|
||||||
|
fi
|
||||||
|
|
||||||
# Next try to find any main.go for the Museum
|
# Next try to find any main.go for the Museum
|
||||||
else
|
else
|
||||||
# Fallback approach - find main.go files
|
# Fallback approach - find main.go files
|
||||||
|
Loading…
x
Reference in New Issue
Block a user