Skip to content

Commit c254850

Browse files
committed
feat: package into single binary
To make it easier to use Realtime, we package it with Burrito and provide a binary to be ran by users more easily. Also added some improvements to our CI/CD pipeline
1 parent dcbddc1 commit c254850

23 files changed

Lines changed: 403 additions & 94 deletions

File tree

.github/workflows/beacon_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
otp-version: 27.x # Define the OTP version [required]
3535
elixir-version: 1.18.x # Define the elixir version [required]
3636
- name: Cache Mix
37-
uses: actions/cache@v5
37+
uses: useblacksmith/cache@v5
3838
with:
3939
path: |
4040
beacon/deps

.github/workflows/docker-build.yml

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,78 @@ on:
55
branches:
66
- main
77

8+
env:
9+
POSTGRES_IMAGE: supabase/postgres:17.6.1.074
10+
811
jobs:
912
build:
10-
runs-on: ubuntu-latest
13+
runs-on: blacksmith-4vcpu-ubuntu-2404
1114

1215
steps:
1316
- name: Checkout code
1417
uses: actions/checkout@v6
1518

1619
- name: Set up Docker Buildx
17-
uses: docker/setup-buildx-action@v3
20+
uses: useblacksmith/setup-docker-builder@v1
1821

1922
- name: Build Docker image
20-
run: docker build .
23+
uses: useblacksmith/build-push-action@v2
24+
with:
25+
push: false
26+
27+
build-burrito:
28+
runs-on: ${{ matrix.runner }}
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
include:
33+
- burrito_target: linux_amd64
34+
runner: blacksmith-4vcpu-ubuntu-2404
35+
- burrito_target: linux_arm64
36+
runner: blacksmith-4vcpu-ubuntu-2404-arm
37+
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v6
41+
42+
- name: Set up Docker Buildx
43+
uses: useblacksmith/setup-docker-builder@v1
44+
45+
- name: Cache Docker images
46+
uses: actions/cache@v5
47+
id: docker-cache
48+
with:
49+
path: /tmp/docker-images
50+
key: docker-images-zstd-${{ env.POSTGRES_IMAGE }}
51+
- name: Load Docker images from cache
52+
if: steps.docker-cache.outputs.cache-hit == 'true'
53+
run: zstd -d --stdout /tmp/docker-images/postgres.tar.zst | docker image load
54+
- name: Pull and save Docker images
55+
if: steps.docker-cache.outputs.cache-hit != 'true'
56+
run: |
57+
docker pull ${{ env.POSTGRES_IMAGE }}
58+
mkdir -p /tmp/docker-images
59+
docker image save ${{ env.POSTGRES_IMAGE }} | zstd -T0 -o /tmp/docker-images/postgres.tar.zst
60+
61+
- name: Build realtime image with cache
62+
uses: useblacksmith/build-push-action@v2
63+
with:
64+
load: true
65+
build-args: BURRITO_TARGET=${{ matrix.burrito_target }}
66+
tags: realtime-realtime:latest
67+
68+
- name: Build and start Burrito binary
69+
env:
70+
BURRITO_TARGET: ${{ matrix.burrito_target }}
71+
run: docker compose -p realtime -f docker-compose.burrito.yml up --wait
72+
73+
- name: Test healthcheck endpoint
74+
run: curl -f http://localhost:4001/healthcheck
75+
76+
- name: Print logs on failure
77+
if: failure()
78+
run: docker compose -p realtime -f docker-compose.burrito.yml logs
79+
80+
- name: Tear down
81+
if: always()
82+
run: docker compose -p realtime -f docker-compose.burrito.yml down

.github/workflows/integration_tests.yml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,5 @@ jobs:
3333

3434
steps:
3535
- uses: actions/checkout@v6
36-
- name: Cache Docker images
37-
uses: actions/cache@v5
38-
id: docker-cache
39-
with:
40-
path: /tmp/docker-images
41-
key: docker-images-integration-zstd-${{ env.POSTGRES_IMAGE }}-${{ env.DENO_IMAGE }}
42-
- name: Load Docker images from cache
43-
if: steps.docker-cache.outputs.cache-hit == 'true'
44-
run: |
45-
zstd -d --stdout /tmp/docker-images/postgres.tar.zst | docker image load &
46-
PID1=$!
47-
zstd -d --stdout /tmp/docker-images/deno.tar.zst | docker image load &
48-
PID2=$!
49-
wait $PID1 || exit $?
50-
wait $PID2 || exit $?
51-
- name: Pull and save Docker images
52-
if: steps.docker-cache.outputs.cache-hit != 'true'
53-
run: |
54-
docker pull ${{ env.POSTGRES_IMAGE }} &
55-
PID1=$!
56-
docker pull ${{ env.DENO_IMAGE }} &
57-
PID2=$!
58-
wait $PID1 || exit $?
59-
wait $PID2 || exit $?
60-
mkdir -p /tmp/docker-images
61-
docker image save ${{ env.POSTGRES_IMAGE }} | zstd -T0 -o /tmp/docker-images/postgres.tar.zst
62-
docker image save ${{ env.DENO_IMAGE }} | zstd -T0 -o /tmp/docker-images/deno.tar.zst
6336
- name: Run integration test
6437
run: docker compose -f docker-compose.tests.yml up --abort-on-container-exit --exit-code-from test-runner

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
otp-version: 27.x # Define the OTP version [required]
3636
elixir-version: 1.18.x # Define the elixir version [required]
3737
- name: Cache Mix
38-
uses: actions/cache@v5
38+
uses: useblacksmith/cache@v5
3939
with:
4040
path: |
4141
deps
@@ -59,7 +59,7 @@ jobs:
5959
- name: Run sobelow
6060
run: mix sobelow --config .sobelow-conf
6161
- name: Retrieve PLT Cache
62-
uses: actions/cache@v5
62+
uses: useblacksmith/cache@v5
6363
id: plt-cache
6464
with:
6565
path: priv/plts

.github/workflows/prod_build.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,104 @@ jobs:
3535
env:
3636
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PROJECT_ACTION }}
3737

38+
binary_linux_amd64:
39+
needs: release
40+
runs-on: blacksmith-4vcpu-ubuntu-2404
41+
if: needs.release.outputs.published == 'true'
42+
timeout-minutes: 60
43+
steps:
44+
- uses: actions/checkout@v6
45+
with:
46+
ref: v${{ needs.release.outputs.version }}
47+
48+
- uses: erlef/setup-beam@v1
49+
with:
50+
otp-version: 27.x
51+
elixir-version: 1.18.x
52+
53+
- uses: dtolnay/rust-toolchain@stable
54+
with:
55+
targets: x86_64-unknown-linux-musl
56+
57+
- run: mix deps.get --only prod
58+
59+
- name: Build Burrito binary
60+
env:
61+
MIX_ENV: prod
62+
BURRITO_TARGET: linux_amd64
63+
SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }}
64+
run: mix release
65+
66+
- name: Upload binary to GitHub release
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PROJECT_ACTION }}
69+
VERSION: ${{ needs.release.outputs.version }}
70+
run: gh release upload "v${VERSION}" burrito_out/realtime_linux_amd64 --clobber
71+
72+
binary_linux_arm64:
73+
needs: release
74+
runs-on: arm-runner
75+
if: needs.release.outputs.published == 'true'
76+
timeout-minutes: 60
77+
steps:
78+
- uses: actions/checkout@v6
79+
with:
80+
ref: v${{ needs.release.outputs.version }}
81+
82+
- uses: erlef/setup-beam@v1
83+
with:
84+
otp-version: 27.x
85+
elixir-version: 1.18.x
86+
87+
- uses: dtolnay/rust-toolchain@stable
88+
89+
- run: mix deps.get --only prod
90+
91+
- name: Build Burrito binary
92+
env:
93+
MIX_ENV: prod
94+
BURRITO_TARGET: linux_arm64
95+
SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }}
96+
run: mix release
97+
98+
- name: Upload binary to GitHub release
99+
env:
100+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PROJECT_ACTION }}
101+
VERSION: ${{ needs.release.outputs.version }}
102+
run: gh release upload "v${VERSION}" burrito_out/realtime_linux_arm64 --clobber
103+
104+
binary_macos_arm64:
105+
needs: release
106+
runs-on: macos-15
107+
if: needs.release.outputs.published == 'true'
108+
timeout-minutes: 60
109+
steps:
110+
- uses: actions/checkout@v6
111+
with:
112+
ref: v${{ needs.release.outputs.version }}
113+
114+
- uses: erlef/setup-beam@v1
115+
with:
116+
otp-version: 27.x
117+
elixir-version: 1.18.x
118+
119+
- uses: dtolnay/rust-toolchain@stable
120+
121+
- run: mix deps.get --only prod
122+
123+
- name: Build Burrito binary
124+
env:
125+
MIX_ENV: prod
126+
BURRITO_TARGET: macos_arm64
127+
SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }}
128+
run: mix release
129+
130+
- name: Upload binary to GitHub release
131+
env:
132+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_PROJECT_ACTION }}
133+
VERSION: ${{ needs.release.outputs.version }}
134+
run: gh release upload "v${VERSION}" burrito_out/realtime_macos_arm64 --clobber
135+
38136
docker_x86_release:
39137
needs: release
40138
runs-on: blacksmith-4vcpu-ubuntu-2404

.github/workflows/prod_linter.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
otp-version: 27.x # Define the OTP version [required]
1919
elixir-version: 1.18.x # Define the elixir version [required]
2020
- name: Cache Mix
21-
uses: actions/cache@v5
21+
uses: useblacksmith/cache@v5
2222
with:
2323
path: deps
2424
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
@@ -36,7 +36,7 @@ jobs:
3636
- name: Credo checks
3737
run: mix credo --strict --mute-exit-status
3838
- name: Retrieve PLT Cache
39-
uses: actions/cache@v5
39+
uses: useblacksmith/cache@v5
4040
id: plt-cache
4141
with:
4242
path: priv/plts

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
components: rustfmt, clippy
3333

3434
- name: Cache Cargo
35-
uses: actions/cache@v5
35+
uses: useblacksmith/cache@v5
3636
with:
3737
path: |
3838
~/.cargo/registry/index

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
otp-version: 27.x # Define the OTP version [required]
4444
elixir-version: 1.18.x # Define the elixir version [required]
4545
- name: Cache Mix
46-
uses: actions/cache@v5
46+
uses: useblacksmith/cache@v5
4747
with:
4848
path: |
4949
deps

0 commit comments

Comments
 (0)