-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature/deployment with copilot (#1)
* Use Python 3.10 * Deploy the app with copilot * Set up the local development server
- Loading branch information
1 parent
4f752ee
commit 3492f40
Showing
22 changed files
with
267 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.envrc | ||
.venv | ||
notebooks/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.9 | ||
3.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM python:3.10.9-slim-bullseye | ||
|
||
WORKDIR /code | ||
|
||
ENV POETRY_HOME="/opt/poetry" | ||
ENV PATH="$POETRY_HOME/bin:$PATH" | ||
|
||
RUN apt-get update && \ | ||
apt-get install --no-install-recommends -y curl && \ | ||
curl -sSL https://install.python-poetry.org/ | python - | ||
|
||
COPY ./pyproject.toml /code/pyproject.toml | ||
COPY ./poetry.lock /code/poetry.lock | ||
RUN poetry config virtualenvs.create false && \ | ||
poetry install --only main | ||
|
||
RUN curl -sSL https://install.python-poetry.org | python3 - --uninstall && \ | ||
apt-get remove -y curl && \ | ||
apt-get autoremove -y && \ | ||
apt-get clean | ||
|
||
COPY ./app /code/app | ||
|
||
EXPOSE 80 | ||
CMD ["uvicorn", "app.app:app", "--host", "0.0.0.0", "--port", "80"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,20 @@ | ||
from chalice import Chalice | ||
from slack_bolt.adapter.aws_lambda.chalice_handler import ChaliceSlackRequestHandler | ||
from fastapi import FastAPI, Request | ||
from slack_bolt.adapter.fastapi import SlackRequestHandler | ||
|
||
from chalicelib.slack import bolt_app | ||
from .lib.slack import bolt_app | ||
|
||
app = Chalice(app_name="openai-bot") | ||
slack_handler = ChaliceSlackRequestHandler(bolt_app, app) | ||
slack_handler.clear_all_log_handlers() | ||
app = FastAPI() | ||
slack_handler = SlackRequestHandler(bolt_app) | ||
|
||
|
||
@app.route("/_health") | ||
def health(): | ||
@app.get("/_health") | ||
async def health(): | ||
return {"status": "ok"} | ||
|
||
|
||
@app.route( | ||
"/slack/events", | ||
methods=["POST"], | ||
content_types=["application/x-www-form-urlencoded", "application/json"], | ||
) | ||
def slack_events(): | ||
request = app.current_request | ||
@app.post("/slack/events") | ||
async def slack_events(request: Request): | ||
if request.headers.get("X-Slack-Retry-Num") is not None: | ||
return {"status": "retry request ignored"} | ||
response = slack_handler.handle(request) | ||
response = await slack_handler.handle(request) | ||
return response |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
application: openai-bot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# The manifest for the "backend" service. | ||
# Read the full specification for the "Request-Driven Web Service" type at: | ||
# https://aws.github.io/copilot-cli/docs/manifest/rd-web-service/ | ||
|
||
# Your service name will be used in naming your resources like log groups, App Runner services, etc. | ||
name: backend | ||
# The "architecture" of the service you're running. | ||
type: Request-Driven Web Service | ||
|
||
image: | ||
# Docker build arguments. | ||
# For additional overrides: https://aws.github.io/copilot-cli/docs/manifest/rd-web-service/#image-build | ||
build: Dockerfile | ||
# Port exposed through your container to route traffic to it. | ||
port: 80 | ||
|
||
# http: | ||
# healthcheck: | ||
# path: / | ||
# healthy_threshold: 3 | ||
# unhealthy_threshold: 5 | ||
# interval: 10s | ||
# timeout: 5s | ||
|
||
# Number of CPU units for the task. | ||
cpu: 1024 | ||
# Amount of memory in MiB used by the task. | ||
memory: 2048 | ||
|
||
# Connect your App Runner service to your environment's VPC. | ||
# network: | ||
# vpc: | ||
# placement: private | ||
|
||
|
||
# Enable tracing for the service. | ||
# observability: | ||
# tracing: awsxray | ||
|
||
# Optional fields for more advanced use-cases. | ||
# | ||
variables: # Pass environment variables as key value pairs. | ||
LOG_LEVEL: info | ||
SLACK_BOT_TOKEN: {{ SLACK_BOT_TOKEN }} | ||
SLACK_USER_TOKEN: {{ SLACK_USER_TOKEN }} | ||
SLACK_SIGNING_SECRET: {{ SLACK_SIGNING_SECRET }} | ||
OPENAI_ORGANIZATION: {{ OPENAI_ORGANIZATION }} | ||
OPENAI_API_KEY: {{ OPENAI_API_KEY }} | ||
|
||
# | ||
# tags: # Pass tags as key value pairs. | ||
# project: project-name | ||
|
||
# You can override any of the values defined above by environment. | ||
# environments: | ||
# dev: | ||
# variables: | ||
# LOG_LEVEL: debug | ||
# SLACK_BOT_TOKEN: {{ SLACK_BOT_TOKEN_DEV }} | ||
# SLACK_USER_TOKEN: {{ SLACK_USER_TOKEN_DEV }} | ||
# SLACK_SIGNING_SECRET: {{ SLACK_SIGNING_SECRET_DEV }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# The manifest for the "test" environment. | ||
# Read the full specification for the "Environment" type at: | ||
# https://aws.github.io/copilot-cli/docs/manifest/environment/ | ||
|
||
# Your environment name will be used in naming your resources like VPC, cluster, etc. | ||
name: dev | ||
type: Environment | ||
|
||
# Import your own VPC and subnets or configure how they should be created. | ||
# network: | ||
# vpc: | ||
# id: | ||
|
||
# Configure the load balancers in your environment, once created. | ||
# http: | ||
# public: | ||
# private: | ||
|
||
# Configure observability for your environment resources. | ||
observability: | ||
container_insights: false |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.