A collection of Go projects for building on BitcoinSV
Install the web application
make install
View the site:
open /public/index.html in a web browser
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
- Start a new project and assign a CNAME
- Make sure the region is us-central
- 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)
app_id
is the Firebase application id for the projectproject
is the Firebase project_idsender_id
is the Firebase sender_id for the project
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 projectfirebase_token
is theci:login
token that is generated fromfirebase login:ci
github_token
is a personal token with access to make a webhookkms_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](.github/IMAGES/infrastructure-diagram.png)
Prerequisites
- An AWS account
- Deploying requires permission to: KMS, SSM, Secrets Manager and Cloud Formation
- AWS CLI (
brew install awscli
) - SAM CLI (
brew tap aws/tap && brew install aws-sam-cli
)
This will create a new AWS CloudFormation stack with:
- (1) CodePipeline with multiple stages to deploy the application from Github
- (1) CodePipeline Webhook to receive Github notifications from a specific
branch:name
- (1) CodeBuild Project to build and deploy the app
- (2) Service Roles for working with CodeBuild and CodePipeline
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"
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
View the live website
Always use the language's best practices!
We're using it! Visit the GoBitcoinSV website.
![]() |
![]() |
---|---|
Satchmo | MrZ |
View the contributing guidelines and follow the code of conduct.
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! ๐