Add Scaleway Deployment Configuration #1
@@ -1,114 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Scaleway Deployment Setup Script
|
|
||||||
# This script helps configure your Scaleway environment for Hugo deployment
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
echo "=========================================="
|
|
||||||
echo "Scaleway Hugo Deployment Setup"
|
|
||||||
echo "=========================================="
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Colors for output
|
|
||||||
RED='\033[0;31m'
|
|
||||||
GREEN='\033[0;32m'
|
|
||||||
YELLOW='\033[1;33m'
|
|
||||||
NC='\033[0m' # No Color
|
|
||||||
|
|
||||||
# Check if scw CLI is installed
|
|
||||||
if ! command -v scw &> /dev/null; then
|
|
||||||
echo -e "${RED}Error: Scaleway CLI (scw) is not installed${NC}"
|
|
||||||
echo "Install it from: https://github.com/scaleway/scaleway-cli"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -e "${GREEN}✓ Scaleway CLI found${NC}"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
# Configuration
|
|
||||||
read -p "Enter your bucket name (default: notebook-arnodo-fr): " BUCKET_NAME
|
|
||||||
BUCKET_NAME=${BUCKET_NAME:-notebook-arnodo-fr}
|
|
||||||
|
|
||||||
read -p "Enter region (default: fr-par): " REGION
|
|
||||||
REGION=${REGION:-fr-par}
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo "Configuration:"
|
|
||||||
echo " Bucket: $BUCKET_NAME"
|
|
||||||
echo " Region: $REGION"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
read -p "Create bucket? (y/n): " CREATE_BUCKET
|
|
||||||
|
|
||||||
if [[ $CREATE_BUCKET =~ ^[Yy]$ ]]; then
|
|
||||||
echo -e "${YELLOW}Creating bucket...${NC}"
|
|
||||||
scw object bucket create name="$BUCKET_NAME" region="$REGION" || {
|
|
||||||
echo -e "${RED}Failed to create bucket. It might already exist.${NC}"
|
|
||||||
}
|
|
||||||
echo -e "${GREEN}✓ Bucket created/verified${NC}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
read -p "Configure bucket for static website hosting? (y/n): " CONFIGURE_WEBSITE
|
|
||||||
|
|
||||||
if [[ $CONFIGURE_WEBSITE =~ ^[Yy]$ ]]; then
|
|
||||||
echo -e "${YELLOW}Configuring static website hosting...${NC}"
|
|
||||||
scw object bucket update "$BUCKET_NAME" \
|
|
||||||
--website-enable=true \
|
|
||||||
--website-index=index.html \
|
|
||||||
--website-error=404.html \
|
|
||||||
region="$REGION"
|
|
||||||
echo -e "${GREEN}✓ Website hosting configured${NC}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
read -p "Apply public read bucket policy? (y/n): " APPLY_POLICY
|
|
||||||
|
|
||||||
if [[ $APPLY_POLICY =~ ^[Yy]$ ]]; then
|
|
||||||
echo -e "${YELLOW}Creating bucket policy...${NC}"
|
|
||||||
|
|
||||||
cat > /tmp/bucket-policy.json << EOF
|
|
||||||
{
|
|
||||||
"Version": "2023-04-17",
|
|
||||||
"Id": "PublicRead",
|
|
||||||
"Statement": [
|
|
||||||
{
|
|
||||||
"Sid": "PublicReadGetObject",
|
|
||||||
"Effect": "Allow",
|
|
||||||
"Principal": "*",
|
|
||||||
"Action": "s3:GetObject",
|
|
||||||
"Resource": "$BUCKET_NAME/*"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
scw object bucket update "$BUCKET_NAME" \
|
|
||||||
--policy=@/tmp/bucket-policy.json \
|
|
||||||
region="$REGION"
|
|
||||||
|
|
||||||
rm /tmp/bucket-policy.json
|
|
||||||
echo -e "${GREEN}✓ Public read policy applied${NC}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo -e "${GREEN}=========================================="
|
|
||||||
echo "Setup Complete!"
|
|
||||||
echo "==========================================${NC}"
|
|
||||||
echo ""
|
|
||||||
echo "Bucket endpoint: http://$BUCKET_NAME.s3-website.$REGION.scw.cloud"
|
|
||||||
echo ""
|
|
||||||
echo "Next steps:"
|
|
||||||
echo "1. Add Scaleway API keys to Gitea repository secrets:"
|
|
||||||
echo " - SCW_ACCESS_KEY"
|
|
||||||
echo " - SCW_SECRET_KEY"
|
|
||||||
echo " - SCW_BUCKET_NAME=$BUCKET_NAME"
|
|
||||||
echo ""
|
|
||||||
echo "2. Configure DNS CNAME record:"
|
|
||||||
echo " notebook.arnodo.fr CNAME $BUCKET_NAME.s3-website.$REGION.scw.cloud."
|
|
||||||
echo ""
|
|
||||||
echo "3. Push to main branch to trigger deployment"
|
|
||||||
echo ""
|
|
||||||
echo "4. Test your site at: http://$BUCKET_NAME.s3-website.$REGION.scw.cloud"
|
|
||||||
echo ""
|
|
||||||
Reference in New Issue
Block a user