-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 439769b
Showing
47 changed files
with
18,075 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,131 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
env: | ||
BUILD_CACHE: /home/runner/.docker/buildkit | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
env: | ||
IMAGE_NAME: ghcr.io/${{ github.repository }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
path: backend | ||
|
||
- uses: actions/checkout@v2 | ||
with: | ||
repository: 'bitclout/core' | ||
path: core | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: ${{ env.BUILD_CACHE }} | ||
key: ${{ runner.os }}-buildkit-v3-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildkit-v3- | ||
- name: Install the latest buildkit release | ||
run: | | ||
BUILDKIT_URL="$(curl -sL https://api.github.com/repos/moby/buildkit/releases \ | ||
| jq -r 'map(select(.name|startswith("v")))|sort_by(.name)[-1].assets[]|select(.name|endswith(".linux-amd64.tar.gz")).browser_download_url')" | ||
curl -L "${BUILDKIT_URL}" | sudo tar -xz -C /usr/local | ||
- name: Start buildkit daemon | ||
run: | | ||
sudo --non-interactive --shell <<END_SUDO | ||
install -d -m 0750 -o root -g docker /run/buildkit | ||
buildkitd & | ||
while ! test -S /run/buildkit/buildkitd.sock; do sleep 0.1; done | ||
chgrp docker /run/buildkit/buildkitd.sock | ||
END_SUDO | ||
- uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Build docker image | ||
run: | | ||
cd backend | ||
buildctl build \ | ||
--frontend=dockerfile.v0 --local dockerfile=. --local context=.. \ | ||
--export-cache type=local,dest=${{ env.BUILD_CACHE }},mode=max \ | ||
--import-cache type=local,src=${{ env.BUILD_CACHE }} \ | ||
--output type=docker,name=${{ env.IMAGE_NAME }} | docker load | ||
echo "Cache size: $(du -sh ${{ env.BUILD_CACHE }})" | ||
- name: Tag stable | ||
if: contains(github.event.head_commit.message, '[stable]') | ||
run: | | ||
docker tag ${{ env.IMAGE_NAME }} ${{ env.IMAGE_NAME }}:stable | ||
- name: Tag and push | ||
if: ${{ github.ref == 'refs/heads/main' }} | ||
run: | | ||
docker tag ${{ env.IMAGE_NAME }} ${{ env.IMAGE_NAME }}:${{ github.sha }} | ||
docker push --all-tags ${{ env.IMAGE_NAME }} | ||
test: | ||
runs-on: ubuntu-latest | ||
env: | ||
IMAGE_NAME: ghcr.io/${{ github.repository }}-test | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
path: backend | ||
|
||
- uses: actions/checkout@v2 | ||
with: | ||
repository: 'bitclout/core' | ||
path: core | ||
|
||
- uses: actions/cache@v2 | ||
with: | ||
path: ${{ env.BUILD_CACHE }} | ||
key: ${{ runner.os }}-buildkit-test-v2-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildkit-test-v2- | ||
- name: Install the latest buildkit release | ||
run: | | ||
BUILDKIT_URL="$(curl -sL https://api.github.com/repos/moby/buildkit/releases \ | ||
| jq -r 'map(select(.name|startswith("v")))|sort_by(.name)[-1].assets[]|select(.name|endswith(".linux-amd64.tar.gz")).browser_download_url')" | ||
curl -L "${BUILDKIT_URL}" | sudo tar -xz -C /usr/local | ||
- name: Start buildkit daemon | ||
run: | | ||
sudo --non-interactive --shell <<END_SUDO | ||
install -d -m 0750 -o root -g docker /run/buildkit | ||
buildkitd & | ||
while ! test -S /run/buildkit/buildkitd.sock; do sleep 0.1; done | ||
chgrp docker /run/buildkit/buildkitd.sock | ||
END_SUDO | ||
- name: Build docker image | ||
run: | | ||
cd backend | ||
buildctl build \ | ||
--frontend=dockerfile.v0 --local dockerfile=. --local context=.. --opt filename=./test.Dockerfile \ | ||
--export-cache type=local,dest=${{ env.BUILD_CACHE }},mode=max \ | ||
--import-cache type=local,src=${{ env.BUILD_CACHE }} \ | ||
--output type=docker,name=${{ env.IMAGE_NAME }} | docker load | ||
echo "Cache size: $(du -sh ${{ env.BUILD_CACHE }})" | ||
- name: Run tests | ||
run: | | ||
docker run ${{ env.IMAGE_NAME }} |
Empty file.
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,38 @@ | ||
FROM alpine:edge AS backend | ||
|
||
RUN apk update | ||
RUN apk upgrade | ||
RUN apk add --update go=1.16.4-r0 gcc g++ vips-dev | ||
|
||
WORKDIR /bitclout/src | ||
|
||
COPY backend/go.mod backend/ | ||
COPY backend/go.sum backend/ | ||
COPY core/go.mod core/ | ||
COPY core/go.sum core/ | ||
COPY core/third_party/ core/third_party/ | ||
|
||
WORKDIR /bitclout/src/backend | ||
|
||
RUN go mod download | ||
|
||
# include backend src | ||
COPY backend/cmd cmd | ||
COPY backend/miner miner | ||
COPY backend/routes routes | ||
COPY backend/main.go . | ||
|
||
# include core src | ||
COPY core/clouthash ../core/clouthash | ||
COPY core/cmd ../core/cmd | ||
COPY core/lib ../core/lib | ||
|
||
# build backend | ||
RUN GOOS=linux go build -mod=mod -a -installsuffix cgo -o bin/backend main.go | ||
|
||
# create tiny image | ||
FROM alpine:edge | ||
|
||
RUN apk add --update vips-dev | ||
|
||
COPY --from=backend /bitclout/src/backend/bin/backend /bitclout/bin/backend |
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,16 @@ | ||
![BitClout Logo](https://bitclout.com/assets/img/camelcase_logo.svg) | ||
|
||
# About BitClout | ||
BitClout is a blockchain built from the ground up to support a fully-featured | ||
social network. Its architecture is similar to Bitcoin, only it supports complex | ||
social network data like profiles, posts, follows, creator coin transactions, and | ||
more. | ||
|
||
[Read about the vision](https://docs.bitclout.com/the-vision) | ||
|
||
# About This Repo | ||
Documentation for this repo lives on docs.bitclout.com. Specifically, the following | ||
docs should give you everything you need to get started: | ||
* [BitClout Code Walkthrough](https://FIXME) | ||
* [Setting Up Your Dev Environment](https://FIXME) | ||
* [Making Your First Changes](https://FIXME) |
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,103 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
coreCmd "github.com/bitclout/core/cmd" | ||
"github.com/spf13/viper" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
type Config struct { | ||
// Core | ||
TXIndex bool | ||
APIPort uint16 | ||
|
||
// Onboarding | ||
StarterBitcloutSeed string | ||
StarterBitcloutNanos uint64 | ||
StarterPrefixNanosMap map[string]uint64 | ||
TwilioAccountSID string | ||
TwilioAuthToken string | ||
TwilioVerifyServiceID string | ||
CompProfileCreation bool | ||
MinSatoshisForProfile uint64 | ||
|
||
// Global State | ||
GlobalStateRemoteNode string | ||
GlobalStateRemoteSecret string | ||
|
||
// Web Security | ||
AccessControlAllowOrigins []string | ||
SecureHeaderDevelopment bool | ||
SecureHeaderAllowHosts []string | ||
|
||
// Analytics + Profiling | ||
AmplitudeKey string | ||
AmplitudeDomain string | ||
DatadogProfiler bool | ||
|
||
// User Interface | ||
SupportEmail string | ||
ShowProcessingSpinners bool | ||
|
||
// Images | ||
GCPCredentialsPath string | ||
GCPBucketName string | ||
} | ||
|
||
func LoadConfig(coreConfig *coreCmd.Config) *Config { | ||
config := Config{} | ||
|
||
// Core | ||
config.TXIndex = viper.GetBool("txindex") | ||
config.APIPort = uint16(viper.GetUint64("api-port")) | ||
if config.APIPort <= 0 { | ||
// TODO: pull this out of core. we shouldn't need core's config here | ||
config.APIPort = coreConfig.Params.DefaultJSONPort | ||
} | ||
|
||
// Onboarding | ||
config.StarterBitcloutSeed = viper.GetString("starter-bitclout-seed") | ||
config.StarterBitcloutNanos = viper.GetUint64("starter-bitclout-nanos") | ||
starterPrefixNanosMap := viper.GetString("starter-prefix-nanos-map") | ||
if len(starterPrefixNanosMap) > 0 { | ||
config.StarterPrefixNanosMap = make(map[string]uint64) | ||
for _, pair := range strings.Split(starterPrefixNanosMap, ",") { | ||
entry := strings.Split(pair, "=") | ||
nanos, err := strconv.Atoi(entry[1]) | ||
if err != nil { | ||
fmt.Printf("invalid nanos: %s", entry[1]) | ||
} | ||
config.StarterPrefixNanosMap[entry[0]] = uint64(nanos) | ||
} | ||
} | ||
config.TwilioAccountSID = viper.GetString("twilio-account-sid") | ||
config.TwilioAuthToken = viper.GetString("twilio-auth-token") | ||
config.TwilioVerifyServiceID = viper.GetString("twilio-verify-service-id") | ||
config.CompProfileCreation = viper.GetBool("comp-profile-creation") | ||
config.MinSatoshisForProfile = viper.GetUint64("min-satoshis-for-profile") | ||
|
||
// Global State | ||
config.GlobalStateRemoteNode = viper.GetString("global-state-remote-node") | ||
config.GlobalStateRemoteSecret = viper.GetString("global-state-remote-secret") | ||
|
||
// Web Security | ||
config.AccessControlAllowOrigins = viper.GetStringSlice("access-control-allow-origins") | ||
config.SecureHeaderDevelopment = viper.GetBool("secure-header-development") | ||
config.SecureHeaderAllowHosts = viper.GetStringSlice("secure-header-allow-hosts") | ||
|
||
// Analytics + Profiling | ||
config.AmplitudeKey = viper.GetString("amplitude-key") | ||
config.AmplitudeDomain = viper.GetString("amplitude-domain") | ||
|
||
// User Interface | ||
config.SupportEmail = viper.GetString("support-email") | ||
config.ShowProcessingSpinners = viper.GetBool("show-processing-spinners") | ||
|
||
// Images | ||
config.GCPCredentialsPath = viper.GetString("gcp-credentials-path") | ||
config.GCPBucketName = viper.GetString("gcp-bucket-name") | ||
|
||
return &config | ||
} |
Oops, something went wrong.