Skip to content

Commit 06c594a

Browse files
committed
code changes, readme, workflows
1 parent 6220be6 commit 06c594a

File tree

18 files changed

+299
-33
lines changed

18 files changed

+299
-33
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @dfinity/boundary-node

.github/workflows/build.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
env:
9+
CARGO_TERM_COLOR: never
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository }}
12+
13+
permissions:
14+
contents: write
15+
packages: write
16+
attestations: write
17+
id-token: write
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-24.04
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Install repro-env
27+
run: |
28+
wget 'https://github.com/kpcyrd/repro-env/releases/download/v0.4.3/repro-env'
29+
echo '2a00b21ac5e990e0c6a0ccbf3b91e34a073660d1f4553b5f3cda2b09cc4d4d8a repro-env' | sha256sum -c -
30+
sudo install -m755 repro-env -t /usr/bin
31+
32+
- name: Install deps
33+
run: sudo apt-get update && sudo apt-get -y install protobuf-compiler podman
34+
35+
- name: Build
36+
run: repro-env build -- cargo build --release --target x86_64-unknown-linux-musl
37+
38+
- name: Generate SHA checksum
39+
run: shasum target/x86_64-unknown-linux-musl/release/ic-http-lb > ic-http-lb.shasum
40+
41+
- name: Remove build files
42+
run: rm -rf target
43+
44+
- name: Build again
45+
run: repro-env build -- cargo build --release --target x86_64-unknown-linux-musl
46+
47+
- name: Check SHA checksum
48+
run: shasum -c ic-http-lb.shasum
49+
50+
- name: Strip
51+
run: /usr/bin/strip target/x86_64-unknown-linux-musl/release/ic-http-lb
52+
53+
- name: Create package root
54+
run: |
55+
mkdir -p .debpkg/usr/sbin
56+
mkdir -p .debpkg/etc/systemd/system
57+
mkdir -p .debpkg/etc/default
58+
mkdir -p .debpkg/DEBIAN
59+
60+
cp target/x86_64-unknown-linux-musl/release/ic-http-lb .debpkg/usr/sbin
61+
cp deploy/ic-http-lb.service .debpkg/etc/systemd/system
62+
cp deploy/ic-http-lb.env .debpkg/etc/default/ic-http-lb
63+
64+
chmod -R g-s .debpkg
65+
66+
- uses: jiro4989/build-deb-action@1bd8ed1458d3dc331f62bf50468cce9b610fd0af
67+
with:
68+
package: ic-http-lb
69+
package_root: .debpkg
70+
maintainer: "DFINITY Boundary Nodes Team"
71+
version: ${{ github.ref }}
72+
arch: amd64
73+
desc: "IC-HTTP-LB Service"
74+
homepage: "https://github.com/dfinity/ic-http-lb"
75+
76+
- uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5
77+
with:
78+
makeLatest: true
79+
artifacts: "target/x86_64-unknown-linux-musl/release/ic-http-lb,*.deb"
80+
body: "IC-HTTP-LB release"
81+
82+
- name: Log in to the Container registry
83+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772
84+
with:
85+
registry: ${{ env.REGISTRY }}
86+
username: ${{ github.actor }}
87+
password: ${{ secrets.GITHUB_TOKEN }}
88+
89+
- name: Extract metadata for Docker
90+
id: docker_meta
91+
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804
92+
with:
93+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
94+
95+
- name: Build and push Docker image
96+
id: docker_push
97+
uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0
98+
with:
99+
context: .
100+
push: true
101+
tags: ${{ steps.docker_meta.outputs.tags }}
102+
labels: ${{ steps.docker_meta.outputs.labels }}
103+
104+
- name: Generate artifact attestation
105+
uses: actions/attest-build-provenance@db473fddc028af60658334401dc6fa3ffd8669fd
106+
with:
107+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
108+
subject-digest: ${{ steps.docker_push.outputs.digest }}
109+
push-to-registry: true

.github/workflows/test.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
env:
10+
CARGO_TERM_COLOR: never
11+
GH_TOKEN: ${{ github.token }}
12+
13+
defaults:
14+
run:
15+
shell: bash
16+
17+
jobs:
18+
test:
19+
permissions:
20+
contents: write
21+
22+
runs-on:
23+
- namespace-profile-ubuntu-24-04-big
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
29+
30+
- name: Install deps
31+
run: sudo apt-get update && sudo apt-get -y install protobuf-compiler && cargo install cargo-all-features
32+
33+
- name: Run all unit and integration tests
34+
run: |
35+
./run-tests.sh

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ target
1919
# and can be added to the global gitignore or merged into this file. For a more nuclear
2020
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
2121
#.idea/
22+
23+
build-linux.sh

Cargo.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ hostname = "0.4.0"
1717
http = "1.3.1"
1818
humantime = "2.2.0"
1919
ic-bn-lib = { path = "../ic-bn-lib", features = [
20-
"cert_providers",
20+
"cert-providers",
2121
"clients-hyper",
22-
"acme_alpn",
22+
"acme-alpn",
2323
"vector",
2424
] }
2525
prometheus = "0.14.0"
@@ -41,3 +41,13 @@ tracing-subscriber = { version = "0.3.18", features = [
4141
] }
4242
url = { version = "2.5.3", features = ["serde"] }
4343
serde_json = "1.0.140"
44+
45+
[profile.release]
46+
strip = "symbols"
47+
codegen-units = 1
48+
lto = "fat"
49+
panic = "abort"
50+
51+
[profile.profiling]
52+
inherits = "release"
53+
debug = true

README.md

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,74 @@
11
# ic-http-lb
2-
Load Balancer for IC HTTP Gateways
2+
3+
`ic-http-lb` is the simple HTTP load balancer that runs in front of HTTP Gateways on the [Internet Computer](https://internetcomputer.org).
4+
5+
## Description
6+
7+
`ic-http-lb` enables load balancing of incoming HTTP requests over a set of backends and performs TLS termination.
8+
9+
## Installation
10+
11+
To install and set up `ic-http-lb`, follow the steps below.
12+
13+
### Simple
14+
15+
- Grab the latest package from the [releases](https://github.com/dfinity/ic-http-lb/releases) page and install it
16+
- Edit `/etc/default/ic-http-lb` file to configure the service using environment variables. See `Usage` section below.
17+
- Start the service with `systemctl start ic-http-lb`
18+
19+
### Advanced
20+
21+
- **Clone the repository**
22+
23+
```bash
24+
git clone git@github.com:dfinity/ic-http-lb.git
25+
cd ic-http-lb
26+
```
27+
28+
- **Install Rust**
29+
30+
Follow the [official Rust installation guide](https://www.rust-lang.org/tools/install).
31+
32+
- **Build**
33+
34+
Execute `cargo build --release` in the `ic-http-lb` folder and you'll get a binary in `target/release` subfolder.
35+
36+
### Reproducible build
37+
38+
- Install [repro-env](https://github.com/kpcyrd/repro-env)
39+
- Build the binary using `repro-env build -- cargo build --release --target x86_64-unknown-linux-musl`
40+
41+
### Running in Docker
42+
- Pull the container: `docker pull ghcr.io/dfinity/ic-http-lb:latest`
43+
- Create the configuration file with the environment variables, e.g. `ic-http-lb.env`
44+
- Run the container: `docker run --env-file ic-http-lb.env ghcr.io/dfinity/ic-http-lb`
45+
46+
## Usage
47+
48+
### Minimal Example
49+
50+
To run a minimal ic-http-lb instance, use the following configuration in `/etc/default/ic-http-lb`:
51+
52+
```
53+
BACKENDS_CONFIG="/etc/ic-http-lb/backends.yaml"
54+
```
55+
56+
`backends.yaml` example:
57+
```
58+
- name: backend1.domain.com
59+
url: https://backend1.domain.com
60+
weight: 1
61+
enabled: true
62+
```
63+
64+
### Options
65+
66+
`ic-http-lb` offers various options that can be configured via command-line arguments or environment variables. For a full list, run `ic-http-lb --help`.
67+
68+
## Contributing
69+
70+
External code contributions are currently not being accepted to this repository.
71+
72+
## License
73+
74+
This project is licensed under the Apache License, Version 2.0. See the [LICENSE](LICENSE) file for more details.

build-linux.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

deploy/ic-http-lb.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
BACKENDS_CONFIG="/etc/ic-http-lb/backends.yaml"

deploy/ic-http-lb.service

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=IC-HTTP-LB
3+
After=network-online.target
4+
Wants=network-online.target
5+
6+
[Service]
7+
User=root
8+
Group=root
9+
Restart=always
10+
EnvironmentFile=-/etc/default/ic-http-lb
11+
ExecStart=/usr/sbin/ic-http-lb
12+
13+
[Install]
14+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)