Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions README-TENCENT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Tencent Cloud Static Website Deployment

This document provides instructions on how to deploy the static website in the `docs/` directory to Tencent Cloud Object Storage (COS).

## Prerequisites

1. **Tencent Cloud Account:** You will need a Tencent Cloud account. If you don't have one, you can sign up on the [Tencent Cloud website](https://www.tencentcloud.com/).

2. **AWS CLI:** The deployment script uses the AWS CLI, which is compatible with Tencent's S3-like API for COS. You can install it using pip:
```bash
pip install awscli
```

3. **API Credentials:** You need to create an API key (SecretId and SecretKey) in the Tencent Cloud console.
- Navigate to the [API Key Management page](https://console.cloud.tencent.com/cam/capi).
- Create a new key and save the SecretId and SecretKey securely.

4. **Configure AWS CLI:** Configure the AWS CLI with your Tencent Cloud credentials. Run the following command and enter your credentials when prompted:
```bash
aws configure
```
- **AWS Access Key ID:** Enter your Tencent Cloud SecretId.
- **AWS Secret Access Key:** Enter your Tencent Cloud SecretKey.
- **Default region name:** Enter a Tencent Cloud region, for example, `ap-guangzhou`.
- **Default output format:** You can leave this as `json`.

## Deployment

The `tencent_deploy.sh` script automates the process of creating a COS bucket, configuring it for static website hosting, and uploading the website files.

### Usage

1. **Make the script executable:**
```bash
chmod +x tencent_deploy.sh
```

2. **Run the script:**
```bash
./tencent_deploy.sh <bucket-name> <region>
```
- `<bucket-name>`: A unique name for your COS bucket (e.g., `my-static-website-123`).
- `<region>`: The Tencent Cloud region where you want to create the bucket (e.g., `ap-guangzhou`).

**Example:**
```bash
./tencent_deploy.sh my-awesome-static-site ap-singapore
```

3. **Access your website:**
After the script finishes, it will print the URL of your deployed website. You can open this URL in your browser to see your live website.
43 changes: 43 additions & 0 deletions tencent_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# This script deploys a static website to Tencent Cloud Object Storage (COS).
# It uses the AWS CLI, which is compatible with Tencent COS S3 API.
#
# Prerequisites:
# 1. AWS CLI installed (pip install awscli)
# 2. AWS CLI configured with Tencent Cloud credentials.
# - Create a new API key on the Tencent Cloud console: https://console.cloud.tencent.com/cam/capi
# - Configure the AWS CLI with the SecretId and SecretKey:
# aws configure
# AWS Access Key ID [None]: <Your-SecretId>
# AWS Secret Access Key [None]: <Your-SecretKey>
# Default region name [None]: <Your-Region>
# Default output format [None]: json
#
# Usage:
# ./tencent_deploy.sh <bucket-name> <region>
# e.g., ./tencent_deploy.sh my-static-website ap-guangzhou

set -e

BUCKET_NAME=$1
REGION=$2
ENDPOINT_URL="cos.${REGION}.myqcloud.com"

if [ -z "$BUCKET_NAME" ] || [ -z "$REGION" ]; then
echo "Usage: $0 <bucket-name> <region>"
exit 1
fi

echo "Creating COS bucket: ${BUCKET_NAME}"
aws --endpoint-url "https://${ENDPOINT_URL}" s3 mb "s3://${BUCKET_NAME}"

echo "Configuring bucket for static website hosting..."
aws --endpoint-url "https://${ENDPOINT_URL}" s3 website "s3://${BUCKET_NAME}" --index-document "index.html" --error-document "index.html"

echo "Uploading website files from docs/ ..."
aws --endpoint-url "https://cos.${REGION}.myqcloud.com" s3 sync docs/ "s3://${BUCKET_NAME}" --acl public-read

WEBSITE_URL="http://${BUCKET_NAME}.cos-website.${REGION}.myqcloud.com"
echo "Deployment complete. Your website is available at:"
echo "${WEBSITE_URL}"
Loading