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
19 changes: 19 additions & 0 deletions samples/docker/aiohttp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# docker build . -t your-repo/hello-bolt
#
FROM python:3.8.5-slim-buster as builder
RUN apt-get update && apt-get clean
COPY requirements.txt /build/
WORKDIR /build/
RUN pip install -U pip && pip install -r requirements.txt

FROM python:3.8.5-slim-buster as app
COPY --from=builder /src/ /app/
COPY --from=builder /usr/local/lib/ /usr/local/lib/
WORKDIR /app/
COPY *.py /app/
ENTRYPOINT python main.py

#
# docker run -e SLACK_SIGNING_SECRET=$SLACK_SIGNING_SECRET -e SLACK_BOT_TOKEN=$SLACK_BOT_TOKEN -e PORT=3000 -p 3000:3000 -it your-repo/hello-bolt
#
17 changes: 17 additions & 0 deletions samples/docker/aiohttp/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
import logging

from slack_bolt.async_app import AsyncApp

logging.basicConfig(level=logging.DEBUG)
app = AsyncApp()


@app.command("/hello-bolt-python")
async def hello(payload, ack):
user_id = payload["user_id"]
await ack(f"Hi <@{user_id}>!")


if __name__ == "__main__":
app.start(port=int(os.environ.get("PORT", int(os.environ.get("PORT", 3000)))))
2 changes: 2 additions & 0 deletions samples/docker/aiohttp/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
slack_bolt
aiohttp>=3,<4
12 changes: 12 additions & 0 deletions samples/docker/fastapi-gunicorn/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# docker build . -t your-repo/hello-bolt
#
FROM tiangolo/uvicorn-gunicorn:python3.8-slim
WORKDIR /app/
COPY *.py /app/
COPY requirements.txt /app/
RUN pip install -U pip && pip install -r requirements.txt

#
# docker run -e SLACK_SIGNING_SECRET=$SLACK_SIGNING_SECRET -e SLACK_BOT_TOKEN=$SLACK_BOT_TOKEN -e VARIABLE_NAME="api" -p 80:80 -it your-repo/hello-bolt
#
26 changes: 26 additions & 0 deletions samples/docker/fastapi-gunicorn/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import logging

from slack_bolt.async_app import AsyncApp

logging.basicConfig(level=logging.DEBUG)
app = AsyncApp()


@app.command("/hello-bolt-python")
async def hello(payload, ack):
user_id = payload["user_id"]
await ack(f"Hi <@{user_id}>!")


from fastapi import FastAPI, Request

api = FastAPI()

from slack_bolt.adapter.fastapi.async_handler import AsyncSlackRequestHandler

app_handler = AsyncSlackRequestHandler(app)


@api.post("/slack/events")
async def endpoint(req: Request):
return await app_handler.handle(req)
3 changes: 3 additions & 0 deletions samples/docker/fastapi-gunicorn/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
slack_bolt
fastapi<1
aiohttp>=3,<4
18 changes: 18 additions & 0 deletions samples/docker/flask-gunicorn/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# docker build . -t your-repo/hello-bolt
#
FROM python:3.8.5-slim-buster as builder
COPY requirements.txt /build/
WORKDIR /build/
RUN pip install -U pip && pip install -r requirements.txt

FROM python:3.8.5-slim-buster as app
WORKDIR /app/
COPY --from=builder /usr/local/bin/ /usr/local/bin/
COPY --from=builder /usr/local/lib/ /usr/local/lib/
COPY *.py /app/
ENTRYPOINT gunicorn --bind :$PORT --workers 1 --threads 2 --timeout 0 main:flask_app

#
# docker run -e SLACK_SIGNING_SECRET=$SLACK_SIGNING_SECRET -e SLACK_BOT_TOKEN=$SLACK_BOT_TOKEN -e PORT=3000 -p 3000:3000 -it your-repo/hello-bolt
#
24 changes: 24 additions & 0 deletions samples/docker/flask-gunicorn/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import logging

from slack_bolt import App

logging.basicConfig(level=logging.DEBUG)
app = App()


@app.command("/hello-bolt-python")
def hello(payload, ack):
user_id = payload["user_id"]
ack(f"Hi <@{user_id}>!")


from flask import Flask, request
from slack_bolt.adapter.flask import SlackRequestHandler

flask_app = Flask(__name__)
handler = SlackRequestHandler(app)


@flask_app.route("/slack/events", methods=["POST"])
def slack_events():
return handler.handle(request)
3 changes: 3 additions & 0 deletions samples/docker/flask-gunicorn/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
slack_bolt
Flask>=1.1
gunicorn>=20
22 changes: 22 additions & 0 deletions samples/docker/flask-uwsgi/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# docker build . -t your-repo/hello-bolt
#
FROM python:3.8.5-slim-buster as builder
RUN apt-get update \
&& apt-get -y install build-essential libpcre3-dev \
&& apt-get clean
COPY requirements.txt /build/
WORKDIR /build/
RUN pip install -U pip && pip install -r requirements.txt

FROM python:3.8.5-slim-buster as app
WORKDIR /app/
COPY --from=builder /usr/local/bin/ /usr/local/bin/
COPY --from=builder /usr/local/lib/ /usr/local/lib/
COPY *.py /app/
COPY uwsgi.ini /app/
ENTRYPOINT uwsgi --ini uwsgi.ini --http :$PORT

#
# docker run -e SLACK_SIGNING_SECRET=$SLACK_SIGNING_SECRET -e SLACK_BOT_TOKEN=$SLACK_BOT_TOKEN -e PORT=3000 -p 3000:3000 -it your-repo/hello-bolt
#
24 changes: 24 additions & 0 deletions samples/docker/flask-uwsgi/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import logging

from slack_bolt import App

logging.basicConfig(level=logging.DEBUG)
app = App()


@app.command("/hello-bolt-python")
def hello(payload, ack):
user_id = payload["user_id"]
ack(f"Hi <@{user_id}>!")


from flask import Flask, request
from slack_bolt.adapter.flask import SlackRequestHandler

flask_app = Flask(__name__)
handler = SlackRequestHandler(app)


@flask_app.route("/slack/events", methods=["POST"])
def slack_events():
return handler.handle(request)
3 changes: 3 additions & 0 deletions samples/docker/flask-uwsgi/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
slack_bolt
Flask>1
uWSGI>=2,<3
7 changes: 7 additions & 0 deletions samples/docker/flask-uwsgi/uwsgi.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[uwsgi]
module = main:flask_app
master = true
uid = nobody
socket = /tmp/uwsgi.sock
die-on-term = true
enable-threads = true
18 changes: 18 additions & 0 deletions samples/docker/sanic/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# docker build . -t your-repo/hello-bolt
#
FROM python:3.8.5-slim-buster as builder
COPY requirements.txt /build/
WORKDIR /build/
RUN pip install -U pip && pip install -r requirements.txt

FROM python:3.8.5-slim-buster as app
WORKDIR /app/
COPY *.py /app/
COPY --from=builder /usr/local/bin/ /usr/local/bin/
COPY --from=builder /usr/local/lib/ /usr/local/lib/
ENTRYPOINT python main.py

#
# docker run -e SLACK_SIGNING_SECRET=$SLACK_SIGNING_SECRET -e SLACK_BOT_TOKEN=$SLACK_BOT_TOKEN -e PORT=3000 -p 3000:3000 -it your-repo/hello-bolt
#
30 changes: 30 additions & 0 deletions samples/docker/sanic/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import logging
import os

from slack_bolt.async_app import AsyncApp
from slack_bolt.adapter.sanic import AsyncSlackRequestHandler

logging.basicConfig(level=logging.DEBUG)
app = AsyncApp()
app_handler = AsyncSlackRequestHandler(app)


@app.command("/hello-bolt-python")
async def hello(payload, ack):
user_id = payload["user_id"]
await ack(f"Hi <@{user_id}>!")


from sanic import Sanic
from sanic.request import Request

api = Sanic(name="awesome-slack-app")


@api.post("/slack/events")
async def endpoint(req: Request):
return await app_handler.handle(req)


if __name__ == "__main__":
api.run(host="0.0.0.0", port=int(os.environ.get("PORT", 3000)))
3 changes: 3 additions & 0 deletions samples/docker/sanic/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
slack_bolt
aiohttp>=3,<4
sanic>=20,<21
28 changes: 28 additions & 0 deletions samples/google_cloud_run/aiohttp/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# https://cloud.google.com/run/docs/quickstarts/build-and-deploy
#
# export PROJECT_ID=`gcloud config get-value project`
# export SLACK_SIGNING_SECRET=
# export SLACK_BOT_TOKEN=
# gcloud builds submit --tag gcr.io/$PROJECT_ID/helloworld
# gcloud run deploy helloworld --image gcr.io/$PROJECT_ID/helloworld --platform managed --update-env-vars SLACK_SIGNING_SECRET=$SLACK_SIGNING_SECRET,SLACK_BOT_TOKEN=$SLACK_BOT_TOKEN
#

# ----------------------------------------------
# Use the official lightweight Python image.
# https://hub.docker.com/_/python
FROM python:3.8.5-slim-buster

# Allow statements and log messages to immediately appear in the Knative logs
ENV PYTHONUNBUFFERED True

# Copy local code to the container image.
ENV APP_HOME /app
WORKDIR $APP_HOME
COPY . ./

# Install production dependencies.
RUN pip install -U pip && pip install -r requirements.txt

# Start AIOHTTP server
ENTRYPOINT python main.py
17 changes: 17 additions & 0 deletions samples/google_cloud_run/aiohttp/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import logging
import os

from slack_bolt.async_app import AsyncApp

logging.basicConfig(level=logging.DEBUG)
app = AsyncApp()


@app.command("/hey-google")
async def hello(payload, ack):
user_id = payload["user_id"]
await ack(f"Hi <@{user_id}>!")


if __name__ == "__main__":
app.start(port=int(os.environ.get("PORT", 3000)))
2 changes: 2 additions & 0 deletions samples/google_cloud_run/aiohttp/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
slack_bolt
aiohttp>=3,<4
28 changes: 28 additions & 0 deletions samples/google_cloud_run/flask-gunicorn/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# https://cloud.google.com/run/docs/quickstarts/build-and-deploy
#
# export PROJECT_ID=`gcloud config get-value project`
# export SLACK_SIGNING_SECRET=
# export SLACK_BOT_TOKEN=
# gcloud builds submit --tag gcr.io/$PROJECT_ID/helloworld
# gcloud run deploy helloworld --image gcr.io/$PROJECT_ID/helloworld --platform managed --update-env-vars SLACK_SIGNING_SECRET=$SLACK_SIGNING_SECRET,SLACK_BOT_TOKEN=$SLACK_BOT_TOKEN
#

# ----------------------------------------------
# Use the official lightweight Python image.
# https://hub.docker.com/_/python
FROM python:3.8.5-slim-buster

# Allow statements and log messages to immediately appear in the Knative logs
ENV PYTHONUNBUFFERED True

# Copy local code to the container image.
ENV APP_HOME /app
WORKDIR $APP_HOME
COPY . ./

# Install production dependencies.
RUN pip install -U pip && pip install -r requirements.txt

# Run the web service on container startup.
ENTRYPOINT gunicorn --bind :$PORT --workers 1 --threads 2 --timeout 0 main:flask_app
30 changes: 30 additions & 0 deletions samples/google_cloud_run/flask-gunicorn/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import logging
import os

from slack_bolt import App

logging.basicConfig(level=logging.DEBUG)
app = App()


@app.command("/hey-google")
def hello(payload, ack):
user_id = payload["user_id"]
ack(f"Hi <@{user_id}>!")


from flask import Flask, request
from slack_bolt.adapter.flask import SlackRequestHandler

flask_app = Flask(__name__)
handler = SlackRequestHandler(app)


@flask_app.route("/slack/events", methods=["POST"])
def slack_events():
return handler.handle(request)


# Only for local debug
if __name__ == "__main__":
flask_app.run(debug=True, host="0.0.0.0", port=int(os.environ.get("PORT", 3000)))
3 changes: 3 additions & 0 deletions samples/google_cloud_run/flask-gunicorn/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
slack_bolt
Flask>=1.1
gunicorn>=20
Loading