forked from getporter/porter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml for bundle to set up discourse (getporter#1182)
* yaml for bundle to set up discourse * Update porter.yaml * add generic porter.yaml to run * delete porter.yaml and edit readme
- Loading branch information
1 parent
28b82cd
commit 22136bf
Showing
6 changed files
with
304 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# See https://docs.docker.com/engine/reference/builder/#dockerignore-file | ||
# Put files here that you don't want copied into your bundle's invocation image | ||
.gitignore | ||
Dockerfile.tmpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Dockerfile | ||
.cnab/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM debian:stretch | ||
|
||
ARG BUNDLE_DIR | ||
|
||
RUN apt-get update && apt-get install -y ca-certificates | ||
|
||
# This is a template Dockerfile for the bundle's invocation image | ||
# You can customize it to use different base images, install tools and copy configuration files. | ||
# | ||
# Porter will use it as a template and append lines to it for the mixins | ||
# and to set the CMD appropriately for the CNAB specification. | ||
# | ||
# Add the following line to porter.yaml to instruct Porter to use this template | ||
# dockerfile: Dockerfile.tmpl | ||
|
||
# You can control where the mixin's Dockerfile lines are inserted into this file by moving "# PORTER_MIXINS" line | ||
# another location in this file. If you remove that line, the mixins generated content is appended to this file. | ||
# PORTER_MIXINS | ||
|
||
# Use the BUNDLE_DIR build argument to copy files into the bundle | ||
COPY . $BUNDLE_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Discourse Example Bundle | ||
This example is a work in progress and not finished. | ||
|
||
## Why Discourse? | ||
[Discourse](https://www.discourse.org/about) is the perfect example bundle because it will illustrate the need for bundling your application and using Porter. Discourse is a platform for discussion with many exciting [features](https://www.discourse.org/features). | ||
|
||
The installation and setup process for Discourse is deceptively simple at first glance. However, it is actually extremely complicated. Although there is a standalone docker image that you can run, there is still a lot of infrastructure that needs to be configured, especially if you wish to use Discourse in production and want to take advantage of all the features that are possible. | ||
|
||
Because of this, you cannot just run the docker image and do a simple install. You will have to go through the complex process in order to set up the infrastructure and customize your Discourse. | ||
|
||
In order to install, first, you need to create a cloud server and access it. Then, you need to install docker and install discourse. To get email working, you will need to set up a mail server and get the credentials. You also need a domain name. | ||
|
||
Then, you will launch a discourse set up tool and answer questions about your hostname, email address, server address, etc. After Discourse is up and running, if an update needs to be made or maintenance is needed, another process is required. | ||
|
||
Additionally, if you want more features such as single-sign-on, plugins, or encryption, those need to be configured as well. Because of all these complex steps that are needed to install Discourse and upgrade it, putting Discourse in a bundle would greatly simplify the process. | ||
|
||
Bundling Discourse would take away the need for individuals installing it to read through all the installation instructions. Users would simply need to enter their credentials and any parameters and Porter would do the work for them. Discourse would be installed with just one command. | ||
|
||
## What bundle should do and look like (parameters and credentials etc) | ||
install: | ||
* cloud server (DigitalOcean, Azure, etc) | ||
- need credentials | ||
* cloud storage for user uploads, pictures (Amazon S3, Azure Blob Storage, etc) | ||
- can set up backups | ||
- need credentials | ||
* email (Mailgun, SendGrid, Mailjet) | ||
- can configure reply via email | ||
- need credentials and email as parameter | ||
* domain name | ||
- hostname parameter | ||
* ssl certificate (Let’s Encrypt free certificate) | ||
- need certificate and key | ||
- have to configure NGINX and a docker container | ||
* Virtual Machine | ||
- need credentials | ||
* postgres database | ||
- need parameters for username, password, database name | ||
* configure SSO | ||
- enable_sso parameter must be enabled | ||
- sso_url: the offsite URL users will be sent to when attempting to log on | ||
- sso_secret: a secret string used to hash SSO payloads | ||
* login via Google, Twitter, GitHub, Facebook | ||
* install plugins | ||
- need plugin's git clone url | ||
- add it to app.yml | ||
- rebuild the container | ||
* multisite configuration with docker | ||
- if you want to host multiple Discourse sites on the same server | ||
* set up webhooks | ||
* enable a CDN | ||
- origin address | ||
- CNAME | ||
- CDN URL | ||
- need to edit DNS map to map CNAME to CDN URL | ||
|
||
upgrade: | ||
- have exec run a script that will do the upgrade (probably run rebuild) | ||
|
||
potential custom actions from launcher: | ||
* start: Start/initialize a container | ||
* stop: Stop a running container | ||
* restart: Restart a container | ||
* destroy: Stop and remove a container | ||
* enter: Use nsenter to get a shell into a container | ||
* logs: View the Docker logs for a container | ||
* bootstrap: Bootstrap a container for the config based on a template | ||
* rebuild: Rebuild a container (destroy old, bootstrap, start new) | ||
* cleanup: Remove all containers that have stopped for > 24 hours | ||
|
||
uninstall: | ||
* delete azure storage account | ||
* delete azure storage container | ||
* delete azure vm | ||
* delete postgres database |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
install() { | ||
echo Hello World | ||
} | ||
|
||
upgrade() { | ||
echo World 2.0 | ||
} | ||
|
||
uninstall() { | ||
echo Goodbye World | ||
} | ||
|
||
# Call the requested function and pass the arguments as-is | ||
"$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
# This is the configuration for Porter | ||
# You must define steps for each action, but the rest is optional | ||
# See https://porter.sh/author-bundles for documentation on how to configure your bundle | ||
# Uncomment out the sections below to take full advantage of what Porter can do! | ||
|
||
name: discourse-azure | ||
version: 0.1.0 | ||
description: "A Porter bundle for Discourse" | ||
# TODO: update the registry to your own, e.g. myregistry/porter-hello:v0.1.0 | ||
tag: getporter/discourse-azure:v0.1.0 | ||
|
||
# Uncomment the line below to use a template Dockerfile for your invocation image | ||
#dockerfile: Dockerfile.tmpl | ||
|
||
mixins: | ||
- az | ||
- exec | ||
|
||
credentials: | ||
- name: sp_client_id | ||
env: AZURE_SP_CLIENT_ID | ||
|
||
- name: sp_password | ||
env: AZURE_SP_PASSWORD | ||
|
||
- name: tenant | ||
env: AZURE_TENANT_ID | ||
|
||
- name: client_secret | ||
env: AZURE_CLIENT_SECRET | ||
|
||
- name: client_id | ||
env: AZURE_CLIENT_ID | ||
|
||
- name: client_secret | ||
env: AZURE_CLIENT_SECRET | ||
|
||
- name: storage_key | ||
env: AZURE_STORAGE_KEY | ||
|
||
- name: storage_connection_string | ||
env: AZURE_STORAGE_CONNECTION_STRING | ||
|
||
parameters: | ||
- name: location | ||
type: string | ||
default: "EastUS" | ||
|
||
- name: resource_group_name | ||
type: string | ||
default: "porter-discourse" | ||
|
||
- name: storage_account_name | ||
type: string | ||
default: "porterstorage" | ||
|
||
- name: storage_container_name | ||
type: string | ||
default: "porterdiscourse" | ||
|
||
- name: database-name | ||
type: string | ||
default: "porter-discourse" | ||
|
||
- name: discourse_hostname | ||
type: string | ||
default: "" | ||
|
||
- name: admin_email | ||
type: string | ||
|
||
- name: SMTP_server_address | ||
type: string | ||
|
||
- name: SMTP_port | ||
type: string | ||
|
||
- name: SMTP_user_name | ||
type: string | ||
|
||
- name: SMTP_password | ||
type: string | ||
|
||
install: | ||
- az: | ||
description: "Azure ClI login" | ||
arguments: | ||
- login | ||
flags: | ||
service-principal: | ||
username: "{{ bundle.credentials.sp_client_id}}" | ||
password: "{{ bundle.credentials.sp_password}}" | ||
tenant: "{{ bundle.credentials.tenant}}" | ||
- az: | ||
description: "Create Azure storage account" | ||
arguments: | ||
- storage | ||
- account | ||
- create | ||
flags: | ||
resource-group: "{{ bundle.parameters.resource_group_name }}" | ||
name: "{{ bundle.parameters.storage_account_name }}" | ||
location: "{{ bundle.parameters.location }}" | ||
- az: | ||
description: "Create Azure storage container" | ||
arguments: | ||
- storage | ||
- container | ||
- create | ||
flags: | ||
resource-group: "{{ bundle.parameters.resource_group_name }}" | ||
name: "{{ bundle.parameters.storage_container_name }}" | ||
account-name: "{{ bundle.parameters.storage_account_name }}" | ||
- az: | ||
description: "Create Postgres database on Azure" | ||
arguments: | ||
- postgres | ||
- db | ||
- create | ||
flags: | ||
resource-group: "{{ bundle.parameters.resource_group_name }}" | ||
name: "{{ bundle.parameters.database-name }}" | ||
server-name: myServer | ||
location: "{{ bundle.parameters.location }}" | ||
# TODO: define an output for the database connection string | ||
- az: | ||
description: "Create Azure VM" | ||
arguments: | ||
- vm | ||
- create | ||
flags: | ||
resource-group: "{{ bundle.parameters.resource_group_name }}" | ||
name: myVM | ||
image: UbuntuLTS | ||
location: "{{ bundle.parameters.location }}" | ||
# TODO: define an output for the IP address of the VM | ||
# TODO: define an output for the root password for the VM | ||
- exec: | ||
description: "Run script to install Discourse" | ||
command: ./installDiscourse.sh | ||
# TODO: pass in arguments from outputs of previous steps - connection string to database, the root password for VM, and the IP address for the VM | ||
# TODO: pass in host name for forum (ex. forum.porter.sh) | ||
# bash script would automate the process of creating the yaml script, injecting the outputs into the script, and kicking off the setup | ||
|
||
upgrade: | ||
- exec: | ||
description: "Run script to upgrade discourse" | ||
command: ./upgradeDiscourse.sh | ||
# bash script will probably run rebuild from launcher | ||
|
||
uninstall: | ||
- az: | ||
description: "Delete Azure storage" | ||
arguments: | ||
- storage | ||
- account | ||
- delete | ||
flags: | ||
resource-group: "{{ bundle.parameters.resource_group_name }}" | ||
name: "{{ bundle.parameters.storage_account_name }}" | ||
- az: | ||
description: "Delete Azure storage container" | ||
arguments: | ||
- storage | ||
- container | ||
- delete | ||
flags: | ||
name: "{{ bundle.parameters.storage_container_name }}" | ||
- az: | ||
description: "Delete VM" | ||
arguments: | ||
- vm | ||
- delete | ||
flags: | ||
resource-group: "{{ bundle.parameters.resource_group_name }}" | ||
name: myVM | ||
- az: | ||
description: "Delete Postgres database" | ||
arguments: | ||
- postgres | ||
- db | ||
- delete | ||
flags: | ||
resource-group: "{{ bundle.parameters.resource_group_name }}" | ||
name: "{{ bundle.parameters.database-name }}" | ||
server-name: myServer |