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

chore(containers and docs): update docs and container images #2003

Merged
merged 3 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
112 changes: 52 additions & 60 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,60 +1,52 @@
# Happening in a well-defined setting the Docker builds should be somewhat
# more reproducible than builds relying on the local workstation environment.
# Hence we're going to use the Docker build as the reference one.
# CI and local builds might be considered a second tier build optimizations.
#
# docker build --tag mm2 .

# NB: The version here was picked to match the one tested in our CI. The latest Travis has (as of 2018-11) is Xenial.
FROM docker.io/ubuntu:xenial

RUN \
apt-get update &&\
apt-get install -y git build-essential libssl-dev wget &&\
apt-get install -y cmake &&\
# https://github.com/rust-lang/rust-bindgen/blob/master/book/src/requirements.md#debian-based-linuxes
apt-get install -y llvm-3.9-dev libclang-3.9-dev clang-3.9 lld &&\
# openssl-sys requirements, cf. https://crates.io/crates/openssl-sys
apt-get install -y pkg-config libssl-dev &&\
apt-get clean

RUN \
wget -O- https://sh.rustup.rs > /tmp/rustup-init.sh &&\
sh /tmp/rustup-init.sh -y --default-toolchain none &&\
. /root/.cargo/env &&\
rustup set profile minimal &&\
rustup install nightly-2020-02-01 &&\
rustup default nightly-2020-02-01 &&\
# It seems that bindgen won't prettify without it:
rustup component add rustfmt-preview &&\
rm -f /tmp/rustup-init.sh

ENV PATH="/root/.cargo/bin:${PATH}"

# First 7 characters of the commit ID.
ENV MM_VERSION="f236ad1"

RUN cd /tmp &&\
wget https://api.github.com/repos/KomodoPlatform/atomicDEX-API/tarball/$MM_VERSION &&\
tar -xzf $MM_VERSION &&\
ls &&\
mv KomodoPlatform-atomicDEX-API-$MM_VERSION /mm2 &&\
rm $MM_VERSION &&\
echo $MM_VERSION > /mm2/MM_VERSION

RUN cd /mm2 && cargo fetch

# This will overwrite the Git version with the local one.
# Only needed when we're developing or changing something locally.
#COPY . /mm2

# Build MM1 and MM2.
# Increased verbosity here allows us to see the MM1 CMake logs.
RUN cd /mm2 &&\
cargo build -vv &&\
mv target/debug/mm2 /usr/local/bin/marketmaker-mainnet &&\
# We currently need BOB_PASSPHRASE, BOB_USERPASS, ALICE_PASSPHRASE and ALICE_USERPASS for the tests…
#cargo test &&\
cargo clean

CMD marketmaker-testnet
FROM docker.io/debian:buster-slim

MAINTAINER Onur Özkan <[email protected]>

RUN apt-get update -y

RUN apt-get install -y \
build-essential \
cmake \
ca-certificates \
curl \
wget \
gnupg

RUN ln -s /usr/bin/python3 /bin/python

RUN apt install -y \
software-properties-common \
lsb-release

RUN curl --output llvm.sh https://apt.llvm.org/llvm.sh

RUN chmod +x llvm.sh

RUN ./llvm.sh 16

RUN rm ./llvm.sh

RUN ln -s /usr/bin/clang-16 /usr/bin/clang

ENV AR=/usr/bin/llvm-ar-16
ENV CC=/usr/bin/clang-16

RUN mkdir -m 0755 -p /etc/apt/keyrings

RUN curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg

RUN echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null

RUN apt-get update -y

RUN apt-get install -y \
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

ENV PATH="/root/.cargo/bin:$PATH"
6 changes: 4 additions & 2 deletions .docker/Dockerfile.ci-container
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN apt install -y \
lsb-release \
gnupg

RUN wget https://apt.llvm.org/llvm.sh
RUN curl --output llvm.sh https://apt.llvm.org/llvm.sh

RUN chmod +x llvm.sh

Expand Down Expand Up @@ -52,4 +52,6 @@ RUN apt-get install -y \
containerd.io \
docker-buildx-plugin

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

ENV PATH="/root/.cargo/bin:$PATH"
5 changes: 0 additions & 5 deletions .docker/Dockerfile.ubuntu.ci
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ RUN \
wget -O- https://sh.rustup.rs > /tmp/rustup-init.sh &&\
sh /tmp/rustup-init.sh -y --default-toolchain none &&\
. /root/.cargo/env &&\
rustup set profile minimal &&\
rustup install nightly-2021-07-18 &&\
rustup default nightly-2021-07-18 &&\
# It seems that bindgen won't prettify without it:
rustup component add rustfmt-preview &&\
rm -f /tmp/rustup-init.sh &&\
chmod -R 777 /root

Expand Down
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ For a curated list of Komodo DeFi Framework based projects and resources, check

## Building from source

### On Host System:

[Pre-built release binaries](https://developers.komodoplatform.com/basic-docs/atomicdex/atomicdex-setup/get-started-atomicdex.html) are available for OSX, Linux or Windows.

If you want to build from source, the following prerequisites are required:
Expand All @@ -82,17 +84,29 @@ If you want to build from source, the following prerequisites are required:
- (Optional) OSX: run `LIBRARY_PATH=/usr/local/opt/openssl/lib`
- (Optional) Linux: Install libudev-dev (dpkg) or libudev-devel (rpm) package.
- [Download](https://github.com/protocolbuffers/protobuf/releases) or [compile](https://github.com/protocolbuffers/protobuf) `protoc 3.21.x+` and add it to your PATH env. It is also available via package managers depending on the OS.
- Additional Rust Components
```
rustup install nightly-2022-10-29
rustup default nightly-2022-10-29
rustup component add rustfmt-preview
```

To build, run `cargo build` (or `cargo build -vv` to get verbose build output).

For more detailed instructions, please refer to the [Installation Guide](https://developers.komodoplatform.com/basic-docs/atomicdex/atomicdex-setup/get-started-atomicdex.html).

### From Container:

If you want to build from source without installing prerequisites to your host system, you can do so by binding the source code inside a container and compiling it there.

Build the image:

```sh
docker build -t mm2-build-container -f .docker/Dockerfile .
```

Bind source code into container and compile it:

```sh
docker run -v "$(pwd)":/app -w /app mm2-build-container cargo build
```

Just like building it on your host system, you will now have the target directory containing the build files.

## Building WASM binary

Please refer to the [WASM Build Guide](./docs/WASM_BUILD.md).
Expand Down
13 changes: 4 additions & 9 deletions docs/RASPBERRY_PI4_CROSS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
1. Install latest nightly toolchain and make it default:
```
rustup install nightly
rustup default nightly
```
2. Install cross: `cargo install cross`.
3. Build the Docker image for cross compilation: `docker build -f .docker/Dockerfile.armv7-unknown-linux-gnueabihf -t mm2-armv7-unknown-linux-gnueabihf .`
4. Build mm2: `cross build --target armv7-unknown-linux-gnueabihf` or `cross build --target armv7-unknown-linux-gnueabihf --release` for release build.
5. The binary path will be `target/armv7-unknown-linux-gnueabihf/debug/mm2` or `target/armv7-unknown-linux-gnueabihf/release/mm2` for release build.
1. Install cross: `cargo install cross`.
2. Build the Docker image for cross compilation: `docker build -f .docker/Dockerfile.armv7-unknown-linux-gnueabihf -t mm2-armv7-unknown-linux-gnueabihf .`
3. Build mm2: `cross build --target armv7-unknown-linux-gnueabihf` or `cross build --target armv7-unknown-linux-gnueabihf --release` for release build.
4. The binary path will be `target/armv7-unknown-linux-gnueabihf/debug/mm2` or `target/armv7-unknown-linux-gnueabihf/release/mm2` for release build.