Skip to content

docker

docker #65

Workflow file for this run

name: docker
on:
workflow_dispatch:
inputs:
tag:
description: tag (ex. v4.0.0) to publish on docker
required: true
jobs:
##
# Build the Rust package
##
build-package:
name: Build package
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install dependencies
run: |
sudo apt update -y
sudo apt install --no-install-recommends -y \
git curl ca-certificates \
gcc g++ cmake clang
env:
DEBIAN_FRONTEND: "noninteractive"
TZ: "Asia/Shanghai"
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-11-07
target: wasm32-unknown-unknown
default: true
- name: Cache target
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-target
- name: Build chainx
run: |
COMMIT=`git rev-parse HEAD` && \
echo using $COMMIT && \
cargo build --release
- name: Collect shared
run: |
mkdir shared
mv target/release/chainx shared/
- name: Upload shared
uses: actions/[email protected]
with:
name: chainx-artifact
path: shared
build-docker:
name: Build docker
runs-on: ubuntu-latest
needs: [build-package]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download shared
uses: actions/download-artifact@v2
with:
name: chainx-artifact
path: shared
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- run: |
DOCKER_IMAGE=chainxorg/chainx
VERSION="${{ github.event.inputs.tag }}"
COMMIT=`git rev-parse HEAD`
BUILD_AT=`date --iso-8601=seconds`
echo building "${DOCKER_IMAGE}:${VERSION} at ${BUILD_AT} on ${COMMIT}"
chmod +x shared/chainx # REQUIRED, see above
echo building "${DOCKER_IMAGE}:${VERSION}"
docker build \
--build-arg CI_BUILD_AT=${BUILD_AT} \
--build-arg CI_GIT_TAG=${VERSION} \
--build-arg CI_GIT_SHA=commit-${COMMIT} \
-f Dockerfile \
-t "${DOCKER_IMAGE}:${VERSION}" \
.
docker push "${DOCKER_IMAGE}:${VERSION}"