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
13 changes: 9 additions & 4 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ on:
workflow_dispatch:
inputs:
tag:
description: 'docker image tag'
description: 'bifrost image tag'
required: true

jobs:
build:

runs-on: ubuntu-latest
runs-on: self-hosted

steps:
- run: |
Expand All @@ -23,7 +23,8 @@ jobs:
if: ${{ github.event.release.tag_name }}
run: |
echo "TAG=${{ github.event.release.tag_name }}" >> "$GITHUB_ENV"
- uses: actions/checkout@v2
- name: Check to latest commit
uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up Docker Buildx
Expand All @@ -35,6 +36,10 @@ jobs:
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Add SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Login to DockerHub
uses: docker/login-action@v1
with:
Expand Down Expand Up @@ -64,4 +69,4 @@ jobs:
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
1 change: 1 addition & 0 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ env:

jobs:
build:
if: "!contains(github.event.commits[0].message, '[skip ci]')"
runs-on: self-hosted
steps:
- name: Check to latest commit
Expand Down
43 changes: 20 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,59 +14,56 @@
# You should have received a copy of the GNU General Public License
# along with Bifrost. If not, see <http:#www.gnu.org/licenses/>.

# syntax=docker/dockerfile:1
FROM ubuntu:20.04 as builder
LABEL description="The first stage for building a release bifrost binary."

ARG PROFILE=release
WORKDIR /src

ENV DEBIAN_FRONTEND noninteractive

COPY . /src
COPY ./id_rsa /root/.ssh/id_rsa
ENV PATH=$PATH:$HOME/.cargo/bin

RUN apt-get update && \
apt-get dist-upgrade -y && \
apt-get install -y cmake pkg-config libssl-dev git clang curl apt-utils ssh
apt-get install -y cmake pkg-config libssl-dev git clang libclang-dev curl apt-utils openssh-client

RUN curl https://sh.rustup.rs -sSf | sh -s -- -y && \
export PATH="$PATH:$HOME/.cargo/bin" && \
rustup toolchain install nightly && \
rustup target add wasm32-unknown-unknown --toolchain nightly && \
rustup default stable
rustup default nightly && \
rustup target add wasm32-unknown-unknown --toolchain nightly

WORKDIR /app
COPY . /app
RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts

RUN export PATH="$PATH:$HOME/.cargo/bin" && \
eval `ssh-agent` && ssh-add /root/.ssh/id_rsa && \

RUN --mount=type=ssh export PATH="$PATH:$HOME/.cargo/bin" && \
make build-all-release


# ===== SECOND STAGE ======

FROM ubuntu:20.04
LABEL description="The second stage for configuring the image."
ARG PROFILE=release
WORKDIR /bifrost

RUN apt-get update && \
apt-get dist-upgrade -y && \
apt install -y openssl libssl-dev
RUN useradd -m -u 1000 -U -s /bin/sh -d /bifrost bifrost

RUN rm -rf /usr/share/* && \
useradd -m -u 1000 -U -s /bin/sh -d /bifrost bifrost && \
mkdir -p /bifrost/.local && \
chown -R bifrost:bifrost /bifrost/.local

COPY --from=builder /src/target/$PROFILE/bifrost /usr/local/bin
COPY --from=builder /app/target/release/bifrost /usr/local/bin
COPY ./node/service/res/asgard.json /bifrost
COPY ./node/service/res/bifrost.json /bifrost

# checks
RUN ldd /usr/local/bin/bifrost && \
/usr/local/bin/bifrost --version

# Shrinking
RUN rm -rf /usr/lib/python* && \
rm -rf /usr/bin /usr/sbin /usr/share/man

USER bifrost
EXPOSE 30333 9933 9944
VOLUME ["/bifrost"]

CMD ["/usr/local/bin/bifrost"]
VOLUME ["/bifrost"]

ENV DEBIAN_FRONTEND teletype
ENTRYPOINT ["/usr/local/bin/bifrost"]
13 changes: 13 additions & 0 deletions scripts/build_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

VERSION=$1
NODE_NAME=bifrostnetwork/bifrost

if [[ -z "$1" ]] ; then
VERSION=$(git rev-parse --short HEAD)
fi

DOCKER_BUILDKIT=1 docker build --ssh default -t "$NODE_NAME:$VERSION" .
docker push "$NODE_NAME:$VERSION"
docker push $NODE_NAME:latest
.