diff --git a/.env.docker b/.env.docker index 98970f858..64725c0fb 100644 --- a/.env.docker +++ b/.env.docker @@ -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 diff --git a/.github/workflows/publish-release-container.yml b/.github/workflows/publish-release-container.yml new file mode 100644 index 000000000..291bb41af --- /dev/null +++ b/.github/workflows/publish-release-container.yml @@ -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 }}" diff --git a/Dockerfile b/Dockerfile index 2ed64e6f9..c58a2b3b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,34 @@ -FROM node:15 as builder -LABEL author="chevdor@gmail.com" +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="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 diff --git a/README.md b/README.md index a7d922b21..3482890b2 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index ac2a4f05c..d6ce6b507 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: @@ -11,7 +11,7 @@ services: sidecar: # build: . - image: chevdor/substrate-api-sidecar + image: docker.io/parity/substrate-api-sidecar:latest ports: - "8080:8080" environment: