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

ci: build container on release #396

Merged
merged 15 commits into from
Jan 19, 2021
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
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="chevdor@gmail.com"
TriplEight marked this conversation as resolved.
Show resolved Hide resolved
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I right in thinking /library/ is equivalent to /_/ on hub.docker.com?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, /_/ is the alias for /library/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about now, but earlier versions of buildah didn't have the docker registry configured by default and it was confusing. Buildah did not understand the docker-style shortened image addresses i.e. node:15 or parity/substrate-api-sidecar and demanded a fqdn everywhere.
Then it softened and now buildah is able to deduct the image address (when you build manually with just node:15 in FROM it will stop and ask where to take it from - QUAY or dockehub), but still it will throw an error on push if you built an image without the registry address in name.


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

LABEL summary="Substrate-api-sidecar." \
name="parity/substrate-api-sidecar" \
maintainer="devops-team@parity.io, chevdor@gmail.com" \
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