This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make a new Kubernetes friendly Docker image (#1499)
The following PIE-1598 subtasks are fixed: fixes PIE-1600 remove entrypoint script fixes PIE-1601 investigate Dockerfile best practices including : - naming - multi step build - comments - labels - build args - entrypoint - minimalism fixes PIE-1604 rewrite Dockerfile according to best practices provide a sample build command that can be used as-is or as an example. Added contents to .dockerignore to make the intermediate build image smaller. Remove .env file that was supposed to be used long ago for a docker quickstart and that we forgot to remove ans is useless today. add jenkins pipeline to test the docker image build
- Loading branch information
1 parent
741ebfc
commit d4bbeae
Showing
11 changed files
with
356 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,15 @@ | ||
.github | ||
.gradle | ||
.idea | ||
.vertx | ||
build | ||
build | ||
kubernetes | ||
Dockerfile | ||
|
||
#Exclude doc related resources | ||
docs | ||
mkdocs.yml | ||
readthedocs.yml | ||
*.md | ||
|
||
Jenkins* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,5 @@ tmp/ | |
build/ | ||
out/ | ||
site/ | ||
/kubernetes/reports/ | ||
/kubernetes/pantheon-*.tar.gz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# extract image stage | ||
# extractin here reduces the number of layers in the final image | ||
FROM alpine:3.9 AS extract-stage | ||
# Copy Pantheon binaries from previous jenkins artefact step | ||
# or from the result of ./gradlew distTar | ||
# and lett ADD unpack them | ||
ADD pantheon-*.tar.gz /tmp/ | ||
|
||
# Run image stage | ||
# Use openJDK JRE only for running pantheon | ||
FROM openjdk:11.0.2-jre-slim-stretch | ||
# Copy extracted binaries from the previous step image | ||
COPY --from=extract-stage /tmp/pantheon* /opt/pantheon | ||
WORKDIR /opt/pantheon | ||
# Expose services ports | ||
# 8545 HTTP JSON-RPC | ||
# 8546 WS JSON-RPC | ||
# 8547 HTTP GraphQL | ||
# 30303 P2P | ||
EXPOSE 8545 8546 8547 30303 | ||
ENTRYPOINT ["/opt/pantheon/bin/pantheon"] | ||
# Build-time metadata as defined at http://label-schema.org | ||
# Use the build_image.sh script in the kubernetes directory of this project to | ||
# easily build this image or as an example of how to inject build parameters. | ||
ARG BUILD_DATE | ||
ARG VCS_REF | ||
ARG VERSION | ||
LABEL org.label-schema.build-date=$BUILD_DATE \ | ||
org.label-schema.name="Pantheon" \ | ||
org.label-schema.description="Enterprise Ethereum client" \ | ||
org.label-schema.url="https://docs.pantheon.pegasys.tech/" \ | ||
org.label-schema.vcs-ref=$VCS_REF \ | ||
org.label-schema.vcs-url="https://github.com/PegaSysEng/pantheon.git" \ | ||
org.label-schema.vendor="Pegasys" \ | ||
org.label-schema.version=$VERSION \ | ||
org.label-schema.schema-version="1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/bin/sh -e | ||
# This script presents a sample way to build Pantheon Docker image | ||
# with automatic build arguments from the current build workspace. | ||
# It must be started from the same path as where the Dockerfile is located. | ||
# you have to pass the imnage tag as an argument like for instance : | ||
# build_image.sh "pegasyseng/pantheon-kubernetes:develop" | ||
|
||
CONTEXT_FOLDER=kubernetes/ | ||
PANTHEON_BUILD_SOURCE='build/distributions/pantheon-*.tar.gz' | ||
|
||
# Checking that you passed the tag for the image to be build | ||
if [ -z "$1" ] | ||
then | ||
me=`basename "$0"` | ||
echo "No image tag argument supplied to ${me}" | ||
echo "ex.: ${me} \"pegasyseng/pantheon-kubernetes:develop\"" | ||
exit 1 | ||
fi | ||
|
||
# looking for the distribution archive, either form CI step that builds form this | ||
# workspace sources but with multiple test steps first | ||
# or it builds it if you don't have one as you are probably | ||
# not in a CI step. | ||
if ls ${PANTHEON_BUILD_SOURCE} 1> /dev/null 2>&1; then | ||
cp ${PANTHEON_BUILD_SOURCE} ${CONTEXT_FOLDER} | ||
else | ||
echo "No pantheon-*.tar.gz archive found." | ||
echo "You are probably not running this from CI so running './gradlew distTar' first to have a local build" | ||
./gradlew distTar | ||
cp ${PANTHEON_BUILD_SOURCE} ${CONTEXT_FOLDER} | ||
fi | ||
|
||
# Builds docker image with tags matching the info form this current workspace | ||
docker build \ | ||
-t "$1" \ | ||
--build-arg BUILD_DATE="`date`" \ | ||
--build-arg VCS_REF="`git show -s --format=%h`" \ | ||
--build-arg VERSION="`grep -oE "version=(.*)" gradle.properties | cut -d= -f2`" \ | ||
${CONTEXT_FOLDER} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
export GOSS_PATH=tests/goss-linux-amd64 | ||
export GOSS_OPTS="$GOSS_OPTS --format junit" | ||
export GOSS_FILES_STRATEGY=cp | ||
DOCKER_IMAGE=$1 | ||
|
||
i=0 | ||
|
||
# Test for normal startup with ports opened | ||
GOSS_FILES_PATH=tests/01 \ | ||
bash tests/dgoss \ | ||
run $DOCKER_IMAGE \ | ||
--network=dev \ | ||
--p2p-host=0.0.0.0 \ | ||
--rpc-http-enabled \ | ||
--rpc-http-host=0.0.0.0 \ | ||
--rpc-ws-enabled \ | ||
--rpc-ws-host=0.0.0.0 \ | ||
--graphql-http-enabled \ | ||
--graphql-http-host=0.0.0.0 \ | ||
> ./reports/01.xml || i=`expr $i + 1` | ||
|
||
exit $i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
file: | ||
/opt/pantheon/bin/pantheon: | ||
exists: true | ||
mode: "0755" | ||
owner: root | ||
group: root | ||
filetype: file | ||
contains: [] | ||
/opt/pantheon/database: | ||
exists: true | ||
mode: "0755" | ||
owner: root | ||
group: root | ||
filetype: directory | ||
contains: [] | ||
/opt/pantheon/key: | ||
exists: true | ||
mode: "0600" | ||
owner: root | ||
group: root | ||
filetype: file | ||
contains: [] | ||
port: | ||
tcp:8545: | ||
listening: true | ||
tcp:8546: | ||
listening: true | ||
tcp:8547: | ||
listening: true | ||
tcp:30303: | ||
listening: true | ||
ip: | ||
- 0.0.0.0 | ||
udp:30303: | ||
listening: true | ||
ip: | ||
- 0.0.0.0 | ||
process: | ||
java: | ||
running: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
port: | ||
tcp:30303: | ||
listening: true | ||
ip: | ||
- 0.0.0.0 | ||
tcp:8545: | ||
listening: true | ||
ip: | ||
- 0.0.0.0 | ||
tcp:8546: | ||
listening: true | ||
ip: | ||
- 0.0.0.0 | ||
tcp:8547: | ||
listening: true | ||
ip: | ||
- 0.0.0.0 |
Oops, something went wrong.