Skip to content
This repository has been archived by the owner on Feb 3, 2025. It is now read-only.

feat(docker): improve docker-compose experience #253

Merged
merged 5 commits into from
Dec 20, 2019
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
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,22 @@ There is a hosted middleware for the æternity mainnet at https://mainnet.aetern

### Run via Docker

This setup runs node, compiler, postgres and middleware together.
This setup runs node, compiler, postgres and aeternal together.

In the `examples` folder there are 2 setup for docker:
- `examples/docker-compose.yml` that includes also the node configuration
- `examples/docker-compose.existing-node.yaml` that relies on an existing node

### Run docker including the node
- Install Docker and Docker Compose.
- Update `docker/aeternity.yaml` as per your requirement.
- Copy `.env.example` to `.env` and if required, edit the node and compiler version.
- From the project root run, run `docker-compose up`
- Update `examples/node/config.yaml` as per your requirement.
- From the project `examples` folders run `docker-compose up`

### Run docker including relying on an existing node
- Install Docker and Docker Compose
- Make sure you can reach the node external port from your machine
- Edit the file `examples/docker-compose.existing-node.yaml` and set the url of your node as explained in the file
- From the project `examples` folder run `docker-compose up -f docker-compose.existing-node.yaml`

### Tips and tricks

Expand Down
11 changes: 4 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@ services:
ports:
- "8080:80"
- "3020:3020"
entrypoint: ./docker/wait-for-it.sh node:3013 -- ./aeternal -p -s -w
entrypoint: /bin/wait-for-it.sh node:3013 -- ./aeternal -p -s -w
environment:
- NODE_URL=node:3013
- AESOPHIA_URL=compiler:3080
- DATABASE_URL=postgres://middleware:middleware@db/middleware
- LOG_CONF=/logs/log.yaml
volumes:
- ${PWD}/docker/wait-for-it.sh:/app/docker/wait-for-it.sh
depends_on:
- db
- node
Expand All @@ -38,10 +35,10 @@ services:
hostname: node
expose: [3013, 3113, 3014]
environment:
AETERNITY_CONFIG: /home/aeterinty/aeternity.yaml
AETERNITY_CONFIG: /home/aeternity/aeternity.yaml
volumes:
- ${PWD}/docker/aeternity.yaml:/home/aeterinty/aeternity.yaml
- node_db:/home/aeterinty/node/data/mnesia
- ${PWD}/docker/aeternity.yaml:/home/aeternity/aeternity.yaml
- node_db:/home/aeternity/node/data/mnesia

db:
image: postgres:11
Expand Down
16 changes: 13 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
FROM rust:1.35.0 as build
FROM rust:1-slim as build

# maybe we can optimize this but easiest way to get nightly
RUN rustup default nightly
RUN USER=root cargo new --bin --vcs none aeternal
WORKDIR /aeternal

RUN apt-get update && apt-get -y install \
pkg-config \
libssl-dev \
libpq-dev \
libcurl3-dev \
libcurl4-openssl-dev

COPY ./Cargo.lock ./Cargo.lock
COPY ./Cargo.toml ./Cargo.toml
RUN touch ./src/lib.rs
Expand All @@ -16,15 +23,18 @@ COPY ./migrations/ ./migrations/
COPY ./swagger/ ./swagger/
RUN cargo build --release

FROM debian:stretch-slim
FROM debian:buster-slim
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get -y install libpq5 libcurl3 libcurl3-gnutls
RUN apt-get update && apt-get -y install libpq5 libcurl4
COPY --from=build /aeternal/target/release/aeternal /app/aeternal
WORKDIR /app
# copy rocket configuration
COPY ./docker/Rocket.toml ./Rocket.toml
# copy minimal logger configuration
COPY ./docker/log4rs-minimal.yaml /logs/log.yaml
# copy the wait-for-it.sh script
COPY ./docker/wait-for-it.sh /bin/wait-for-it.sh
# set the entry-point
ENTRYPOINT ["/app/aeternal"]
CMD ["-p", "-s", "-w"]
EXPOSE 80 3020
2 changes: 1 addition & 1 deletion docker/aeternity.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
peers: []
# peers: []

http:
external:
Expand Down
46 changes: 46 additions & 0 deletions examples/docker-compose.existing-node.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

# This example configuration assumes that there is
# a reachable node at MY_NODE_URL address:
# change the MY_NODE_URL placeholder with the address
# of the external endpoint of an existing node ex: 10.123.123.123:3013

version: '3.1'
services:
aeternal:
# Hint: adjust the version to one available on
# https://hub.docker.com/r/aeternity/aeternal/tags
image: aeternity/aeternal:develop
ports:
- "8080:80"
- "3020:3020"
entrypoint: ./aeternal -p -s -w
environment:
- NODE_URL=______________MY_NODE_URL_______________
- AESOPHIA_URL=compiler:3080
- DATABASE_URL=postgres://aeternal:aeternal@db/aeternal
depends_on:
- db
- compiler

db:
image: postgres:11
restart: unless-stopped
environment:
- POSTGRES_USER=aeternal
- POSTGRES_PASSWORD=aeternal
- POSTGRES_DB=aeternal
volumes:
- ae-mdw-postgres-volume:/var/lib/postgresql/data
expose: [5432]

compiler:
# Hint: adjust the version to one available on
# https://hub.docker.com/r/aeternity/aesophia_http/tags
image: aeternity/aesophia_http:v4.1.0
hostname: compiler
expose: [3080]

volumes:
ae-mdw-postgres-volume:
external: false
node_db:
53 changes: 53 additions & 0 deletions examples/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
version: '3.1'
services:
aeternal:
# Hint: adjust the version to one available on
# https://hub.docker.com/r/aeternity/aeternal/tags
image: aeternity/aeternal:develop
ports:
- "8080:80"
- "3020:3020"
entrypoint: /bin/wait-for-it.sh node:3013 -- ./aeternal -p -s -w
environment:
- NODE_URL=node:3013
- AESOPHIA_URL=compiler:3080
- DATABASE_URL=postgres://aeternal:aeternal@db/aeternal
depends_on:
- db
- node
- compiler

node:
# Hint: adjust the version to one available on
# https://hub.docker.com/r/aeternity/aeternity/tags
image: aeternity/aeternity:v5.2.0
hostname: node
expose: [3013, 3113, 3014]
environment:
AETERNITY_CONFIG: /home/aeternity/aeternity.yaml
volumes:
- ${PWD}/node/config.yaml:/home/aeternity/aeternity.yaml
- node_db:/home/aeternity/node/data/mnesia

db:
image: postgres:11
restart: unless-stopped
environment:
- POSTGRES_USER=aeternal
- POSTGRES_PASSWORD=aeternal
- POSTGRES_DB=aeternal
volumes:
- ae-mdw-postgres-volume:/var/lib/postgresql/data
expose: [5432]

compiler:
# Hint: adjust the version to one available on
# https://hub.docker.com/r/aeternity/aesophia_http/tags
image: aeternity/aesophia_http:v4.1.0
hostname: compiler
expose: [3080]

volumes:
ae-mdw-postgres-volume:
external: false
node_db:
21 changes: 21 additions & 0 deletions examples/node/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
http:
external:
port: 3013
internal:
port: 3113
listen_address: 0.0.0.0
debug_endpoints: true

websocket:
channel:
listen_address: 0.0.0.0
port: 3014

chain:
persist: true

mining:
autostart: false

# fork_management:
# network_id: "ae_uat"