Deploying the Slack App¶
Jackalope is written in Python using the Flask framework. This gives a wide variety of options in deploying the application in your environment from installing onto a standalone server, a cloud instance, or within a container.
Note
If you are testing, skip to Run from application.py below.
You will need the following components to deploy the application:
- A web server or load balancer to serve traffic over TLS
- A WSGI server (uWSGI or Gunicorn for example) to run the application code
- A MySQL server
The application will only connect to a MySQL server if all of the required Environment Variables have been provided. If not, a local SQLite database will be created within the application directory.
In a cloud instance deployments you can use services such as:
Run from application.py¶
This script creates the root application object from the
jackalope.create_app()
application factory function. If the script has
been called from the command line an instance will be launched in a local
development server.
$ python application.py
The development server will be accessible at:
http://localhost:5000
If the application is being deployed with a WSGI framework, configure the WSGI
server to point to the application.py
file and the application
object.
Alternatively, the WSGI framework can instantiate and customize an application
object using jackalope.create_app()
.
Testing with ngrok¶
For testing, you can use the ngrok secure tunneling service to expose the application to the internet and access it using both HTTP and HTTPS.
Note
ngrok will create randomized subdomains each time you execute the
binary (e.g. 4951502d.ngrok.io
). Custom subdomain names are a part of a
paid subscription.
Once you have the ngrok
binary you can create your tunnel.
Expose a local port on your client (5000 in this example):
$ ngrok http 5000 --bind-tls true
Expose a port on another host from your client (such as a running Docker host):
$ ngrok http 192.168.99.100:5000 --bind-tls true
When ngrok
is running you will see the available public endpoints in the
window and a stream of traffic logging. Going to http://127.0.0.1:4040
in
your browser will show the web UI and additional details on the requests that
are being made through the tunnel.
Environment Variables¶
Configuration settings are applied at runtime from the environment variables detailed below.
-
DEBUG
¶ Run the application in debug mode (additional logging).
This setting will set to
True
if any value is provided. To leave this setting disabled do not set it in the environment.
-
SECRET_KEY
¶ The secret key is a value used to secure sessions with the application.
If a value is not present the application will generate a 16-byte key using
os.urandom()
.
-
SERVER_NAME
¶ The domain name of the application server.
Example:
jackalope.mydomain.org
-
SLACK_CLIENT_ID
¶ The client ID for the Slack application.
This is obtained during the app creation process at:
https://api.slack.com/apps
-
SLACK_CLIENT_SECRET
¶ The client secret key for the Slack application.
This is obtained during the app creation process at:
https://api.slack.com/apps
-
SLACK_SHAREABLE_URL
¶ The URL provided by Slack for installing the application to channels. This is used for the installation page’s “Add to Slack” button that is provided as a part of this application.
This is obtainted during the app create process at:
https://api.slack.com/apps
Note
The following database values are required when connecting Jackalope to a MySQL server. If they are omitted, a SQLite database will be created within the application directory. This is not recommended for production deployments.
-
DATABASE_URL
¶ The URL to the MySQL server with the port.
Example:
localhost:3306 database.mydomain.org:3306
-
DATABASE_NAME
¶ The name of the MySQL database residing on the server.
-
DATABASE_USER
¶ The username to access the database with.
-
DATABASE_PASSWD
¶ The password to the user accessing the database.