Skip to content

Commit 5860563

Browse files
authored
Merge pull request stripe#17 from suz-stripe/docker
Ruby version update + Docker support
2 parents 3a5109b + 2e39c53 commit 5860563

File tree

5 files changed

+55
-18
lines changed

5 files changed

+55
-18
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env

.ruby-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.5.1
1+
2.6.5

Dockerfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM ruby:2.6.5-alpine
2+
3+
RUN apk add build-base
4+
RUN mkdir -p /www/example-terminal-backend
5+
WORKDIR /www/example-terminal-backend
6+
COPY . .
7+
RUN bundle install
8+
EXPOSE 4567
9+
10+
ENTRYPOINT ["ruby", "web.rb", "-o", "0.0.0.0"]

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source "https://rubygems.org"
22

3-
ruby "2.5.1"
3+
ruby "2.6.5"
44

55
gem 'dotenv', '~> 2.2'
66
gem 'encrypted_cookie', '~> 0.0'

README.md

+42-16
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,52 @@
11
# Example Terminal Backend
22

3-
This is a simple [Sinatra](http://www.sinatrarb.com/) webapp that you can use to run the [Stripe Terminal](https://stripe.com/docs/terminal) example apps. To get started:
3+
This is a simple [Sinatra](http://www.sinatrarb.com/) webapp that you can use to run the [Stripe Terminal](https://stripe.com/docs/terminal) example apps. To get started, you can choose from the following options:
44

5-
1. Set up a free [Heroku account](https://signup.heroku.com).
5+
1. [Run it on a free Heroku account](#running-on-heroku)
6+
2. [Run it locally on your machine](#running-locally-on-your-machine)
7+
3. [Run it locally via Docker CLI](#running-locally-with-docker)
68

7-
2. Obtain your Stripe **secret, test mode** API Key, available in the [Dashboard](https://dashboard.stripe.com/account/apikeys). Note that you must use your secret key, not your publishable key, to set up the backend. For more information on the differences between **secret** and publishable keys, see [API Keys](https://stripe.com/docs/keys). For more information on **test mode**, see [Test and live modes](https://stripe.com/docs/keys#test-live-modes).
9+
ℹ️ You also need to obtain your Stripe **secret, test mode** API Key, available in the [Dashboard](https://dashboard.stripe.com/account/apikeys). Note that you must use your secret key, not your publishable key, to set up the backend. For more information on the differences between **secret** and publishable keys, see [API Keys](https://stripe.com/docs/keys). For more information on **test mode**, see [Test and live modes](https://stripe.com/docs/keys#test-live-modes).
810

9-
3. Click the button below to deploy the example backend. You'll be prompted to enter a name for the Heroku application as well as your Stripe API key.
11+
## Running the app
12+
13+
### Running on Heroku
14+
15+
1. Set up a free [Heroku account](https://signup.heroku.com).
16+
2. Click the button below to deploy the example backend. You'll be prompted to enter a name for the Heroku application as well as your Stripe API key.
17+
3. Go to the [next steps](#next-steps) in this README for how to use this app
1018

1119
[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy)
1220

21+
### Running locally on your machine
22+
23+
If you prefer running the backend locally, ensure you have the required Ruby runtime version installed as per the [latest Gemfile in this repo](Gemfile).
24+
25+
Clone down this repo to your computer, and then follow the steps below:
26+
27+
1. Create a file named `.env` within the newly cloned repo directory and add the following line:
28+
```
29+
STRIPE_TEST_SECRET_KEY={YOUR_API_KEY}
30+
```
31+
2. In your terminal, run `bundle install`
32+
3. Run `ruby web.rb`
33+
4. The example backend should now be running at `http://localhost:4567`
34+
5. Go to the [next steps](#next-steps) in this README for how to use this app
35+
36+
### Running locally with Docker
37+
38+
We have a pre-built Docker image you can run locally if you're into the convenience of containers.
39+
40+
Install [Docker Desktop](https://www.docker.com/products/developer-tools) if you don't already have it. Then follow the steps below:
41+
42+
1. In your terminal, run `docker run -e STRIPE_TEST_SECRET_KEY={YOUR_API_KEY} -p 4567:4567 stripe/example-terminal-backend` (replace `{YOUR_API_KEY}` with your own test key)
43+
2. The example backend should now be running at `http://localhost:4567`
44+
3. Go to the [next steps](#next-steps) in this README for how to use this app
45+
46+
---
47+
48+
## Next steps
49+
1350
Next, navigate to one of our example apps. Follow the instructions in the README to set up and run the app. You'll provide the URL of the example backend you just deployed.
1451

1552
| SDK | Example App |
@@ -18,16 +55,5 @@ Next, navigate to one of our example apps. Follow the instructions in the README
1855
| JavaScript | https://github.com/stripe/stripe-terminal-js-demo |
1956
| Android | https://github.com/stripe/stripe-terminal-android |
2057

21-
**Note that this backend is intended for example purposes only**. Because endpoints are not authenticated, you should not use this backend in production.
22-
23-
### Running locally
24-
If you prefer running the backend locally:
58+
⚠️ **Note that this backend is intended for example purposes only**. Because endpoints are not authenticated, you should not use this backend in production.
2559

26-
1. Create a file named `.env` and add the following line
27-
```
28-
STRIPE_TEST_SECRET_KEY={YOUR_API_KEY}
29-
```
30-
2. Run `bundle install`
31-
3. Run `ruby web.rb`
32-
33-
4. The example backend should now be running at `http://localhost:4567`

0 commit comments

Comments
 (0)