Skip to content

Commit

Permalink
[docker] add indexer image
Browse files Browse the repository at this point in the history
  • Loading branch information
rustielin authored and aptos-bot committed Apr 19, 2022
1 parent 90630cd commit 43042f5
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 6 deletions.
5 changes: 4 additions & 1 deletion docker/build-aws.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ BUILD_PROJECTS=()

while [[ "$1" =~ ^- ]]; do case $1 in
--build-all )
BUILD_PROJECTS=(aptos-validator aptos-init aptos-faucet aptos-safety-rules aptos-tools aptos-forge aptos-txn-emitter)
BUILD_PROJECTS=(aptos-validator aptos-init aptos-faucet aptos-safety-rules aptos-tools aptos-forge aptos-txn-emitter aptos-indexer)
;;
--build-validator )
BUILD_PROJECTS=(aptos-validator)
;;
--build-indexer )
BUILD_PROJECTS=(aptos-indexer)
;;
--build-init )
BUILD_PROJECTS=(aptos-init)
;;
Expand Down
1 change: 1 addition & 0 deletions docker/build-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ if [ "$IMAGE_TARGETS" = "release" ] || [ "$IMAGE_TARGETS" = "all" ]; then
-p aptos-transaction-replay \
-p aptos-writeset-generator \
-p transaction-emitter \
-p aptos-indexer \
"$@"

# Build our core modules!
Expand Down
45 changes: 45 additions & 0 deletions docker/indexer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM debian:buster-20220228@sha256:fd510d85d7e0691ca551fe08e8a2516a86c7f24601a940a299b5fe5cdd22c03a AS debian-base

FROM debian-base AS toolchain

# To use http/https proxy while building, use:
# docker build --build-arg https_proxy=http://fwdproxy:8080 --build-arg http_proxy=http://fwdproxy:8080

RUN apt-get update && apt-get install -y cmake curl clang git pkg-config libssl-dev libpq-dev

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
ENV PATH "$PATH:/root/.cargo/bin"

WORKDIR /aptos
COPY rust-toolchain /aptos/rust-toolchain
RUN rustup install $(cat rust-toolchain)

FROM toolchain AS builder

ARG ENABLE_FAILPOINTS
COPY . /aptos

RUN IMAGE_TARGETS="release" ./docker/build-common.sh

### Production Image ###
FROM debian-base AS pre-prod

RUN apt-get update && apt-get install -y libssl1.1 net-tools tcpdump iproute2 netcat libpq-dev \
&& apt-get clean && rm -r /var/lib/apt/lists/*

RUN mkdir -p /opt/aptos/bin
COPY --from=builder /aptos/target/release/aptos-indexer /usr/local/bin

FROM pre-prod as testing

RUN /usr/local/bin/aptos-indexer -h

FROM pre-prod as prod

ARG BUILD_DATE
ARG GIT_REV
ARG GIT_UPSTREAM

LABEL org.label-schema.schema-version="1.0"
LABEL org.label-schema.build-date=$BUILD_DATE
LABEL org.label-schema.vcs-ref=$GIT_REV
8 changes: 8 additions & 0 deletions docker/indexer/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
# Copyright (c) Aptos
# SPDX-License-Identifier: Apache-2.0
set -e

DIR="$( cd "$( dirname "$0" )" && pwd )"

$DIR/../aptos-build.sh $DIR/Dockerfile aptos/indexer "$@"
28 changes: 28 additions & 0 deletions docker/indexer/buildspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This buildspec is for AWS Codebuild
version: 0.2

env:
secrets-manager:
DOCKERHUB_USERNAME: dockerhub_ro_username
DOCKERHUB_PASSWORD: dockerhub_ro_password

phases:
install:
runtime-versions:
docker: 18
pre_build:
commands:
- echo logging in to dockerhub.
- echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- bash docker/indexer/build.sh
post_build:
commands:
- echo Build completed on `date`
# Tag and push the docker images
- echo Logging in to Amazon ECR...
- $(aws ecr get-login --no-include-email --region us-west-2)
- SOURCE=aptos/indexer:latest TARGET_REPO=$APTOS_INDEXER_REPO TARGET_TAGS="${TAGS}:dev_$(git rev-parse --short=8 HEAD)" docker/tag-and-push.sh
2 changes: 1 addition & 1 deletion docker/init/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM debian-base AS toolchain
# To use http/https proxy while building, use:
# docker build --build-arg https_proxy=http://fwdproxy:8080 --build-arg http_proxy=http://fwdproxy:8080

RUN apt-get update && apt-get install -y cmake curl clang git pkg-config libssl-dev
RUN apt-get update && apt-get install -y cmake curl clang git pkg-config libssl-dev libpq-dev

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
ENV PATH "$PATH:/root/.cargo/bin"
Expand Down
2 changes: 1 addition & 1 deletion docker/safety-rules/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM debian-base AS toolchain
# To use http/https proxy while building, use:
# docker build --build-arg https_proxy=http://fwdproxy:8080 --build-arg http_proxy=http://fwdproxy:8080

RUN apt-get update && apt-get install -y cmake curl clang git pkg-config libssl-dev
RUN apt-get update && apt-get install -y cmake curl clang git pkg-config libssl-dev libpq-dev

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
ENV PATH "$PATH:/root/.cargo/bin"
Expand Down
2 changes: 1 addition & 1 deletion docker/tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM debian-base AS toolchain
# To use http/https proxy while building, use:
# docker build --build-arg https_proxy=http://fwdproxy:8080 --build-arg http_proxy=http://fwdproxy:8080

RUN apt-get update && apt-get install -y cmake curl clang git pkg-config libssl-dev
RUN apt-get update && apt-get install -y cmake curl clang git pkg-config libssl-dev libpq-dev

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
ENV PATH "$PATH:/root/.cargo/bin"
Expand Down
2 changes: 1 addition & 1 deletion docker/txn-emitter/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM debian-base AS toolchain
# To use http/https proxy while building, use:
# docker build --build-arg https_proxy=http://fwdproxy:8080 --build-arg http_proxy=http://fwdproxy:8080

RUN apt-get update && apt-get install -y cmake curl clang git pkg-config libssl-dev
RUN apt-get update && apt-get install -y cmake curl clang git pkg-config libssl-dev libpq-dev

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
ENV PATH "$PATH:/root/.cargo/bin"
Expand Down
2 changes: 1 addition & 1 deletion docker/validator/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM debian-base AS toolchain
# To use http/https proxy while building, use:
# docker build --build-arg https_proxy=http://fwdproxy:8080 --build-arg http_proxy=http://fwdproxy:8080

RUN apt-get update && apt-get install -y cmake curl clang git pkg-config libssl-dev
RUN apt-get update && apt-get install -y cmake curl clang git pkg-config libssl-dev libpq-dev

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain none
ENV PATH "$PATH:/root/.cargo/bin"
Expand Down

0 comments on commit 43042f5

Please sign in to comment.