Skip to content

Commit

Permalink
chore: initial Tiltfile
Browse files Browse the repository at this point in the history
  • Loading branch information
bodymindarts committed Oct 23, 2023
1 parent ca3c8b0 commit 4cdb27b
Show file tree
Hide file tree
Showing 15 changed files with 318 additions and 5 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/tilt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "Tilt CI"
on:
pull_request:
branches: [ main ]
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Tilt CI
run: nix develop -c bash -c "cd dev && tilt ci"
Empty file added dev/.env
Empty file.
29 changes: 24 additions & 5 deletions dev/Tiltfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
api_target = "//core/api:api"
docker_compose("./docker-compose.deps.yml", ".env","galoy-dev")

groups = {
"bitcoin": [
"bitcoind",
"bitcoind-signer",
"postgres-bria",
"fulcrum",
"bria",
],
"tracing": [
"otel-agent",
],
}
for service in groups["bitcoin"]:
dc_resource(service, labels = ["bitcoin"])

local_resource(
"api",
labels = ["frontend"],
cmd = "buck2 build {}".format(api_target),
serve_cmd = "buck2 run {}".format(api_target),
name='init-onchain',
labels = ['bitcoin'],
cmd='bin/init-onchain.sh',
resource_deps = [
"bitcoind",
"bria",
]
)
15 changes: 15 additions & 0 deletions dev/bin/helpers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

COMPOSE_PROJECT_NAME="${COMPOSE_PROJECT_NAME:-quickstart}"

bitcoin_cli() {
docker exec "${COMPOSE_PROJECT_NAME}-bitcoind-1" bitcoin-cli "$@"
}

bitcoin_signer_cli() {
docker exec "${COMPOSE_PROJECT_NAME}-bitcoind-signer-1" bitcoin-cli "$@"
}

bria_cli() {
docker exec "${COMPOSE_PROJECT_NAME}-bria-1" bria "$@"
}
24 changes: 24 additions & 0 deletions dev/bin/init-onchain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -e

DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
source "${DIR}/helpers.sh"

echo "Seeding some regtest blocks..."

bitcoin_cli createwallet "outside" || true
bitcoin_cli -generate 200 > /dev/null 2>&1

bitcoin_signer_cli createwallet "dev" || true
bitcoin_signer_cli -rpcwallet=dev importdescriptors "$(cat ./config/bitcoind/bitcoind_signer_descriptors.json)"

echo "Checking that bria is running..."

for _ in {1..20}; do
bria_cli wallet-balance -w dev-wallet && break
sleep 1
done
bria_cli wallet-balance -w dev-wallet || exit 1

echo "DONE"
19 changes: 19 additions & 0 deletions dev/config/bitcoind/bitcoin.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
rpcuser=rpcuser
rpcpassword=rpcpassword
debug=mempool
debug=rpc
server=1
txindex=1
printtoconsole=1
zmqpubrawtx=tcp://0.0.0.0:28333
zmqpubrawblock=tcp://0.0.0.0:28332
blockfilterindex=1
bind=0.0.0.0
fallbackfee=0.0002
rpcallowip=0.0.0.0/0
regtest=1
[regtest]
bind=0.0.0.0
fallbackfee=0.0002
rpcallowip=0.0.0.0/0
rpcbind=0.0.0.0
1 change: 1 addition & 0 deletions dev/config/bitcoind/bitcoind_signer_descriptors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"active":true,"desc":"wpkh([6f2fa1b2/84'/0'/0']tprv8gXB88g1VCScmqPp8WcetpJPRxix24fRJJ6FniYCcCUEFMREDrCfwd34zWXPiY5MW2xp8e1Z6EeBrh74zMSgfQQmTorWtE1zyBtv7yxdcoa/0/*)#88k4937c","timestamp":0},{"active":true,"desc":"wpkh([6f2fa1b2/84'/0'/0']tprv8gXB88g1VCScmqPp8WcetpJPRxix24fRJJ6FniYCcCUEFMREDrCfwd34zWXPiY5MW2xp8e1Z6EeBrh74zMSgfQQmTorWtE1zyBtv7yxdcoa/1/*)#knn5cywq","internal":true,"timestamp":0}]
8 changes: 8 additions & 0 deletions dev/config/bria.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
app:
blockchain:
network: regtest
electrum_url: fulcrum:50001
tracing:
host: "otel-agent"
port: 4318
service_name: "bria-dev"
7 changes: 7 additions & 0 deletions dev/config/fulcrum/fulcrum.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bitcoind = bitcoind:18443
rpcuser = rpcuser
rpcpassword = rpcpassword
peering = false
announce = false
tcp = 0.0.0.0:50001
ssl = 0.0.0.0:50002
19 changes: 19 additions & 0 deletions dev/config/fulcrum/tls.cert
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-----BEGIN CERTIFICATE-----
MIIDBTCCAe2gAwIBAgIUKCSR4otDtA4+ow5z5zL9zc1CI10wDQYJKoZIhvcNAQEL
BQAwEjEQMA4GA1UECgwHRnVsY3J1bTAeFw0yMjExMjkxMDUzNDFaFw0zMjExMjYx
MDUzNDFaMBIxEDAOBgNVBAoMB0Z1bGNydW0wggEiMA0GCSqGSIb3DQEBAQUAA4IB
DwAwggEKAoIBAQDasNdsbz47BDEjzKLeG4RxOqMikrBY6fQd0+8pt8Fh/qSaF2lG
NpLbADDcszyddb0GD5tYQe7YBIyrexp9Q1gvejj1zuagXwlSYfrSkiDB3nBYreSl
wq4i87VjCMX5Fr270S3mHfptg5zbPgQvvTvnD0Y7Ur9lriNydWp9Qz6TLWWYVhui
yxLrtsxv6hRDndlkIxDbZt9kr6yzLroBtXFEFSCeROb1sE2ouVXC89eAlcpvWZF6
MMnlAkECRS5m3QtKyYtTQ0FTGBrAN2xUnirR9z+wpAOu3S/AjEt4AC1ome75tiJv
rtCIaf438QhNerb/sQmyHXIpjw6KZxADKS3RAgMBAAGjUzBRMB0GA1UdDgQWBBS0
xHEskJjxCg8F1YYT0NkzBVFsTDAfBgNVHSMEGDAWgBS0xHEskJjxCg8F1YYT0Nkz
BVFsTDAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCwxhxRCfa1
DXfFP+BM9OwDldNC9B66d/6hueaY26YJxcLvuKcAm+0MwciNFnWhb9yiY2wnWaZ6
zA6VKuxCrVU7egg5gG2+lZYjAiQOkFtVNHGEIjVTow4GJAkJGjH/B9J2teHKR1a6
XDJ5xKLAIM7hnKVjIM7cA/Y3Q/AsR/uzp4GOccqHX3g/AKKLFahLCkVv5CeIrl+y
kPv/3jXbP71iJPhG2j74EVPLeQ0qKAb03vz2Y2HaSBripGQEwnx7MoQnbRhYx00Y
+LG1WGYeNOEXfT8trewl+gfsoLenlDTLukIfjjvQ5dRDA9pD1ij+1+jz/XCyQ7w5
LzhYnJBwIGpt
-----END CERTIFICATE-----
28 changes: 28 additions & 0 deletions dev/config/fulcrum/tls.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDasNdsbz47BDEj
zKLeG4RxOqMikrBY6fQd0+8pt8Fh/qSaF2lGNpLbADDcszyddb0GD5tYQe7YBIyr
exp9Q1gvejj1zuagXwlSYfrSkiDB3nBYreSlwq4i87VjCMX5Fr270S3mHfptg5zb
PgQvvTvnD0Y7Ur9lriNydWp9Qz6TLWWYVhuiyxLrtsxv6hRDndlkIxDbZt9kr6yz
LroBtXFEFSCeROb1sE2ouVXC89eAlcpvWZF6MMnlAkECRS5m3QtKyYtTQ0FTGBrA
N2xUnirR9z+wpAOu3S/AjEt4AC1ome75tiJvrtCIaf438QhNerb/sQmyHXIpjw6K
ZxADKS3RAgMBAAECggEBAJB5g9f/Jf2XJ1+fMXnKdBTZyCxu/FHBPaT2/mlxHDDB
Kb0i+kmIhDxqQ92KC+F6hwYaCWalKEVNvCENktJuSzQSas75gSMxpdbnI+043Ks3
aMEtIIDhvGka2Bo1EZUdkPsjlk8QPwFakaXFsr5XJdvgG2XVpNxnzsMvDsryQcS4
X+foFXRFPWjTvof9v68WyeIUWVKumVA/285TmS6jMqsYkDHKxg25CiBr95WJKsSo
+o1sBmj9DvJXGxwo47MGX65dZxU4PVTBA9ABq3kA9SnOpzr0Tz27eJl8Er6zOENy
9JmijNLDTuPRwxqDMjW/He5NHz13vnXf5FasGWhfuIECgYEA+isl7jPFDAybPH1b
dL0d8NEwl8CloZ9a0AmsQZ8BGi6gn/uQAtNfZk2Q9vFMulBmppMnYTDrYh7KwZ8u
UjiSg3QIKZgixtZQelDxAv5G8VpR20DeQwn4pxBgvo0WeGKlxV2WdbouwhW1OBoj
fRnTHfzxCkqsS6B+mff8awsKfv8CgYEA38naezhfm4G54wkYUnD8cx4GvuGRHHoR
DcXMyPm2+zub4sYeVDCzh6eoIkNc8TW+YEZNsiYOxYfuYiKLmlw1m2TeZKXwf7Vc
9OkX5Is+7ARlJlG27xU4OLfOMrIdaibPUFLDTWknTryu3hLKoWGHsbfB/7hJoUBq
7np6odIhIy8CgYBgzuu5txzsocA880G99iUs+La2Mt2lorYQxX18U1yo1hxgbIf5
H/TN8PxFI3GOs+hVU6KskLK14LaToNbbCHtiFTfHaNEkYvD3tHTftKidY1dD4mFg
Te6EL+lQM+bbJUmDC8lau3a2spHTKQJMuf6hny1jzyvHhE8ZpAZxIe+o3wKBgQCt
y0UxjIYzbnu+JcINxFFJ1XfHpcXcJ7A20fZH3iaM1a4qX1IOcAP8xed9NHNpoCNJ
AVA1mfi+zuICtHFWX2YCWEOeRoCPrXmTebJkev9Sq9ch+zPmWMRgx94K4OiXF6zI
5H1oENHGBCKJtG5JBkUrb1nqDmSgJjblHZk/MsEpYQKBgBoI4QpQ0yhn812H0BJV
T1t0SM9+bkJC40ogme0R5/gUz8aDe+A2WHN/HH+q6QKLvkLxBCH8y7RufoKSN2XB
IqtTRZQX/yQyY/AZB7Rse29fmomDGa3/xj1LK33zhYqwMgDmisymu3XER6EwGRV6
RTv9SXp8+92eNOwSJ63hEZV9
-----END PRIVATE KEY-----
68 changes: 68 additions & 0 deletions dev/config/otel-agent-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
receivers:
jaeger:
protocols:
thrift_compact: # on port 6831
thrift_binary: # on port 6832
otlp:
protocols:
http: # on port 4318

processors:
filter/ottl:
error_mode: ignore
traces:
span:
- 'resource.attributes["service.name"] == "stablesats-dev"'
- 'resource.attributes["service.name"] == "bria-dev"'
- 'name == "grpc.lnrpc.State/GetState"'
- 'name == "app.prices.getCurrentSatPrice"'
- 'name == "app.prices.getCurrentUsdCentPrice"'
- 'name == "grpc.PriceFeed/GetPrice"'
- 'name == "grpc.PriceFeed/ListCurrencies"'
- 'name == "services.cache.local.set"'
- 'name == "services.cache.local.get"'
- 'name == "app.prices.listCurrencies"'
- 'name == "services.cache.local.getOrSet"'
batch:
attributes:
actions:
- key: graphql.variables.input.code
action: update
value: "<redacted>"
- key: code.function.params.code
action: update
value: "<redacted>"
- key: code.function.params.authToken
action: update
value: "<redacted>"
- key: code.function.params.totpCode
action: update
value: "<redacted>"
- key: graphql.variables.input.totpCode
action: update
value: "<redacted>"
- key: graphql.variables.input.authToken
action: update
value: "<redacted>"

exporters:
logging:
loglevel: debug
otlp:
endpoint: "api.honeycomb.io:443"
headers:
"x-honeycomb-team": ${HONEYCOMB_API_KEY}
"x-honeycomb-dataset": ${HONEYCOMB_DATASET}

extensions:
health_check:
pprof:
zpages:

service:
extensions: [health_check, pprof, zpages]
pipelines:
traces:
receivers: [jaeger, otlp]
processors: [filter/ottl, attributes, batch]
exporters: [otlp, logging]
89 changes: 89 additions & 0 deletions dev/docker-compose.deps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
version: "3"
services:
mongodb:
image: mongo:7.0.2
ports:
- "27017:27017"
environment:
- MONGO_INITDB_DATABASE=galoy
bria:
image: us.gcr.io/galoy-org/bria:latest
ports:
- "2743:2743"
- "2742:2742"
environment:
- PG_CON=postgres://user:password@postgres-bria:5432/pg
- BITCOIND_SIGNER_ENDPOINT=https://bitcoind-signer:18443
command:
- bria
- daemon
- --config
- /bria.yml
- dev
- -x
- tpubDDDDGYiFda8HfJRc2AHFJDxVzzEtBPrKsbh35EaW2UGd5qfzrF2G87ewAgeeRyHEz4iB3kvhAYW1sH6dpLepTkFUzAktumBN8AXeXWE9nd1
- -d
- m/84h/0h/0h
volumes:
- ${HOST_PROJECT_PATH:-.}/config/bria.yml:/bria.yml
depends_on:
bitcoind-signer:
condition: service_started
otel-agent:
condition: service_started
fulcrum:
condition: service_started
postgres-bria:
condition: service_healthy
postgres-bria:
image: postgres:14.1
environment:
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
- POSTGRES_DB=pg
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 5s
timeout: 30s
retries: 5
fulcrum:
image: cculianu/fulcrum:latest
ports:
- "50001:50001"
depends_on: [bitcoind]
volumes:
- ${HOST_PROJECT_PATH:-.}/config/fulcrum/fulcrum.conf:/fulcrum.conf
- ${HOST_PROJECT_PATH:-.}/config/fulcrum/tls.key:/tls.key
- ${HOST_PROJECT_PATH:-.}/config/fulcrum/tls.cert:/tls.cert
environment:
- DATA_DIR=/db
- SSL_CERTFILE=/tls.cert
- SSL_KEYFILE=/tls.key
command: ["Fulcrum", "/fulcrum.conf"]
bitcoind:
image: lncm/bitcoind:v24.0.1
ports:
- "18443:18443"
volumes:
- ${HOST_PROJECT_PATH:-.}/config/bitcoind/bitcoin.conf:/data/.bitcoin/bitcoin.conf
bitcoind-signer:
image: lncm/bitcoind:v24.0.1
ports: []
volumes:
- ${HOST_PROJECT_PATH:-.}/config/bitcoind/bitcoin.conf:/data/.bitcoin/bitcoin.conf
depends_on: [bitcoind]
entrypoint: ["/bin/sh", "-c"]
command:
- |
bitcoind -connect=bitcoind:18444
otel-agent:
ports:
- "4318:4318" #! http receiver
image: otel/opentelemetry-collector-contrib:0.84.0
command: ["--config=/etc/otel-agent-config.yaml"]
environment:
- HONEYCOMB_DATASET=${HONEYCOMB_DATASET}
- HONEYCOMB_API_KEY=${HONEYCOMB_API_KEY}
volumes:
- ${HOST_PROJECT_PATH:-.}/config/otel-agent-config.yaml:/etc/otel-agent-config.yaml
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
devShells.default = mkShell {
inherit nativeBuildInputs;
BUCK2_VERSION = buck2Version;
COMPOSE_PROJECT_NAME = "galoy-dev";
};

formatter = alejandra;
Expand Down
1 change: 1 addition & 0 deletions typos.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
files.extend-exclude = [
"dev",
"core/api/dev",
"core/api/src/domain/users/languages.ts",
"core/api/src/services/loopd/protos",
Expand Down

0 comments on commit 4cdb27b

Please sign in to comment.