Skip to content

A collection of go projects for building on Bitcoin SV

License

Notifications You must be signed in to change notification settings

BitcoinSchema/gobitcoinsv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

A collection of Go projects for building on BitcoinSV

last commit Release Mergify Status app health
standard-readme compliant Sponsor Donate


GoBitcoinSV


Table of Contents


Installation

Install the web application

make install

View the site: open /public/index.html in a web browser


Deployment & Hosting

This repository has CI integration using AWS CodePipeline.

The build in AWS will deploy to firebase.

The actual build process can be found in the buildspec.yml file.

The application relies on AWS Secrets Manager and AWS SSM to store environment variables. Sensitive environment variables are encrypted using AWS KMS and then decrypted at runtime.

Deploy different environments by changing the <stage> to production or development as example. The default stage is production if it's not specified.

Firebase Hosting Setup
  1. Start a new project and assign a CNAME
  2. Make sure the region is us-central
  3. Generate a CI firebase_token using the command: firebase login:ci
Create Environment Encryption Key(s) (AWS)

Create a KMS Key per <stage> for your application(s) to encrypt environment variables

make create-env-key stage="<stage>"

This will also store the kms_key_id in SSM located at: /<application>/<stage>/kms_key_id

Manage Environment Variables (AWS)

Add or update your project information (all parameters are required)

make firebase-save-project \
      app_id="YOUR_APP_ID" \
      project="YOUR_PROJECT_ID" \
      sender_id="YOUR_SENDER_ID" \
      stage="<stage>"
Manage Environment Secrets (AWS)
  • firebase_api_key is found in the Firebase console for that specific project
  • firebase_token is the ci:login token that is generated from firebase login:ci
  • github_token is a personal token with access to make a webhook
  • kms_key_id is from the previous step (Create Environment Encryption Keys)

Add or update your secrets (all parameters are required)

make save-secrets \
      firebase_api_key="YOUR_FIREBASE_API_KEY" \
      firebase_token="YOUR_FIREBASE_CI_TOKEN" \
      github_token="YOUR_GITHUB_TOKEN" \
      kms_key_id="YOUR_KMS_KEY_ID" \
      stage="<stage>"
Create CI Environment (AWS)
infrastructure diagram

Prerequisites

This will create a new AWS CloudFormation stack with:

NOTE: Requires an existing S3 bucket for artifacts and sam-cli deployments (located in the Makefile)

One command will build, test, package and deploy the application to AWS. After initial deployment, updating is as simple as committing to Github.

make deploy

(Example) Customized deployment for another stage

make deploy stage="development" branch="development"

(Example) Customized deployment for a feature branch

make deploy stage="development" branch="some-feature" feature="some-feature"

(Example) Customized S3 bucket location

make deploy bucket="some-S3-bucket-location"

(Example) Customized tags for the deployment

make deploy tags="MyTag=some-value AnotherTag=some-value"
Tear Down CI Environment (AWS)

Remove the stack (using default stage: staging)

make teardown

(Example) Teardown another stack via stage

make teardown stage="development"

(Example) Teardown a feature/branch stack

make teardown stage="development" feature="some-feature"

Documentation

No documentation at this time. View the source code of the website.

Release Deployment

goreleaser for easy binary or library deployment to Github and can be installed via: brew install goreleaser.

The .goreleaser.yml file is used to configure goreleaser.

Use make release-snap to create a snapshot version of the release, and finally make release to ship to production.

Makefile Commands

View all makefile commands

make help

List of all current commands:

audit                         Checks for any packages that are vulnerable
aws-param-certificate         Returns the ssm location for the domain ssl certificate id
aws-param-zone                Returns the ssm location for the host zone id
clean                         Remove previous builds, cache or install modules
create-env-key                Creates a new key in KMS for a new stage
create-secret                 Creates an secret into AWS SecretsManager
decrypt                       Decrypts data using a KMY Key ID (awscli v2)
decrypt-deprecated            Decrypts data using a KMY Key ID (awscli v1)
deploy                        Build, prepare and deploy
encrypt                       Encrypts data using a KMY Key ID (awscli v2)
env-key-location              Returns the environment encryption key location
firebase-deploy-simple        Deploys to firebase with limited flags
firebase-get-env              Gets the current environment variables in the associated project
firebase-param-app-id         Returns the location of the app_id parameter in SSM
firebase-param-location       Creates a parameter location (for Firebase details in SSM)
firebase-param-project        Returns the location of the project-id parameter in SSM
firebase-param-sender-id      Returns the location of the sender_id parameter in SSM
firebase-save-project         Saves the firebase project information for use by CloudFormation
firebase-set-env              Set an environment variable in a firebase project
firebase-update               Update the firebase tools
help                          Show this help message
install                       Install the application
invalidate-cache              Invalidates a cloudfront cache based on path
lint                          Run the JS linter
outdated                      Checks for any outdated packages
package                       Process the CF template and prepare for deployment
reinstall                     Removes all files and re-installs from scratch
release                       Full production release (creates release in Github)
release-snap                  Test the full release (build binaries)
release-test                  Full production test release (everything except deploy)
replace-version               Replaces the version in HTML/JS (pre-deploy)
save-domain-info              Saves the zone id and the ssl id for use by CloudFormation
save-param                    Saves a plain-text string parameter in SSM
save-param-encrypted          Saves an encrypted string value as a parameter in SSM
save-secrets                  Helper for saving sensitive credentials to Secrets Manager
tag                           Generate a new tag and push (tag version=0.0.0)
tag-remove                    Remove a tag if found (tag-remove version=0.0.0)
tag-update                    Update an existing tag to current commit (tag-update version=0.0.0)
teardown                      Deletes the entire stack
update-secret                 Updates an existing secret in AWS SecretsManager
upload-files                  Upload/puts files into S3 bucket

Examples

View the live website


Code Standards

Always use the language's best practices!


Usage

We're using it! Visit the GoBitcoinSV website.


Maintainers

Satchmo MrZ
Satchmo MrZ

Contributing

View the contributing guidelines and follow the code of conduct.

How can I help?

All kinds of contributions are welcome πŸ™Œ! The most basic way to show your support is to star 🌟 the project, or to raise issues πŸ’¬. You can also support this project by becoming a sponsor on GitHub πŸ‘ or by making a bitcoin donation to ensure this journey continues indefinitely! πŸš€

Stars


License

License