Skip to content
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
8 changes: 6 additions & 2 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ docker buildx build -t mono-ui:0.1-pre-release -f ./docker/mono-ui-dockerfile .

# build aries engine image
docker buildx build -t aries-engine:0.1-pre-release -f ./docker/aries-engine-dockerfile .

# build mega engine image
docker buildx build -t mega-engine:0.1-pre-release -f ./docker/mega-engine-dockerfile .
```

## Test Mono Engine
Expand Down Expand Up @@ -122,8 +125,9 @@ server {
docker network create aries-network

# run postgres and aries engine
docker run --rm -it -d --name mono-pg --network aries-network -v /tmp/data/mono/pg-data:/var/lib/postgresql/data -p 5432:5432 mono-pg:0.1-pre-release
docker run --rm -it -d --name aries-engine --network aries-network -v /tmp/data/mono/mono-data:/opt/mega -p 8001:8001 -p 8888:8888 aries-engine:0.1-pre-release
docker run --rm -it -d --name mono-pg --network aries-network -v /mnt/data/mono/pg-data:/var/lib/postgresql/data -p 5432:5432 mono-pg:0.1-pre-release
docker run --rm -it -d --name aries-engine --network aries-network -e HUB_HOST=aries-engine -v /mnt/data/mono/mono-data:/opt/mega -p 8001:8001 -p 8888:8888 aries-engine:0.1-pre-release
docker run --rm -it -d --name mega-engine --network aries-network -v /mnt/data/mono/mono-data:/opt/mega -p 8000:8000 mega-engine:0.1-pre-release
```

[3] Nginx configuration for Aries
Expand Down
68 changes: 68 additions & 0 deletions docker/mega-engine-dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
FROM debian:bookworm-slim AS builder

WORKDIR /opt/mega

# build args, to specify the build type, release or debug
ARG BUILD_TYPE=release

# check arg value
RUN if [ "$BUILD_TYPE" != "release" ] && [ "$BUILD_TYPE" != "debug" ]; then \
echo "Invalid BUILD_TYPE: $BUILD_TYPE, must be release or debug"; \
exit 1; \
fi

# set mirror for apt
# RUN echo "deb http://mirrors.ustc.edu.cn/debian bookworm main contrib non-free" > /etc/apt/sources.list && \
# echo "deb http://mirrors.ustc.edu.cn/debian-security bookworm-security main contrib non-free" >> /etc/apt/sources.list && \
# echo "deb http://mirrors.ustc.edu.cn/debian bookworm-updates main contrib non-free" >> /etc/apt/sources.list

RUN apt-get update && apt-get install -y \
cmake \
clang \
build-essential \
nodejs \
npm \
curl \
wget \
file \
libssl-dev \
libgtk-3-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
ca-certificates \
&& curl https://sh.rustup.rs -sSf | sh -s -- -y \
&& . $HOME/.cargo/env

ENV PATH=/root/.cargo/bin:$PATH

# copy the source code, the context must be the root of the project
COPY . .

# build
RUN cargo clean
RUN git submodule deinit --all -f
RUN git submodule update --init --recursive
RUN if [ "$BUILD_TYPE" = "release" ]; then \
cargo build -p mega --release; \
else \
cargo build -p mega; \
fi

# final image
FROM debian:bookworm-slim

RUN apt-get update && apt-get install -y libssl-dev ca-certificates

ARG BUILD_TYPE=release

COPY --from=builder /opt/mega/target/$BUILD_TYPE/mega /usr/local/bin/mega
COPY --from=builder /opt/mega/docker/start-mega.sh /usr/local/bin/start-mega.sh
RUN chmod +x /usr/local/bin/start-mega.sh
RUN chmod +x /usr/local/bin/mega
COPY --from=builder /opt/mega/target/$BUILD_TYPE/libpipy.so /usr/local/lib/libpipy.so
# refresh shared library cache
RUN ldconfig

VOLUME /opt/mega

CMD ["bash", "-c", "/usr/local/bin/start-mega.sh"]
10 changes: 8 additions & 2 deletions docker/start-aries.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
#!/bin/sh

# user must set the HUB_HOST
if [ -z "$HUB_HOST" ]; then
echo "HUB_HOST is not set"
exit 1
fi

export MEGA_BASE_DIR="/opt/mega"
CONFIG_FILE="$MEGA_BASE_DIR/etc/config.toml"

if [ -f "$CONFIG_FILE" ]; then
echo "Using config file: $CONFIG_FILE"
exec /usr/local/bin/aries -c "$CONFIG_FILE" --host 0.0.0.0 --hub-host gitmono.org
exec /usr/local/bin/aries -c "$CONFIG_FILE" --host 0.0.0.0 --hub-host $HUB_HOST
else
exec /usr/local/bin/aries --host 0.0.0.0 --hub-host gitmono.org
exec /usr/local/bin/aries --host 0.0.0.0 --hub-host $HUB_HOST
fi
11 changes: 11 additions & 0 deletions docker/start-mega.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

export MEGA_BASE_DIR="/opt/mega"
CONFIG_FILE="$MEGA_BASE_DIR/etc/config.toml"

if [ -f "$CONFIG_FILE" ]; then
echo "Using config file: $CONFIG_FILE"
exec /usr/local/bin/mega -c "$CONFIG_FILE" service multi http ssh --host 0.0.0.0 --bootstrap-node http://aries-engine:8001
else
exec /usr/local/bin/mega service multi http ssh --host 0.0.0.0 --bootstrap-node aries-engine:8001
fi