Skip to content

Commit d17c020

Browse files
authored
feat: change ECR image to manual build
1 parent de54635 commit d17c020

File tree

10 files changed

+334
-166
lines changed

10 files changed

+334
-166
lines changed

.github/workflows/build-android.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ on:
55
branches: [ "main" ]
66
pull_request:
77
branches: [ "main" ]
8-
8+
permissions:
9+
contents: read
10+
pull-requests: write
911
jobs:
1012
build-android:
1113
runs-on: ubuntu-latest

.github/workflows/build-ios.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ on:
55
branches: [ "main" ]
66
pull_request:
77
branches: [ "main" ]
8-
8+
permissions:
9+
contents: read
10+
pull-requests: write
911
jobs:
1012
build-ios:
1113
runs-on: macos-latest

.github/workflows/code-lint.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ on:
55
branches: [ "main" ]
66
pull_request:
77
branches: [ "main" ]
8-
8+
permissions:
9+
contents: read
10+
pull-requests: write
911
jobs:
1012
code-lint:
1113
runs-on: ubuntu-latest

.github/workflows/release-template.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
description: 'Release Version Code'
1111
required: true
1212
type: string
13+
permissions:
14+
contents: read
15+
pull-requests: write
1316
env:
1417
NEW_VERSION: ${{ github.event.inputs.release_tag }}
1518
NEW_VERSION_CODE: ${{ github.event.inputs.release_code }}

README.md

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,37 +82,62 @@ this [example](https://github.com/awslabs/aws-lambda-web-adapter/tree/main/examp
8282
2. Check whether you are in the [supported region](#supported-region), then click on the **Create parameter** button.
8383
3. Fill in the parameters below, leaving other options as default:
8484

85-
- **Name**: Enter a parameter name (e.g., "SwiftChatAPIKey", will be used as `ApiKeyParam` in Step 2).
85+
- **Name**: Enter a parameter name (e.g., "SwiftChatAPIKey", will be used as `ApiKeyParam` in Step 3).
8686

8787
- **Type**: Select `SecureString`
8888

89-
- **Value**: Enter any string without spaces.(this will be your `API Key` in Step 3)
89+
- **Value**: Enter any string without spaces.(this will be your `API Key` in Step 4)
9090

9191
4. Click **Create parameter**.
9292

93-
### Step 2: Deploy stack and get your API URL
93+
### Step 2: Build and push container images to ECR
9494

95-
1. Go to [CloudFormation Console](https://console.aws.amazon.com/cloudformation/home#/stacks/create/template?stackName=SwiftChat) and select **Upload a template file** under **Specify template**, then use one of the following templates to deploy. (Make sure you are in the same region where your API Key was created.)
95+
1. Clone this repository:
96+
```bash
97+
git clone https://github.com/aws-samples/swift-chat.git
98+
cd swift-chat
99+
```
96100

97-
- **App Runner**
101+
2. Run the build and push script:
102+
```bash
103+
cd server/scripts
104+
bash ./push-to-ecr.sh
105+
```
98106

99-
Open [SwiftChatAppRunner.template](https://github.com/aws-samples/swift-chat/blob/main/server/template/SwiftChatAppRunner.template), then download and upload the file.
107+
3. Follow the prompts to configure:
108+
- ECR repository name (or use default: `swift-chat-api`)
109+
- Image tag (please use default: `latest`)
110+
- AWS region (the region you want to deploy, e.g.,: `us-east-1`)
111+
- Deployment type:
112+
- Option 1 (default): **AppRunner** - uses amd64 architecture
113+
- Option 2: **Lambda** - uses arm64 architecture
100114

101-
- **Lambda** (Note: For AWS customer use only)
115+
4. The script will build and push the Docker image to your ECR repository.
102116

103-
Open [SwiftChatLambda.template](https://github.com/aws-samples/swift-chat/blob/main/server/template/SwiftChatLambda.template) then download and upload the file.
117+
5. **Important**: Copy the image URI displayed at the end of the script output. You'll need this in the next step.
104118

105-
2. Click **Next**, On the "Specify stack details" page, provide the following information:
106-
- Fill the `ApiKeyParam` with the parameter name you used for storing the API key (e.g., "SwiftChatAPIKey").
107-
- For App Runner, choose an `InstanceTypeParam` based on your needs.
108-
3. Click **Next**, Keep the "Configure stack options" page as default, Read the Capabilities and Check the "I
119+
### Step 3: Deploy stack and get your API URL
120+
121+
1. Download the CloudFormation template you want to use:
122+
- For App Runner: [SwiftChatAppRunner.template](https://github.com/aws-samples/swift-chat/blob/main/server/template/SwiftChatAppRunner.template)
123+
- For Lambda: [SwiftChatLambda.template](https://github.com/aws-samples/swift-chat/blob/main/server/template/SwiftChatLambda.template)
124+
125+
2. Go to [CloudFormation Console](https://console.aws.amazon.com/cloudformation/home#/stacks/create/template?stackName=SwiftChatAPI) and select **Upload a template file** under **Specify template**, then upload the template file you downloaded. (Make sure you are in the same region where your API Key was created.)
126+
127+
3. Click **Next**, On the "Specify stack details" page, provide the following information:
128+
- **Stack name**: Keep the default "SwiftChatAPI" or change if needed
129+
- **ApiKeyParam**: Enter the parameter name you used for storing the API key (e.g., "SwiftChatAPIKey")
130+
- **ContainerImageUri**: Enter the ECR image URI from Step 2 output
131+
- For App Runner, choose an **InstanceTypeParam** based on your needs
132+
133+
4. Click **Next**, Keep the "Configure stack options" page as default, Read the Capabilities and Check the "I
109134
acknowledge that AWS CloudFormation might create IAM resources" checkbox at the bottom.
110-
4. Click **Next**, In the "Review and create" Review your configuration and click **Submit**.
135+
5. Click **Next**, In the "Review and create" Review your configuration and click **Submit**.
111136

112-
Wait about 3-5 minutes for the deployment to finish, then click the CloudFormation stack and go to **Outputs** tab, you
137+
Wait about 35 minutes for the deployment to finish, then click the CloudFormation stack and go to **Outputs** tab, you
113138
can find the **API URL** which looks like: `https://xxx.xxx.awsapprunner.com` or `https://xxx.lambda-url.xxx.on.aws`
114139

115-
### Step 3: Open the App and setup with API URL and API Key
140+
### Step 4: Open the App and setup with API URL and API Key
116141

117142
1. Launch the App, open the drawer menu, and tap **Settings**.
118143
2. Paste the `API URL` and `API Key`(The **Value** you typed in Parameter Store) Under Amazon Bedrock -> SwiftChat

README_CN.md

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,36 +74,60 @@ SwiftChat 是一款快速响应的 AI 聊天应用,采用 [React Native](https
7474
2. 检查您是否在 [支持的区域](#支持的区域),然后点击 **创建参数** 按钮。
7575
3. 填入以下参数,其他选项保持默认:
7676

77-
- **名称**:输入参数名称(例如 "SwiftChatAPIKey",将在步骤 2 中用作 `ApiKeyParam`)。
77+
- **名称**:输入参数名称(例如 "SwiftChatAPIKey",将在步骤 3 中用作 `ApiKeyParam`)。
7878

7979
- **类型**:选择 `SecureString`
8080

81-
- ****:输入任何不含空格的字符串(这将是步骤 3 中您的 `API Key`
81+
- ****:输入任何不含空格的字符串(这将是步骤 4 中您的 `API Key`
8282

8383
4. 点击 **创建参数**
8484

85-
### 步骤 2:部署堆栈并获取 API URL
85+
### 步骤 2:构建并推送容器镜像到 ECR
8686

87-
1. 前往 [CloudFormation 控制台](https://console.aws.amazon.com/cloudformation/home#/stacks/create/template?stackName=SwiftChat),在**指定模板**下选择**上传模板文件**,然后使用以下模板之一进行部署。(确保您所在的区域与创建 API Key 的区域相同。)
87+
1. 克隆此仓库:
88+
```bash
89+
git clone https://github.com/aws-samples/swift-chat.git
90+
cd swift-chat
91+
```
8892

89-
- **App Runner**
93+
2. 运行构建和推送脚本:
94+
```bash
95+
cd server/scripts
96+
bash ./push-to-ecr.sh
97+
```
9098

91-
打开 [SwiftChatAppRunner.template](https://github.com/aws-samples/swift-chat/blob/main/server/template/SwiftChatAppRunner.template),然后下载并上传文件。
99+
3. 按照提示进行配置:
100+
- ECR 仓库名称(或使用默认值:`swift-chat-api`
101+
- 镜像标签(请使用默认值:`latest`
102+
- AWS 区域(填写你希望部署的区域,例如:`us-east-1`
103+
- 部署类型:
104+
- 选项 1(默认):**AppRunner** - 使用 amd64 架构
105+
- 选项 2:**Lambda** - 使用 arm64 架构
92106

93-
- **Lambda**(注意:仅供 AWS 客户使用)
107+
4. 脚本将构建并推送 Docker 镜像到您的 ECR 仓库。
94108

95-
打开 [SwiftChatLambda.template](https://github.com/aws-samples/swift-chat/blob/main/server/template/SwiftChatLambda.template),然后下载并上传文件
109+
5. **重要**:复制脚本输出末尾显示的镜像 URI。您将在下一步中需要它
96110

97-
2. 点击 **下一步**,在"指定堆栈详细信息"页面,提供以下信息:
98-
- 用您存储 API 密钥的参数名称填写 `ApiKeyParam`(例如 "SwiftChatAPIKey")。
99-
- 对于 App Runner,根据您的需求选择 `InstanceTypeParam`
100-
3. 点击 **下一步**,保持"配置堆栈选项"页面为默认,阅读功能并勾选底部的"我确认 AWS CloudFormation 可能会创建 IAM 资源"复选框。
101-
4. 点击 **下一步**,在"审核并创建"中检查您的配置并点击 **提交**
111+
### 步骤 3:部署堆栈并获取 API URL
102112

103-
等待约 3-5 分钟完成部署,然后点击 CloudFormation 堆栈并转到 **输出** 选项卡,您可以找到类似
104-
`https://xxx.xxx.awsapprunner.com``https://xxx.lambda-url.xxx.on.aws`**API URL**
113+
1. 下载您想使用的 CloudFormation 模板:
114+
- App Runner:[SwiftChatAppRunner.template](https://github.com/aws-samples/swift-chat/blob/main/server/template/SwiftChatAppRunner.template)
115+
- Lambda:[SwiftChatLambda.template](https://github.com/aws-samples/swift-chat/blob/main/server/template/SwiftChatLambda.template)
105116

106-
### 步骤 3:打开应用并使用 API URL 和 API Key 进行设置
117+
2. 前往 [CloudFormation 控制台](https://console.aws.amazon.com/cloudformation/home#/stacks/create/template?stackName=SwiftChatAPI),在**指定模板**下选择**上传模板文件**,然后上传您下载的模板文件。(确保您所在的区域与创建 API Key 的区域相同。)
118+
119+
3. 点击 **下一步**,在"指定堆栈详细信息"页面,提供以下信息:
120+
- **Stack name**:保持默认的 "SwiftChatAPI" 或根据需要更改
121+
- **ApiKeyParam**:输入您用于存储 API 密钥的参数名称(例如 "SwiftChatAPIKey")
122+
- **ContainerImageUri**:输入步骤 2 输出的 ECR 镜像 URI
123+
- 对于 App Runner,根据您的需求选择 **InstanceTypeParam**
124+
125+
4. 点击 **下一步**,保持"配置堆栈选项"页面为默认,阅读功能并勾选底部的"我确认 AWS CloudFormation 可能会创建 IAM 资源"复选框。
126+
5. 点击 **下一步**,在"审核并创建"中检查您的配置并点击 **提交**
127+
128+
等待约 3-5 分钟完成部署,然后点击 CloudFormation 堆栈并转到 **输出** 选项卡,您可以找到 **API URL**,类似于:`https://xxx.xxx.awsapprunner.com``https://xxx.lambda-url.xxx.on.aws`
129+
130+
### 步骤 4:打开应用并使用 API URL 和 API Key 进行设置
107131

108132
1. 启动应用,打开抽屉菜单,点击 **设置**
109133
2. 粘贴 `API URL``API Key`(您在 Parameter Store 中输入的 ****)到 Amazon Bedrock -> SwiftChat Server 下,然后选择您的区域。

0 commit comments

Comments
 (0)