diff --git a/.envrc b/.envrc index cd576b7a05..864e52a04d 100644 --- a/.envrc +++ b/.envrc @@ -1,3 +1,5 @@ +use flake + export DOCKER_HOST_IP=${DOCKER_HOST_IP:-127.0.0.1} export NETWORK=regtest diff --git a/.github/workflows/quickstart.yml b/.github/workflows/quickstart.yml index daa3fbbaa4..92c109272e 100644 --- a/.github/workflows/quickstart.yml +++ b/.github/workflows/quickstart.yml @@ -13,16 +13,16 @@ jobs: - uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} - - uses: carvel-dev/setup-action@v1 + - uses: cachix/install-nix-action@v22 with: - only: ytt, vendir + github_access_token: ${{ secrets.GITHUB_TOKEN }} - name: Test quickstart run: | cd quickstart - ./bin/bump-galoy-git-ref.sh ${{ github.event.pull_request.head.sha }} - ./bin/bump-galoy-image-digest.sh local - ./bin/bump-mongodb-migrate-image-digest.sh local - make re-render + nix develop -c ./bin/bump-galoy-git-ref.sh ${{ github.event.pull_request.head.sha }} + nix develop -c./bin/bump-galoy-image-digest.sh local + nix develop -c ./bin/bump-mongodb-migrate-image-digest.sh local + nix develop -c make re-render source .envrc docker compose up -d ./bin/quickstart.sh diff --git a/.gitignore b/.gitignore index ec5974ed1e..9ded3adfa9 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,5 @@ generated.gql junit.xml .next + +.direnv/ diff --git a/ci/pipeline.yml b/ci/pipeline.yml index d9ed561130..0fa5b3f5be 100644 --- a/ci/pipeline.yml +++ b/ci/pipeline.yml @@ -127,7 +127,7 @@ jobs: - name: image params: CONTEXT: repo - BUILD_ARGS_FILE: repo/.env + BUILD_ARGS_FILE: repo/.build-args run: path: build - put: edge-image @@ -137,7 +137,20 @@ jobs: - name: build-debug-edge-image serial: true plan: - - { get: repo, trigger: true } + - in_parallel: + - { get: repo, trigger: true } + - { get: pipeline-tasks } + - task: prepare-docker-build + config: + platform: linux + image_resource: #@ nodejs_task_image_config() + inputs: + - name: pipeline-tasks + - name: repo + outputs: + - name: repo + run: + path: pipeline-tasks/ci/tasks/prepare-docker-build.sh - task: build privileged: true config: @@ -152,7 +165,7 @@ jobs: - name: image params: CONTEXT: repo - BUILD_ARGS_FILE: repo/.env + BUILD_ARGS_FILE: repo/.build-args DOCKERFILE: "repo/Dockerfile-debug" run: path: build @@ -163,7 +176,20 @@ jobs: - name: build-migrate-edge-image serial: true plan: - - { get: repo, trigger: true } + - in_parallel: + - { get: repo, trigger: true } + - { get: pipeline-tasks } + - task: prepare-docker-build + config: + platform: linux + image_resource: #@ nodejs_task_image_config() + inputs: + - name: pipeline-tasks + - name: repo + outputs: + - name: repo + run: + path: pipeline-tasks/ci/tasks/prepare-docker-build.sh - task: build privileged: true config: @@ -178,7 +204,7 @@ jobs: - name: image params: CONTEXT: repo - BUILD_ARGS_FILE: repo/.env + BUILD_ARGS_FILE: repo/.build-args DOCKERFILE: "repo/Dockerfile-migrate" run: path: build @@ -189,7 +215,20 @@ jobs: - name: build-websocket-edge-image serial: true plan: - - { get: repo, trigger: true } + - in_parallel: + - { get: repo, trigger: true } + - { get: pipeline-tasks } + - task: prepare-docker-build + config: + platform: linux + image_resource: #@ nodejs_task_image_config() + inputs: + - name: pipeline-tasks + - name: repo + outputs: + - name: repo + run: + path: pipeline-tasks/ci/tasks/prepare-docker-build.sh - task: build privileged: true config: @@ -204,7 +243,7 @@ jobs: - name: image params: CONTEXT: repo - BUILD_ARGS_FILE: repo/.env + BUILD_ARGS_FILE: repo/.build-args DOCKERFILE: "repo/Dockerfile-websocket" run: path: build diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000000..4b9f6a9108 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1694948089, + "narHash": "sha256-d2B282GmQ9o8klc22/Rbbbj6r99EnELQpOQjWMyv0rU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "5148520bfab61f99fd25fb9ff7bfbb50dad3c9db", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000000..f16564efe9 --- /dev/null +++ b/flake.nix @@ -0,0 +1,47 @@ +{ + description = "Galoy dev environment"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem (system: let + overlays = [ + (self: super: { + nodejs = super.nodejs_20; + yarn = super.yarn.override { + nodejs = super.nodejs_20; + }; + }) + ]; + pkgs = import nixpkgs {inherit overlays system;}; + nativeBuildInputs = with pkgs; [ + nodejs + tilt + yarn + alejandra + gnumake + docker-compose + shellcheck + shfmt + vendir + jq + ytt + direnv + nix-direnv + ]; + in + with pkgs; { + devShells.default = mkShell { + inherit nativeBuildInputs; + }; + + formatter = alejandra; + }); +} diff --git a/quickstart/bin/re-render.sh b/quickstart/bin/re-render.sh index 88c913e2a4..3245e3c0b6 100755 --- a/quickstart/bin/re-render.sh +++ b/quickstart/bin/re-render.sh @@ -3,19 +3,18 @@ set -e REPO_ROOT=$(git rev-parse --show-toplevel) -GALOY_DEV_DIR=${REPO_ROOT}/quickstart/dev GALOY_ROOT_DIR=${REPO_ROOT}/quickstart/galoy -pushd ${REPO_ROOT}/quickstart +pushd "${REPO_ROOT}/quickstart" ytt -f vendir > vendir.yml vendir sync -ytt -f ./docker-compose.tmpl.yml -f ${GALOY_ROOT_DIR}/docker-compose.yml -f ${GALOY_ROOT_DIR}/docker-compose.override.yml > docker-compose.yml +ytt -f ./docker-compose.tmpl.yml -f "${GALOY_ROOT_DIR}/docker-compose.yml" -f "${GALOY_ROOT_DIR}/docker-compose.override.yml" > docker-compose.yml -pushd ${GALOY_ROOT_DIR} +pushd "${GALOY_ROOT_DIR}" source .envrc mkdir -p "${GALOY_ROOT_DIR}/../vendor/galoy-quickstart/env" export OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-agent:4318 -envsubst < .env.ci | grep -v '^LND2' > ${GALOY_ROOT_DIR}/../.env.galoy +envsubst < .env.ci | grep -v '^LND2' > "${GALOY_ROOT_DIR}/../.env.galoy"