Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed Aug 21, 2021
0 parents commit cb03d05
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 0 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: ./start-listmonk.sh
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# listmonk Heroku installer

This repository is a Heroku Buildpack + button installer for [listmonk](https://github.com/knadh/listmonk). It downloads and installs the latest binary release from the listmonk releases page.

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/knadh/listmonk-heroku)

Licensed under the MIT license.
32 changes: 32 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "listmonk",
"description": "Self-hosted newsletter + mailing list manager",
"repository": "https://github.com/knadh/listmonk-heroku",
"logo": "https://listmonk.app/static/images/listmonk.svg",
"website": "https://listmonk.app",
"keywords": ["emails", "newsletter", "mailing-list"],

"buildpacks": [
{
"url": "https://github.com/knadh/listmonk-heroku"
}
],
"addons": ["heroku-postgresql"],

"env": {
"LISTMONK_APP__ADMIN_USERNAME": {
"description": "Admin username",
"value": ""
},
"LISTMONK_APP__ADMIN_PASSWORD": {
"description": "Admin password",
"value": ""
}
},

"scripts": {
"postdeploy": "./install-db.sh"
},

"success_url": "/settings"
}
15 changes: 15 additions & 0 deletions bin/compile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
# bin/compile <build-dir> <cache-dir>

echo "Downloading listmonk"

BUILD_DIR=$1

# Get the URL of the latest Linux release.
URL=$(curl -L -s https://api.github.com/repos/knadh/listmonk/releases/latest | grep -o -E "https://(.*)listmonk_(.*)_linux_amd64.tar.gz")

# Download and extract the release to the build dir.
curl -L -s $URL | tar xvz -C $BUILD_DIR

# Generate the config file.
cd $BUILD_DIR && ./listmonk --new-config
5 changes: 5 additions & 0 deletions bin/detect
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
# bin/detect <build-dir>

echo "Null"
exit 0
4 changes: 4 additions & 0 deletions bin/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

echo "config_vars: {}"

15 changes: 15 additions & 0 deletions env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

# DATABSE_URL and PORT come from Heroku.
# DATABASE_URL="postgres://listmonk:listmonk@localhost:9432/listmonk"
# PORT="9005"

export LISTMONK_APP__ADDRESS="0.0.0.0:$PORT"

# `cut` is used to cut out the separators (:, @, /) that come matched with the groups.
export LISTMONK_DB__HOST=$(echo $DATABASE_URL | grep -oP "postgres://.*@\K(.+?):" | cut -d: -f1)
export LISTMONK_DB__PORT=$(echo $DATABASE_URL | grep -oP "postgres://.*@.*:\K(\d+)/" | cut -d/ -f1)
export LISTMONK_DB__USER=$(echo $DATABASE_URL | grep -oP "postgres://\K(.+?):" | cut -d: -f1)
export LISTMONK_DB__PASSWORD=$(echo $DATABASE_URL | grep -oP "postgres://.*:\K(.+?)@" | cut -d@ -f1)
export LISTMONK_DB__DATABASE=$(echo $DATABASE_URL | grep -oP "postgres://.*@.*:.*/\K(.+?)$")
export LISTMONK_DB__SSL_MODE="require"
7 changes: 7 additions & 0 deletions install-db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

# Source the DB variables from the env.
source ./env.sh

# Setup the listmonk DB.
./listmonk --install --yes
7 changes: 7 additions & 0 deletions start-listmonk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

# Source the DB variables from the env.
source ./env.sh

./listmonk --upgrade --yes
./listmonk

0 comments on commit cb03d05

Please sign in to comment.