Skip to content

Commit

Permalink
ci: build container on release (#396)
Browse files Browse the repository at this point in the history
* new (CI): optimized Dockerfile; labeled Dockerfile; Github Action to build container; edit docker-compose

* new (CI): rename secrets

* CI: edit registry name

* CI: edit registry namespace

* CI: do repeat yourself in GHA

* CI: fix maintainers; debug version tag

* CI: add rpc to env file

* CI: build the same image in parallel, what a joke

* CI: fix matrix

* CI: debug matrix

* CI: debug matrix 2

* CI: according to doc this should work

* CI: proudly move it to parity namespace

* CI: add docker pull to README
  • Loading branch information
TriplEight committed Jan 19, 2021
1 parent 43a8137 commit ed52edd
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 10 deletions.
1 change: 1 addition & 0 deletions .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ SAS_EXPRESS_BIND_HOST=0.0.0.0
# Port exposed by the container
SAS_EXPRESS_PORT=8080

SAS_SUBSTRATE_WS_URL=wss://rpc.polkadot.io
51 changes: 51 additions & 0 deletions .github/workflows/publish-release-container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and Publish container for new releases

on:
release:
types:
- published

jobs:
build:
name: Build and push image
runs-on: ubuntu-latest
strategy:
matrix:
# this matrix runs the jobs twice, in parallel. This is due to
# both buildah actions can't manage more than one image tag.
tag:
- latest
- ${{ github.event.release.tag_name }}
env:
REGISTRY: docker.io/parity
IMAGE_NAME: substrate-api-sidecar
VERSION: ${{ github.event.release.tag_name }}

steps:
- uses: actions/checkout@v2

- name: Build Image tagged ${{ matrix.tag }}
uses: redhat-actions/buildah-build@v1
with:
image: ${{ env.IMAGE_NAME }}
tag: ${{ matrix.tag }}
dockerfiles: |
./Dockerfile
build-args: |
VERSION=${{ env.VERSION }}
VCS_REF=${{ github.ref }}
BUILD_DATE=${{ github.event.release.published_at }}
- name: Push image tagged ${{ matrix.tag }} to docker.io
id: push-to-dockerhub
uses: redhat-actions/push-to-registry@v1
with:
registry: ${{ env.REGISTRY }}
image: ${{ env.IMAGE_NAME }}
tag: ${{ matrix.tag }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Check the image
run: |
echo "New image has been pushed to ${{ steps.push-to-dockerhub.outputs.registry-path }}"
30 changes: 23 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
FROM node:15 as builder
LABEL author="[email protected]"
FROM docker.io/library/node:15 as builder

WORKDIR /opt/builder

COPY . .
RUN curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh -s -- -y && \
. $HOME/.cargo/env && \
cargo install wasm-pack && \
yarn install && \

RUN yarn install && \
yarn build

# ---------------------------------

FROM node:15-alpine
FROM docker.io/library/node:15-alpine

# metadata
ARG VERSION=""
ARG VCS_REF=master
ARG BUILD_DATE=""

LABEL summary="Substrate-api-sidecar." \
name="parity/substrate-api-sidecar" \
maintainer="[email protected], [email protected]" \
version="${VERSION}" \
description="Substrate-api-sidecar image." \
io.parity.image.vendor="Parity Technologies" \
io.parity.image.source="https://github.com/paritytech/substrate-api-sidecar/blob/\
${VCS_REF}/Dockerfile" \
io.parity.image.documentation="https://github.com/paritytech/substrate-api-sidecar/\
blob/${VCS_REF}/README.md" \
io.parity.image.revision="${VCS_REF}" \
io.parity.image.created="${BUILD_DATE}"

WORKDIR /usr/src/app

COPY --from=builder /opt/builder /usr/src/app
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,15 @@ CALC_DEBUG=1 sh calc/build.sh

## Docker

### Build
### Pull the latest release

```bash
docker pull docker.io/parity/substrate-api-sidecar:latest
```

The specific image tag matches the release version.

### Or build from source

```bash
yarn build:docker
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.8"
services:
polkadot:
container_name: polkadot
image: chevdor/polkadot:latest
image: docker.io/parity/polkadot:latest
volumes:
- ~/polkadot-data:/data
# ports:
Expand All @@ -11,7 +11,7 @@ services:

sidecar:
# build: .
image: chevdor/substrate-api-sidecar
image: docker.io/parity/substrate-api-sidecar:latest
ports:
- "8080:8080"
environment:
Expand Down

0 comments on commit ed52edd

Please sign in to comment.