Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Add script and dockerfile to build an injected docker image for the p…
Browse files Browse the repository at this point in the history
…olkadot-collator binary (#591)

* remove exec flag on json file
* fix dockerignore filter to allow building the injected docker image
* Update docker/injected.Dockerfile
* Update docker/scripts/build-injected-image.sh

Co-authored-by: Martin Pugh <pugh@s3kr.it>
Co-authored-by: Denis Pisarev <denis.pisarev@parity.io>
  • Loading branch information
3 people committed Sep 3, 2021
1 parent 968c91e commit bf4024f
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
**/*.txt
**/*.md
/docker/
!/target/release/polkadot-collator

# dotfiles in the repo root
/.*
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,17 @@ cargo build --release
```
### Register the parachain
![image](https://user-images.githubusercontent.com/2915325/99548884-1be13580-2987-11eb-9a8b-20be658d34f9.png)

## Build the docker image

After building `polkadot-collator` with cargo as documented in [this chapter](#build--launch-rococo-collators), the following will allow producting a new docker image where the compiled binary is injected:

```
./docker/scripts/build-injected-image.sh
```

You may then start a new contaier:

```
docker run --rm -it $OWNER/$IMAGE_NAME --collator --tmp --parachain-id 1000 --execution wasm --chain /specs/westmint.json
```
49 changes: 49 additions & 0 deletions docker/injected.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM docker.io/library/debian:buster-slim

# metadata
ARG VCS_REF
ARG BUILD_DATE
ARG IMAGE_NAME

LABEL io.parity.image.authors="devops-team@parity.io" \
io.parity.image.vendor="Parity Technologies" \
io.parity.image.title="${IMAGE_NAME}" \
io.parity.image.description="polkadot: a platform for web3" \
io.parity.image.source="https://github.com/paritytech/polkadot/blob/${VCS_REF}/scripts/docker/Dockerfile" \
io.parity.image.revision="${VCS_REF}" \
io.parity.image.created="${BUILD_DATE}" \
io.parity.image.documentation="https://github.com/paritytech/cumulus/"

# show backtraces
ENV RUST_BACKTRACE 1

# install tools and dependencies
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
libssl1.1 \
ca-certificates \
curl && \
# apt cleanup
apt-get autoremove -y && \
apt-get clean && \
find /var/lib/apt/lists/ -type f -not -name lock -delete; \
# add user and link ~/.local/share/polkadot to /data
useradd -m -u 1000 -U -s /bin/sh -d /polkadot polkadot && \
mkdir -p /data /polkadot/.local/share && \
chown -R polkadot:polkadot /data && \
ln -s /data /polkadot/.local/share/polkadot && \
mkdir -p /specs

# add polkadot-collator binary to the docker image
COPY ./target/release/polkadot-collator /usr/local/bin
COPY ./polkadot-parachains/res/*.json /specs/

USER polkadot

# check if executable works in this container
RUN /usr/local/bin/polkadot-collator --version

EXPOSE 30333 9933 9944
VOLUME ["/polkadot"]

ENTRYPOINT ["/usr/local/bin/polkadot-collator"]
6 changes: 6 additions & 0 deletions docker/scripts/build-injected-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

OWNER=parity
IMAGE_NAME=polkadot-collator
docker build --no-cache --build-arg IMAGE_NAME=$IMAGE_NAME -t $OWNER/$IMAGE_NAME -f ./docker/injected.Dockerfile .
docker images | grep $IMAGE_NAME
2 changes: 1 addition & 1 deletion docker/test-parachain-collator.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ WORKDIR /paritytech/cumulus
# not the actual directory. We're stuck just enumerating them.
COPY . .

RUN cargo build --release -p polkadot-collator
RUN cargo build --release --locked -p polkadot-collator

# the collator stage is normally built once, cached, and then ignored, but can
# be specified with the --target build flag. This adds some extra tooling to the
Expand Down
Empty file modified polkadot-parachains/res/statemint.json
100755 → 100644
Empty file.

0 comments on commit bf4024f

Please sign in to comment.