diff --git a/scripts/docker/README.md b/scripts/docker/README.md new file mode 100644 index 000000000..86b2fcb6a --- /dev/null +++ b/scripts/docker/README.md @@ -0,0 +1,40 @@ +## Usage + +```docker build -f docker/ubuntu/Dockerfile --tag ethcore/parity:branch_or_tag_name .``` + +## Usage - CentOS + +Builds a lightweight non-root Parity docker image: +``` +git clone https://github.com/paritytech/parity-ethereum.git +cd parity-ethereum +./docker/centos/build.sh +``` + +Fully customised build: +``` +PARITY_IMAGE_REPO=my-personal/parity \ +PARITY_BUILDER_IMAGE_TAG=build-latest \ +PARITY_RUNNER_IMAGE_TAG=centos-parity-experimental \ +./docker/centos/build.sh +``` + +Default values: +``` +# The image name +PARITY_IMAGE_REPO - parity/parity + +# The tag to be used for builder image, git commit sha will be appended +PARITY_BUILDER_IMAGE_TAG - build + +# The tag to be used for runner image +PARITY_RUNNER_IMAGE_TAG - latest +``` + +All default ports you might use will be exposed: +``` +# secret +# ipfs store ui rpc ws listener discovery +# ↓ ↓ ↓ ↓ ↓ ↓ ↓ +EXPOSE 5001 8082 8083 8180 8545 8546 30303/tcp 30303/udp +``` diff --git a/scripts/docker/alpine/Dockerfile b/scripts/docker/alpine/Dockerfile new file mode 100644 index 000000000..47b37372e --- /dev/null +++ b/scripts/docker/alpine/Dockerfile @@ -0,0 +1,43 @@ +FROM alpine:edge AS builder + +# show backtraces +ENV RUST_BACKTRACE 1 + +RUN apk add --no-cache \ + build-base \ + cargo \ + cmake \ + eudev-dev \ + linux-headers \ + perl \ + rust + +WORKDIR /parity +COPY . /parity +RUN cargo build --release --target x86_64-alpine-linux-musl --verbose +RUN strip target/x86_64-alpine-linux-musl/release/parity + + +FROM alpine:edge + +# show backtraces +ENV RUST_BACKTRACE 1 + +RUN apk add --no-cache \ + libstdc++ \ + eudev-libs \ + libgcc + +RUN addgroup -g 1000 parity \ + && adduser -u 1000 -G parity -s /bin/sh -D parity + +USER parity + +EXPOSE 8080 8545 8180 + +WORKDIR /home/parity + +RUN mkdir -p /home/parity/.local/share/io.parity.ethereum/ +COPY --chown=parity:parity --from=builder /parity/target/x86_64-alpine-linux-musl/release/parity ./ + +ENTRYPOINT ["./parity"] diff --git a/scripts/docker/centos/Dockerfile b/scripts/docker/centos/Dockerfile new file mode 100644 index 000000000..22a98c003 --- /dev/null +++ b/scripts/docker/centos/Dockerfile @@ -0,0 +1,28 @@ +FROM centos:latest + +RUN mkdir -p /opt/parity/data && \ + chmod g+rwX /opt/parity/data && \ + mkdir -p /opt/parity/release + +COPY parity/parity /opt/parity/release + +WORKDIR /opt/parity/data + +# exposing default ports +# +# secret +# ipfs store ui rpc ws listener discovery +# ↓ ↓ ↓ ↓ ↓ ↓ ↓ +EXPOSE 5001 8082 8083 8180 8545 8546 30303/tcp 30303/udp + +# switch to non-root user +USER 1001 + +#if no base path provided, assume it's current workdir +CMD ["--base-path","."] +ENTRYPOINT ["/opt/parity/release/parity"] + + + + + diff --git a/scripts/docker/centos/Dockerfile.build b/scripts/docker/centos/Dockerfile.build new file mode 100644 index 000000000..454af403a --- /dev/null +++ b/scripts/docker/centos/Dockerfile.build @@ -0,0 +1,25 @@ +FROM centos:latest + +WORKDIR /build + +ADD . /build/parity-ethereum + +RUN yum -y update && \ + yum install -y systemd-devel git make gcc-c++ gcc file binutils && \ + curl -L "https://cmake.org/files/v3.12/cmake-3.12.0-Linux-x86_64.tar.gz" -o cmake.tar.gz && \ + tar -xzf cmake.tar.gz && \ + cp -r cmake-3.12.0-Linux-x86_64/* /usr/ && \ + curl https://sh.rustup.rs -sSf | sh -s -- -y && \ + PATH=/root/.cargo/bin:$PATH && \ + RUST_BACKTRACE=1 && \ + rustc -vV && \ + cargo -V && \ + gcc -v && \ + g++ -v && \ + cmake --version && \ + cd parity-ethereum && \ + cargo build --verbose --release --features final && \ + strip /build/parity-ethereum/target/release/parity && \ + file /build/parity-ethereum/target/release/parity + + diff --git a/scripts/docker/centos/build.sh b/scripts/docker/centos/build.sh new file mode 100755 index 000000000..7215e745f --- /dev/null +++ b/scripts/docker/centos/build.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env sh + +# The image name +PARITY_IMAGE_REPO=${PARITY_IMAGE_REPO:-parity/parity} +# The tag to be used for builder image +PARITY_BUILDER_IMAGE_TAG=${PARITY_BUILDER_IMAGE_TAG:-build} +# The tag to be used for runner image +PARITY_RUNNER_IMAGE_TAG=${PARITY_RUNNER_IMAGE_TAG:-latest} + +echo Building $PARITY_IMAGE_REPO:$PARITY_BUILDER_IMAGE_TAG-$(git log -1 --format="%H") +docker build --no-cache -t $PARITY_IMAGE_REPO:$PARITY_BUILDER_IMAGE_TAG-$(git log -1 --format="%H") . -f docker/centos/Dockerfile.build + +echo Creating $PARITY_BUILDER_IMAGE_TAG-$(git log -1 --format="%H"), extracting binary +docker create --name extract $PARITY_IMAGE_REPO:$PARITY_BUILDER_IMAGE_TAG-$(git log -1 --format="%H") +mkdir docker/centos/parity +docker cp extract:/build/parity-ethereum/target/release/parity docker/centos/parity + +echo Building $PARITY_IMAGE_REPO:$PARITY_RUNNER_IMAGE_TAG +docker build --no-cache -t $PARITY_IMAGE_REPO:$PARITY_RUNNER_IMAGE_TAG docker/centos/ -f docker/centos/Dockerfile + +echo Cleaning up ... +rm -rf docker/centos/parity +docker rm -f extract +docker rmi -f $PARITY_IMAGE_REPO:$PARITY_BUILDER_IMAGE_TAG-$(git log -1 --format="%H") + +echo Echoing Parity version: +docker run $PARITY_IMAGE_REPO:$PARITY_RUNNER_IMAGE_TAG --version + +echo Done. diff --git a/scripts/docker/hub/Dockerfile b/scripts/docker/hub/Dockerfile new file mode 100644 index 000000000..4eec8cfc6 --- /dev/null +++ b/scripts/docker/hub/Dockerfile @@ -0,0 +1,27 @@ +FROM ubuntu:xenial +MAINTAINER Parity Technologies +#set ENVIROMENT +ARG TARGET +ENV TARGET ${TARGET} + +# install tools and dependencies +RUN apt update && apt install -y --no-install-recommends openssl libudev-dev file + +# show backtraces +ENV RUST_BACKTRACE 1 + +#cleanup Docker image +RUN apt autoremove -y +RUN apt clean -y +RUN rm -rf /tmp/* /var/tmp/* /var/lib/apt/lists/* + +#add TARGET to docker image +COPY artifacts/x86_64-unknown-linux-gnu/$TARGET /usr/bin/$TARGET + +# Build a shell script because the ENTRYPOINT command doesn't like using ENV +RUN echo "#!/bin/bash \n ${TARGET} \$@" > ./entrypoint.sh +RUN chmod +x ./entrypoint.sh + +# setup ENTRYPOINT +EXPOSE 5001 8080 8082 8083 8545 8546 8180 30303/tcp 30303/udp +ENTRYPOINT ["./entrypoint.sh"] diff --git a/scripts/docker/ubuntu-aarch64/Dockerfile b/scripts/docker/ubuntu-aarch64/Dockerfile new file mode 100644 index 000000000..cd8320530 --- /dev/null +++ b/scripts/docker/ubuntu-aarch64/Dockerfile @@ -0,0 +1,45 @@ +FROM ubuntu:14.04 +WORKDIR /build + +# install tools and dependencies +RUN apt-get -y update && \ + apt-get install -y --force-yes --no-install-recommends \ + curl git make g++ gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \ + libc6-arm64-cross libc6-dev-arm64-cross wget file ca-certificates \ + binutils-aarch64-linux-gnu cmake3 libudev-dev \ + && \ + apt-get clean + +# install rustup +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y + +# rustup directory +ENV PATH /root/.cargo/bin:$PATH + +ENV RUST_TARGETS="aarch64-unknown-linux-gnu" + +# multirust add arm--linux-gnuabhf toolchain +RUN rustup target add aarch64-unknown-linux-gnu + +# show backtraces +ENV RUST_BACKTRACE 1 + +# show tools +RUN rustc -vV && cargo -V + +# build parity +ADD . /build/parity +RUN cd parity && \ + mkdir -p .cargo && \ + echo '[target.aarch64-unknown-linux-gnu]\n\ + linker = "aarch64-linux-gnu-gcc"\n'\ + >>.cargo/config && \ + cat .cargo/config && \ + cargo build --target aarch64-unknown-linux-gnu --release --verbose && \ + ls /build/parity/target/aarch64-unknown-linux-gnu/release/parity && \ + /usr/bin/aarch64-linux-gnu-strip /build/parity/target/aarch64-unknown-linux-gnu/release/parity + +RUN file /build/parity/target/aarch64-unknown-linux-gnu/release/parity + +EXPOSE 8080 8545 8180 +ENTRYPOINT ["/build/parity/target/aarch64-unknown-linux-gnu/release/parity"] diff --git a/scripts/docker/ubuntu-arm/Dockerfile b/scripts/docker/ubuntu-arm/Dockerfile new file mode 100644 index 000000000..bbdc280d5 --- /dev/null +++ b/scripts/docker/ubuntu-arm/Dockerfile @@ -0,0 +1,45 @@ +FROM ubuntu:14.04 +WORKDIR /build + +# install tools and dependencies +RUN apt-get -y update && \ + apt-get install -y --force-yes --no-install-recommends \ + curl git make g++ gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf \ + libc6-dev-armhf-cross wget file ca-certificates \ + binutils-arm-linux-gnueabihf cmake3 libudev-dev \ + && \ + apt-get clean + +# install rustup +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y + +# rustup directory +ENV PATH /root/.cargo/bin:$PATH + +ENV RUST_TARGETS="arm-unknown-linux-gnueabihf" + +# multirust add arm--linux-gnuabhf toolchain +RUN rustup target add armv7-unknown-linux-gnueabihf + +# show backtraces +ENV RUST_BACKTRACE 1 + +# show tools +RUN rustc -vV && cargo -V + +# build parity +ADD . /build/parity +RUN cd parity && \ + mkdir -p .cargo && \ + echo '[target.armv7-unknown-linux-gnueabihf]\n\ + linker = "arm-linux-gnueabihf-gcc"\n'\ + >>.cargo/config && \ + cat .cargo/config && \ + cargo build --target armv7-unknown-linux-gnueabihf --release --verbose && \ + ls /build/parity/target/armv7-unknown-linux-gnueabihf/release/parity && \ + /usr/bin/arm-linux-gnueabihf-strip /build/parity/target/armv7-unknown-linux-gnueabihf/release/parity + +RUN file /build/parity/target/armv7-unknown-linux-gnueabihf/release/parity + +EXPOSE 8080 8545 8180 +ENTRYPOINT ["/build/parity/target/armv7-unknown-linux-gnueabihf/release/parity"]