WIP: Subkey docker image (#3183)

* WIP to release subkey im docker

* debug run with publishing

* debug build

* debug build 2

* easier sync

* fix the template

* fix typo
This commit is contained in:
TriplEight
2019-07-26 02:40:53 +02:00
committed by Gavin Wood
parent a5efdd05d7
commit d98f3c6023
3 changed files with 114 additions and 35 deletions
+83 -35
View File
@@ -106,7 +106,7 @@ cargo-check-subkey:
- /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 - /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
script: script:
- cd ./subkey - cd ./subkey
- BUILD_DUMMY_WASM_BINARY=1 time cargo check --release # makes sense to save artifacts for building it - BUILD_DUMMY_WASM_BINARY=1 time cargo check --release
- sccache -s - sccache -s
@@ -172,11 +172,13 @@ test-linux-stable-int:
expire_in: 24 hrs expire_in: 24 hrs
paths: paths:
- ${CI_COMMIT_SHORT_SHA}_int_failure.log - ${CI_COMMIT_SHORT_SHA}_int_failure.log
allow_failure: true
check-web-wasm: check-web-wasm:
stage: test stage: test
<<: *docker-env <<: *docker-env
allow_failure: true
except: except:
- /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1 - /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
script: script:
@@ -218,33 +220,33 @@ build-linux-release:
stage: build stage: build
<<: *collect-artifacts <<: *collect-artifacts
<<: *docker-env <<: *docker-env
<<: *build-only # debug <<: *build-only
except: except:
variables: variables:
- $DEPLOY_TAG - $DEPLOY_TAG
script: script:
- time cargo build --release --verbose - time cargo build --release --verbose
- mkdir -p ./artifacts - mkdir -p ./artifacts/substrate/
- mv ./target/release/substrate ./artifacts/. - mv ./target/release/substrate ./artifacts/substrate/.
- echo -n "Substrate version = " - echo -n "Substrate version = "
- if [ "${CI_COMMIT_TAG}" ]; then - if [ "${CI_COMMIT_TAG}" ]; then
echo "${CI_COMMIT_TAG}" | tee ./artifacts/VERSION; echo "${CI_COMMIT_TAG}" | tee ./artifacts/substrate/VERSION;
else else
./artifacts/substrate --version | ./artifacts/substrate/substrate --version |
sed -n -r 's/^substrate ([0-9.]+.*-[0-9a-f]{7,13})-.*$/\1/p' | sed -n -r 's/^substrate ([0-9.]+.*-[0-9a-f]{7,13})-.*$/\1/p' |
tee ./artifacts/VERSION; tee ./artifacts/substrate/VERSION;
fi fi
- sha256sum ./artifacts/substrate | tee ./artifacts/substrate.sha256 - sha256sum ./artifacts/substrate/substrate | tee ./artifacts/substrate/substrate.sha256
- printf '\n# building node-template\n\n' - printf '\n# building node-template\n\n'
- ./scripts/node-template-release.sh ./artifacts/substrate-node-template.tar.gz - ./scripts/node-template-release.sh ./artifacts/substrate/substrate-node-template.tar.gz
- cp -r scripts/docker/* ./artifacts - cp -r scripts/docker/substrate.Dockerfile ./artifacts/substrate/
- sccache -s - sccache -s
build-linux-subkey: build-linux-subkey:
stage: build stage: build
<<: *collect-artifacts <<: *collect-artifacts
<<: *docker-env <<: *docker-env
# <<: *build-only # debug <<: *build-only
except: except:
variables: variables:
- $DEPLOY_TAG - $DEPLOY_TAG
@@ -252,19 +254,21 @@ build-linux-subkey:
- cd ./subkey - cd ./subkey
- BUILD_DUMMY_WASM_BINARY=1 time cargo build --release --verbose - BUILD_DUMMY_WASM_BINARY=1 time cargo build --release --verbose
- cd .. - cd ..
# - time cargo build --release
- sccache -s - sccache -s
- mkdir -p ./artifacts - mkdir -p ./artifacts/subkey
- mv ./target/release/subkey ./artifacts/. - mv ./target/release/subkey ./artifacts/subkey/.
- echo -n "Subkey version = " - echo -n "Subkey version = "
- ./artifacts/subkey --version | - ./artifacts/subkey/subkey --version |
sed -n -r 's/^subkey ([0-9.]+.*)/\1/p' | sed -n -r 's/^subkey ([0-9.]+.*)/\1/p' |
tee ./artifacts/SUBKEY-VERSION; tee ./artifacts/subkey/VERSION;
- sha256sum ./artifacts/subkey | tee ./artifacts/subkey.sha256 - sha256sum ./artifacts/subkey/subkey | tee ./artifacts/subkey/subkey.sha256
- cp -r scripts/docker/subkey.Dockerfile ./artifacts/subkey/
- sccache -s
build-rust-doc-release: build-rust-doc-release:
stage: build stage: build
<<: *docker-env <<: *docker-env
allow_failure: true allow_failure: true
artifacts: artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}-doc" name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}-doc"
@@ -290,8 +294,13 @@ build-rust-doc-release:
<<: *build-only <<: *build-only
<<: *kubernetes-build <<: *kubernetes-build
publish-docker-release: publish-docker-substrate: &publish-docker-release
<<: *publish-build # debug <<: *publish-build
stage: publish
dependencies:
- build-linux-release
<<: *kubernetes-build
# debug
image: docker:stable image: docker:stable
services: services:
- docker:dind - docker:dind
@@ -301,7 +310,7 @@ publish-docker-release:
DOCKER_HOST: tcp://localhost:2375 DOCKER_HOST: tcp://localhost:2375
DOCKER_DRIVER: overlay2 DOCKER_DRIVER: overlay2
GIT_STRATEGY: none GIT_STRATEGY: none
# DOCKERFILE: scripts/docker/Dockerfile # DOCKERFILE: scripts/docker/substrate.Dockerfile
CONTAINER_IMAGE: parity/substrate CONTAINER_IMAGE: parity/substrate
before_script: before_script:
- test "$Docker_Hub_User_Parity" -a "$Docker_Hub_Pass_Parity" - test "$Docker_Hub_User_Parity" -a "$Docker_Hub_Pass_Parity"
@@ -309,38 +318,77 @@ publish-docker-release:
- docker login -u "$Docker_Hub_User_Parity" -p "$Docker_Hub_Pass_Parity" - docker login -u "$Docker_Hub_User_Parity" -p "$Docker_Hub_Pass_Parity"
- docker info - docker info
script: script:
- VERSION="$(cat ./artifacts/VERSION)" - cd ./artifacts/substrate/
- VERSION="$(cat ./VERSION)"
- echo "Substrate version = ${VERSION}" - echo "Substrate version = ${VERSION}"
- test -z "${VERSION}" && exit 1 - test -z "${VERSION}" && exit 1
- cd ./artifacts
- docker build - docker build
--build-arg VCS_REF="${CI_COMMIT_SHA}" --build-arg VCS_REF="${CI_COMMIT_SHA}"
--build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" --build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
--tag $CONTAINER_IMAGE:$VERSION --tag $CONTAINER_IMAGE:$VERSION
--tag $CONTAINER_IMAGE:latest . --tag $CONTAINER_IMAGE:latest
--file substrate.Dockerfile .
- docker push $CONTAINER_IMAGE:$VERSION - docker push $CONTAINER_IMAGE:$VERSION
- docker push $CONTAINER_IMAGE:latest - docker push $CONTAINER_IMAGE:latest
after_script: after_script:
- docker logout - docker logout
# only VERSION information is needed for the deployment # only VERSION information is needed for the deployment
- find ./artifacts/ -depth -not -name VERSION -not -name artifacts -delete - find ./artifacts/ -depth -not -name VERSION -type f -delete
publish-docker-subkey:
# debug <<: *publish-docker-release
stage: publish
dependencies:
- build-linux-subkey
# debug <<: *build-only
<<: *kubernetes-build
image: docker:stable
services:
- docker:dind
variables:
DOCKER_HOST: tcp://localhost:2375
DOCKER_DRIVER: overlay2
GIT_STRATEGY: none
# DOCKERFILE: scripts/docker/subkey.Dockerfile
CONTAINER_IMAGE: parity/subkey
before_script:
- test "$Docker_Hub_User_Parity" -a "$Docker_Hub_Pass_Parity"
|| ( echo "no docker credentials provided"; exit 1 )
- docker login -u "$Docker_Hub_User_Parity" -p "$Docker_Hub_Pass_Parity"
- docker info
script:
- cd ./artifacts/subkey/
- VERSION="$(cat ./VERSION)"
- echo "Subkey version = ${VERSION}"
- test -z "${VERSION}" && exit 1
- docker build
--build-arg VCS_REF="${CI_COMMIT_SHA}"
--build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
--tag $CONTAINER_IMAGE:$VERSION
--tag $CONTAINER_IMAGE:latest
--file subkey.Dockerfile .
- docker push $CONTAINER_IMAGE:$VERSION
- docker push $CONTAINER_IMAGE:latest
after_script:
- docker logout
publish-s3-release: publish-s3-release:
<<: *publish-build # debug <<: *publish-build
stage: publish
dependencies:
- build-linux-release
- build-linux-subkey
<<: *kubernetes-build
# debug
image: parity/awscli:latest image: parity/awscli:latest
variables: variables:
GIT_STRATEGY: none GIT_STRATEGY: none
BUCKET: "releases.parity.io" BUCKET: "releases.parity.io"
PREFIX: "substrate/${ARCH}-${DOCKER_OS}" PREFIX: "substrate/${ARCH}-${DOCKER_OS}"
script: script:
- aws s3 sync ./artifacts/ s3://${BUCKET}/${PREFIX}/$(cat ./artifacts/VERSION)/ - aws s3 sync ./artifacts/ s3://${BUCKET}/${PREFIX}/$(cat ./artifacts/substrate/VERSION)/
- echo "update objects in latest path" - echo "update objects in latest path"
- for file in ./artifacts/*; do - aws s3 sync s3://${BUCKET}/${PREFIX}/$(cat ./artifacts/substrate/VERSION)/ s3://${BUCKET}/${PREFIX}/latest/
name="$(basename ${file})";
aws s3api copy-object
--copy-source ${BUCKET}/${PREFIX}/$(cat ./artifacts/VERSION)/${name}
--bucket ${BUCKET} --key ${PREFIX}/latest/${name};
done
after_script: after_script:
- aws s3 ls s3://${BUCKET}/${PREFIX}/latest/ - aws s3 ls s3://${BUCKET}/${PREFIX}/latest/
--recursive --human-readable --summarize --recursive --human-readable --summarize
@@ -423,8 +471,8 @@ publish-gh-doc:
- kubernetes-parity-build - kubernetes-parity-build
before_script: before_script:
- test -z "${DEPLOY_TAG}" && - test -z "${DEPLOY_TAG}" &&
test -f ./artifacts/VERSION && test -f ./artifacts/substrate/VERSION &&
DEPLOY_TAG="$(cat ./artifacts/VERSION)" DEPLOY_TAG="$(cat ./artifacts/substrate/VERSION)"
- test "${DEPLOY_TAG}" || ( echo "Neither DEPLOY_TAG nor VERSION information available"; exit 1 ) - test "${DEPLOY_TAG}" || ( echo "Neither DEPLOY_TAG nor VERSION information available"; exit 1 )
script: script:
- echo "Substrate version = ${DEPLOY_TAG}" - echo "Substrate version = ${DEPLOY_TAG}"
@@ -450,7 +498,7 @@ publish-gh-doc:
.deploy-cibuild: &deploy-cibuild .deploy-cibuild: &deploy-cibuild
<<: *deploy <<: *deploy
dependencies: dependencies:
- publish-docker-release - publish-docker-substrate
.deploy-tag: &deploy-tag .deploy-tag: &deploy-tag
<<: *deploy <<: *deploy
@@ -0,0 +1,31 @@
FROM debian:stretch-slim
# metadata
ARG VCS_REF
ARG BUILD_DATE
LABEL io.parity.image.authors="devops-team@parity.io" \
io.parity.image.vendor="Parity Technologies" \
io.parity.image.title="parity/subkey" \
io.parity.image.description="Subkey: key generating utility for Substrate." \
io.parity.image.source="https://github.com/paritytech/substrate/blob/${VCS_REF}/scripts/docker/subkey.Dockerfile" \
io.parity.image.revision="${VCS_REF}" \
io.parity.image.created="${BUILD_DATE}" \
io.parity.image.documentation="https://github.com/paritytech/substrate/tree/${VCS_REF}/subkey"
# show backtraces
ENV RUST_BACKTRACE 1
# add user
RUN useradd -m -u 1000 -U -s /bin/sh -d /subkey subkey
# add subkey binary to docker image
COPY ./subkey /usr/local/bin
USER subkey
# check if executable works in this container
RUN /usr/local/bin/subkey --version
ENTRYPOINT ["/usr/local/bin/subkey"]