Skip to content

Commit

Permalink
Merge d4e8825 into 9c1af51
Browse files Browse the repository at this point in the history
  • Loading branch information
dometto committed Apr 8, 2023
2 parents 9c1af51 + d4e8825 commit 6cc0839
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 24 deletions.
51 changes: 27 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ CuttingEdge monitors the status of the dependencies of your projects and lets yo
* Gitlab (both gitlab.com and [self-hosted instances](#Adding-self-hosted-repository-servers))
* Gitea ([self-hosted](#Adding-self-hosted-repository-servers))
* Both public and [private repositories](#Authorization-and-private-repositories)

## Requirements

CuttingEdge is lightweight and easy to deploy:
CuttingEdge is lightweight and easy to deploy:

* No database required
* you can optionally use [data stores like Redis](#Using-Redis-and-other-data-stores)
* but you can optionally use [data stores like Redis](#Using-Redis-and-other-data-stores)
* Simple configuration through a `projects.yml` file
* Requires relatively few resources (~120MB RAM), so...
* It can even run on [Heroku](#Deploying-on-Heroku)'s free plan!
* It can even run on many hosting services' free plans, such as [Render.com](https://render.com)
* Easily deploy to Render.com with the provided [configuration](#Deploying-on-Render)!

## Installation

Expand All @@ -50,30 +49,34 @@ Before running, define your repositories in [projects.yml](#projectsyml). You ma

Also see our example [docker-compose](docker-compose.yml) file for an example of how to use CuttingEdge with [Redis as a datastore](#Using-Redis-and-other-data-stores) via Docker.

### Deploying on Heroku
### Deploying on Render

CuttingEdge runs out of the box on [Render.com](https://render.com), and is lightweight enough to function on the free plan. This repository already contains the `render.yaml` needed for deployment.

CuttingEdge runs out of the box on Heroku, and is lightweight enough to function on the Heroku free plan. This repository already contains the `Procfile` needed for deployment.
**Note: on Render, CuttingEdge uses `render.config.rb` instead of `config.rb`**.

**Note: on Heroku, CuttingEdge uses `heroku.config.rb` instead of `config.rb`**.
**Note: if you will be using a public GitHub or GitLab repo to host your CuttingEdge configuration, make sure not to put any secrets in `render.config.rb` or `projects.yaml`.** Instead, use [environment variables](https://render.com/docs/environment-variables) (for instance to [set authentication tokens](#Authorization-and-private-repositories)). **You can also add `render.config.rb` and `projects.yaml` as "secret files" on the Render.com Dashboard instead of committing them to your repo!**

Steps:

1. Clone/fork this repository, as it already contains some settings (in `heroku.config.rb`) relevant to Heroku
1. Edit `projects.yml` and commit it to the repo.
1. Fork this repository (for use on Render.com, your fork needs to be available on GitHub or GitLab).
1. Clone your fork locally.
1. Edit your `render.yaml` (set a name for your instance) and commit it to the repo.
1. Edit your `projects.yml` to suit your needs and commit it to the repo (or add it as a secret file).
1. Edit your `render.config.rb` to suit your needs and commit it to the repo (or add it as a secret file).
1. `gem install bundler && bundle install`
2. `git add Gemfile.lock && git commit -m "Commit Gemfile.lock for use on Heroku"`
3. `heroku create my-cuttingedge`
4. `heroku config:add HEROKU_APP_NAME=my-cuttingedge`
5. `heroku addons:create heroku-redis:hobby-dev -a my-cuttingedge` (using Redis is highly recommended on Heroku)
6. `git push heroku master`
7. *Optional, if you want to receive [email notifications](#Email-Notifications)*:
* `heroku addons:create mailgun:starter`
* `heroku config:add CUTTING_EDGE_MAIL_TO=mydependencies@mydependencymonitoring.com`
* If you are on the free plan: [add your email addresses as Authorized Recipients](https://help.mailgun.com/hc/en-us/articles/217531258-Authorized-Recipients) in [Mailgun](https://app.mailgun.com/) (login via Heroku)
1. `git add Gemfile.lock && bundle lock --add-platform x86_64-linux && git commit -m "Commit Gemfile.lock for use on Render"`
1. On Render.com, create a new Blueprint instance:
* On the Render Dashboard, go to the Blueprint page and click the New Blueprint Instance button.
* Connect your forked repository.
1. Render.com will now deploy your instance of CuttingEdge!
* Re-deployment will be triggered whenever you push to your GitHub or GitLab repo, or whenver you update the environment variables or secret files on the Render.com Dashboard.

You may also want to set some [Heroku config variables](https://devcenter.heroku.com/articles/config-vars), for instance to [use authentication tokens](#Authorization-and-private-repositories) in `heroku.config.rb`.
Note that Render switches off apps running on their free plan when they idle, so you may want to ensure your app does not idle by polling it periodically, or upgrade to a higher plan.

### Deploying on Heroku

Note that Heroku switches off apps running on their free plan when they idle, so you may want to look at [this](https://medium.com/better-programming/keeping-my-heroku-app-alive-b19f3a8c3a82).
Heroku's free plan has been discontinued, but this Repository still contains the necessary files for hosting CuttingEdge on Heroku. See [here](https://github.com/repotag/cutting_edge/blob/main/heroku/HEROKU_HOWTO.md) for instructions.

### As a gem

Expand Down Expand Up @@ -105,7 +108,7 @@ When your instance of CuttingEdge is running, you can visit the landing page by

An instance on Heroku will be accessible through:

`https://your-app-name.herokuapp.com/`
`https://your-app-name.onrender.com/`

### projects.yml

Expand Down Expand Up @@ -231,7 +234,7 @@ module CuttingEdge
end
```

This approach is especially useful on Heroku, where you can use [Heroku config variables](https://devcenter.heroku.com/articles/config-vars).
This approach is especially useful on services like Render.com, where you can use [environment variables](https://render.com/docs/environment-variables).

**NB: When adding repositories in config.rb, you must explicitly set the email attribute (or else email will be considered disabled for the repo).**

Expand Down Expand Up @@ -303,7 +306,7 @@ end

See the [Moneta](https://github.com/moneta-rb/moneta) instructions.

Note that Heroku offers a free [Redis Add-on](https://elements.heroku.com/addons/heroku-redis).
Note that the default [configuration for Render](#Deploying-on-Render) includes use of a free Redis instance.

## Contributing

Expand Down
24 changes: 24 additions & 0 deletions heroku/HEROKU_HOWTO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# How to Deploy CuttingEdge on Heroku

**Note: on Heroku, CuttingEdge uses `heroku.config.rb` instead of `config.rb`**.

**Note: if you will be using a public GitHub or GitLab repo to host your CuttingEdge configuration, make sure not to put any secrets in `heroku.config.rb` or `projects.yaml`.** Instead, use [environment variables](https://render.com/docs/environment-variables) (for instance to [set authentication tokens](https://github.com/repotag/cutting_edge/blob/main/README.md#Authorization-and-private-repositories)).

Steps:

1. Fork and clone this repository locally
1. Move `Procfile` from the `heroku` subdirectory into the repository root and commit.
1. Move the sample `heroku.config.rb` from the `heroku` subdirectory into the repository.
1. Edit `heroku.config.rb` to suit your needs and commit.
1. Edit `projects.yml` to suit your needs and commit it to the repo.
1. `gem install bundler && bundle install`
2. `git add Gemfile.lock && git commit -m "Commit Gemfile.lock for use on Heroku"
3. `heroku create my-cuttingedge`
4. `heroku config:add HEROKU_APP_NAME=my-cuttingedge`
5. `heroku addons:create heroku-redis:hobby-dev -a my-cuttingedge` (using Redis is highly recommended on Heroku)
6. `git push heroku master`
7. *Optional, if you want to receive [email notifications](#Email-Notifications)*:
* `heroku addons:create mailgun:starter`
* `heroku config:add CUTTING_EDGE_MAIL_TO=mydependencies@mydependencymonitoring.com`

You may also want to set some [Heroku config variables](https://devcenter.heroku.com/articles/config-vars), for instance to [use authentication tokens](#Authorization-and-private-repositories) in `heroku.config.rb`.
File renamed without changes.
File renamed without changes.
34 changes: 34 additions & 0 deletions render.config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Example settings for deployment on render.com

module CuttingEdge
SERVER_HOST = "#{ENV['RENDER_EXTERNAL_HOSTNAME']}" # At what domain is this CuttingEdge instance running?
SERVER_URL = "https://#{SERVER_HOST}"

if ENV['REDIS_HOST'] # If redis is defined in your render.yaml, this will automatically use it.
require 'moneta'
require 'openssl'
redis_url = "redis://#{ENV['REDIS_HOST']}"
redis_url = "#{redis_url}:#{ENV['REDIS_PORT']}" if ENV['REDIS_PORT']
STORE = ::Moneta.new(:Redis,
url: redis_url,
ssl_params: {
verify_mode: OpenSSL::SSL::VERIFY_NONE
}
)
end

# Your additional configuration goes here.
# See for options: https://github.com/repotag/cutting_edge/blob/main/config.rb
# If you are going to host the repository containing this file publically (e.g. on GitHub), please read:
# https://github.com/repotag/cutting_edge/blob/master/README.md#Defining-repositories-in-configrb
end

# Needed to write to Render logs.
::SemanticLogger.add_appender(io: $stderr)

# Configure mail server settings if desired:

# require 'mail'
# Mail.defaults do
# delivery_method :smtp, address: '', port: 587, user_name: '', password: '', enable_ssl: true, domain: 'my-cuttingedge.render.com'
# end
28 changes: 28 additions & 0 deletions render.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Blueprint for use with render.com: https://render.com/docs/blueprint-spec
# Update name below: the instance will be deployed to https://$name.onrender.com
# Modify projects.yml and render.config.rb in your repo, or add them as secret files via the render.com Dashboard

services:
- type: web
env: ruby
name: my-cuttingedge
buildCommand: bundle install
startCommand: bundle exec cutting_edge -p $PORT --config render.config.rb
plan: free
envVars:
- key: PORT
value: 4567
- key: REDIS_HOST
fromService:
type: redis
name: ce-redis
property: host
- key: REDIS_PORT
fromService:
type: redis
name: ce-redis
property: port
- type: redis
name: ce-redis
ipAllowList: []
plan: free

0 comments on commit 6cc0839

Please sign in to comment.