Skip to content

Commit

Permalink
Merge pull request AleoNet#1288 from AleoHQ/docker-builds
Browse files Browse the repository at this point in the history
Docker builds
  • Loading branch information
zosorock authored Nov 17, 2021
2 parents 5ff6147 + eff7042 commit 5f304d8
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 0 deletions.
113 changes: 113 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,107 @@ jobs:
- clear_environment:
cache_key: snarkos-clippy-cache


build-and-publish-docker-arm:
machine:
image: ubuntu-2004:202101-01
docker_layer_caching: true
resource_class: arm.large
steps:
- checkout
- run: mkdir -p my_workspace
- run:
name: "Build snarkos Docker Image ARM V8"
no_output_timeout: 2h
command: |
VERSION=$(git rev-parse --short HEAD)
docker build -f Dockerfile -t $DOCKER_REPO:$CIRCLE_BRANCH-$VERSION-arm64 .
- run:
name: "Push snarkos Docker Image ARM V8"
command: |
VERSION=$(git rev-parse --short HEAD)
echo $DOCKERHUB_TOKEN | docker login -u $DOCKERHUB_USERNAME --password-stdin
# CREATE THE SHELL FILE WITH IMAGE NAME AND TAG
docker push $DOCKER_REPO:$CIRCLE_BRANCH-$VERSION-arm64
echo "Pushed $DOCKER_REPO:$CIRCLE_BRANCH-$VERSION-arm64"
- run:
name: "Save arm64 image tag"
command: |
VERSION=$(git rev-parse --short HEAD)
echo "$CIRCLE_BRANCH-$VERSION-arm64" > my_workspace/docker_tag_arm
- persist_to_workspace:
root: my_workspace
paths:
- docker_tag_arm

build-and-publish-docker-amd:
machine:
image: ubuntu-2004:202101-01
docker_layer_caching: true
resource_class: xlarge
steps:
- checkout
- run: mkdir -p my_workspace
- run:
name: "Build snarkos Docker Image AMD"
no_output_timeout: 2h
command: |
VERSION=$(git rev-parse --short HEAD)
docker build -f Dockerfile -t $DOCKER_REPO:$CIRCLE_BRANCH-$VERSION-amd64 .
- run:
name: "Push snarkos Docker Image AMD"
command: |
VERSION=$(git rev-parse --short HEAD)
echo $DOCKERHUB_TOKEN | docker login -u $DOCKERHUB_USERNAME --password-stdin
docker push $DOCKER_REPO:$CIRCLE_BRANCH-$VERSION-amd64
echo "Pushed $DOCKER_REPO:$CIRCLE_BRANCH-$VERSION-amd64"
- run:
name: "Save amd64 image tag"
command: |
VERSION=$(git rev-parse --short HEAD)
echo "$CIRCLE_BRANCH-$VERSION-amd64" > my_workspace/docker_tag_amd
- persist_to_workspace:
root: my_workspace
paths:
- docker_tag_amd

publish_snarkos_manifest:
machine:
image: ubuntu-2004:202101-01
docker_layer_caching: true
resource_class: medium
steps:
- checkout
- attach_workspace:
at: my_workspace
- run:
name: "Pull ARM docker image"
command: |
ARM_TAG=$(cat my_workspace/docker_tag_arm)
echo $ARM_TAG
echo $DOCKERHUB_TOKEN | docker login -u $DOCKERHUB_USERNAME --password-stdin
docker pull $DOCKER_REPO:$ARM_TAG
- run:
name: "Pull AMD docker image"
command: |
AMD_TAG=$(cat my_workspace/docker_tag_amd)
echo $AMD_TAG
docker pull $DOCKER_REPO:$AMD_TAG
- run:
name: "Create and push docker multi arch manifest"
command: |
ARM_TAG=$(cat my_workspace/docker_tag_arm)
AMD_TAG=$(cat my_workspace/docker_tag_amd)
echo $DOCKERHUB_TOKEN | docker login -u $DOCKERHUB_USERNAME --password-stdin
echo $DOCKER_REPO
echo $CIRCLE_BRANCH
echo $ARM_TAG
echo $AMD_TAG
docker manifest create $DOCKER_REPO:${CIRCLE_BRANCH}-latest --amend $DOCKER_REPO:${ARM_TAG} --amend $DOCKER_REPO:${AMD_TAG}
docker manifest inspect $DOCKER_REPO:${CIRCLE_BRANCH}-latest
docker manifest push $DOCKER_REPO:${CIRCLE_BRANCH}-latest
echo "Pushed $DOCKER_REPO:${CIRCLE_BRANCH}-latest"
workflows:
main-workflow:
jobs:
Expand All @@ -121,3 +222,15 @@ workflows:
# - rust-stable
- fmt
- clippy
build-snarkos-docker-images:
when:
or:
- equal: [ testnet2, << pipeline.git.branch >> ]
- equal: [ docker-builds, << pipeline.git.branch >> ]
jobs:
- build-and-publish-docker-arm
- build-and-publish-docker-amd
- publish_snarkos_manifest:
requires:
- build-and-publish-docker-arm
- build-and-publish-docker-amd
59 changes: 59 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
FROM ubuntu:18.04 AS builder
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
DEBIAN_FRONTEND=noninteractive
RUN set -eux ; \
apt-get update -y && \
apt-get dist-upgrade -y && \
apt-get install -y --no-install-recommends \
ca-certificates \
gcc \
libc6-dev \
wget \
build-essential \
clang \
gcc \
libssl-dev \
make \
pkg-config \
xz-utils && \
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
amd64) rustArch='x86_64-unknown-linux-gnu' ;; \
arm64) rustArch='aarch64-unknown-linux-gnu' ;; \
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
esac; \
\
url="https://static.rust-lang.org/rustup/dist/${rustArch}/rustup-init"; \
wget "$url"; \
chmod +x rustup-init; \
./rustup-init -y --no-modify-path --default-toolchain stable; \
rm rustup-init; \
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
rustup --version; \
cargo --version; \
rustc --version; \
apt-get remove -y --auto-remove wget && \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*;
WORKDIR /usr/src/snarkOS
COPY . .
RUN cargo build --release
FROM ubuntu:18.04
SHELL ["/bin/bash", "-c"]
VOLUME ["/aleo/data"]
RUN set -ex && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y -o DPkg::Options::=--force-confold && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
ca-certificates curl jq && \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
mkdir -p /aleo/{bin,data} && \
mkdir /usr/local/cargo
COPY --from=builder /usr/src/snarkOS/target/release/snarkos /aleo/bin/
COPY --from=builder /usr/src/snarkOS/start /aleo/
CMD ["/aleo/start"]
8 changes: 8 additions & 0 deletions start
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
mkdir -p /aleo/data/ledger && \
mkdir -p /aleo/data/params/git/checkouts/snarkvm-f1160780ffe17de8/e7266f9/parameters/src/testnet2/resources && \
mkdir -p /aleo/data/params/registry/src/github.com-1ecc6299db9ec823/snarkvm-parameters-0.7.9/src/testnet2/resources && \
ln -s /aleo/data/ledger /.ledger-2 && \
ln -s /aleo/data/params/git /usr/local/cargo/git && \
ln -s /aleo/data/params/registry /usr/local/cargo/registry && \
/aleo/bin/snarkos --node 4132 --rpc 3032 --verbosity 3 --trial

0 comments on commit 5f304d8

Please sign in to comment.