Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build the basic release docker image #232

Merged
merged 4 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[target.aarch64-unknown-linux-gnu]
rustflags = [
"-C", "link-arg=-static",
"-C", "target-feature=+crt-static"
]
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ prost = "0.7.0"
prost-types = "0.7.0"
qstring = "0.7.2"
rand = "0.8.3"
rdkafka = { version = "0.25.0", features = [ "cmake-build" ] }
rdkafka = { version = "0.26.0", features = [ "cmake-build" ] }
rust_decimal = { version = "1.10.3", features = [ "postgres", "bytes", "byteorder" ] }
rust_decimal_macros = "1.10.3"
serde = { version = "1.0.124", features = [ "derive" ] }
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,22 @@ $ cd $DingirExchangeDir/examples/js ; npm i
$ npx ts-node trade.ts
```

## Release

We uses [cross](https://github.com/rust-embedded/cross) to generate release builds for Linux Distributions.
For example, you could generate a static release build via the below command.

```
cross build --target aarch64-unknown-linux-gnu --release
```

And a new Docker image could be generated by the `release` script.

```
# In root directory of this project
./release/release.sh YOUR_DOCKER_REGISTRY_DOMAIN.COM:YOUR_DOMAIN_PORT NEW_IMAGE_TAG
```

## Related Projects

[Peatio](https://github.com/openware/peatio): A full-featured crypto exchange backend, with user account system and crypto deposit/withdraw. Written in Ruby/Rails. It can process less than 200 orders per second.
Expand Down
6 changes: 6 additions & 0 deletions release/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM ubuntu:20.04

COPY config /config
COPY target/aarch64-unknown-linux-gnu/debug/matchengine /usr/bin/

CMD 'matchengine'
40 changes: 40 additions & 0 deletions release/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
set -u

if [ $# -ne 2 ]
then
echo "Usage: $0 docker-registry image-tag"
exit 1
fi

DOCKER_IMAGE_NAME='dingir-exchange-matchengine'
DOCKER_TARGET="$1/$DOCKER_IMAGE_NAME:$2"

function run() {
install_cross
build_release
docker_build
help_info
}

function install_cross() {
echo 'install cross - https://github.com/rust-embedded/cross'
cargo install cross
}

function build_release() {
echo 'build a release for target aarch64-unknown-linux-gnu'
cross build --bin matchengine --target aarch64-unknown-linux-gnu --release
}

function docker_build() {
echo "docker build a image $DOCKER_TARGET"
docker build -t $DOCKER_TARGET -f release/Dockerfile .
}

function help_info() {
echo "Push to Docker Registry: docker push $DOCKER_TARGET"
echo "Run a new Docker Container: docker run $DOCKER_TARGET"
}

run