Skip to content

Commit

Permalink
GitHub Actions builds docker image. (#580)
Browse files Browse the repository at this point in the history
* Build Docker image with GitHub Actions.

* Install clang, libclang-dev, and cmake.

* Only run release workflows on tag.

* Add Dockerfile in .editorconfig.

* Fix typo.

* Fix indentation of Dockerfile.

* simplify: rust setup

Co-authored-by: Xavier Lau <[email protected]>
Co-authored-by: HackFisher <[email protected]>
  • Loading branch information
3 people authored Nov 9, 2020
1 parent 251bebc commit ca06562
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ indent_style=space
indent_size=2
indent_style=space
tab_width=8

[Dockerfile*]
indent_size=4
indent_style=space
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Release
on:
push:
tags: ["*"]

jobs:
build-docker-image:
name: Build Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2
with:
repository: itering/actions
path: .github/actions
persist-credentials: false
ssh-key: "${{ secrets.ITERING_ACTIONS_DEPLOY_KEY }}"

- name: Docker login
uses: docker/login-action@v1
with:
username: ${{ secrets.QUAY_IO_BOT_USERNAME }}
password: ${{ secrets.QUAY_IO_BOT_PASSWORD }}
registry: quay.io

- uses: ./.github/actions/docker-build-deploy
with:
deploy_phase: production
docker_registry: quay.io
trigger_token: ${{ secrets.ITERING_DEPLOYMENT_TRIGGER_TOKEN }}
trigger_endpoint: ${{ secrets.ITERING_DEPLOYMENT_TRIGGER_ENDPOINT }}
docker_build_options: -f .maintain/docker/Dockerfile
skip_deploy: true # for now

- uses: ./.github/actions/dingtalk-notify
if: failure() && (github.event_name == 'pull_request' && github.event.pull_request.draft == false || github.event_name != 'pull_request')
with:
dingtalk_bot_token: ${{ secrets.DINGTALK_BOT_TOKEN }}
34 changes: 26 additions & 8 deletions .maintain/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,38 @@
FROM iteringops/darwinia-builder:latest as builder
##
# Builder
##

RUN rustup update && rustup default nightly
FROM rust:1 as builder

COPY . /source
WORKDIR /source
ARG RUST_TOOLCHAIN=nightly-2020-10-06
ENV CARGO_TERM_COLOR=always

ENV TERM="xterm-256color"
RUN apt-get update && apt-get install -y --no-install-recommends \
clang \
libclang-dev \
cmake \
&& rm -rf /var/lib/apt/lists/*

RUN rustup default ${RUST_TOOLCHAIN} \
&& rustup target add wasm32-unknown-unknown

WORKDIR /src
COPY . .

RUN cargo build --release

##
# Final stage
##

FROM debian:stable-slim

RUN apt-get update && apt-get -y install openssl && apt-get clean
COPY --from=builder /source/target/release/darwinia /usr/local/bin/.
RUN apt-get update && apt-get install -y --no-install-recommends \
openssl \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /src/target/release/darwinia /usr/local/bin/

EXPOSE 30333 9933 9944
VOLUME ["/data"]

ENTRYPOINT [ "/usr/local/bin/darwinia" ]

0 comments on commit ca06562

Please sign in to comment.