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

feat(local docker build and run) #14

Closed
wants to merge 2 commits into from
Closed
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
4 changes: 4 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
steps:
- label: publish docker
command: ./scripts/docker-release.sh
branches: "master | mhala-docker"
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
Dockerfile.local
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM nearprotocol/bridge as bridge
FROM ubuntu:20.04 as wasm

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update -qq && apt-get install -y \
git \
cmake \
g++ \
pkg-config \
libssl-dev \
curl \
llvm \
clang \
&& rm -rf /var/lib/apt/lists/*

ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH

RUN curl https://sh.rustup.rs -sSf | \
sh -s -- -y --no-modify-path

RUN rustup target add wasm32-unknown-unknown
WORKDIR /root
COPY . .
RUN ./build.sh

FROM node:12
ENV NEAR_ENV local
RUN npm install -g near-cli
RUN mkdir ~/.near
COPY --from=bridge /root/.near/localnet/node0/validator_key.json ~/.near
COPY --from=wasm /root/res/linkdrop.wasm .
CMD ["near deploy --accountId node0 --wasmFile linkdrop.wasm --keyPath validator_key.json --nodeUrl $NODE_URL"]
26 changes: 26 additions & 0 deletions scripts/docker-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -eo pipefail

branch=${BUILDKITE_BRANCH//:/_}
branch=${branch//\//_}
commit=${BUILDKITE_COMMIT}

if [[ ${commit} == "HEAD" ]]; then
commit=$(git rev-parse HEAD)
fi

image_name="linkdrop"

docker build -t $image_name .

docker tag $image_name nearprotocol/${image_name}:${branch}-${commit}
docker tag $image_name nearprotocol/${image_name}:${branch}

set -x
docker push nearprotocol/${image_name}:${branch}-${commit}
docker push nearprotocol/${image_name}:${branch}
if [[ ${branch} == "master" ]];
then
docker tag $image_name nearprotocol/${image_name}:latest
docker push nearprotocol/${image_name}:latest
fi