You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by ko...@apache.org on 2019/10/31 00:57:51 UTC
[avro] branch master updated: AVRO-2609 Send Minimal Build Context
to Docker (#694)
This is an automated email from the ASF dual-hosted git repository.
kojiromike pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/master by this push:
new cfc8041 AVRO-2609 Send Minimal Build Context to Docker (#694)
cfc8041 is described below
commit cfc80417bb61e31c5e4ae66669b3cef27a873a13
Author: Michael A. Smith <mi...@smith-li.com>
AuthorDate: Wed Oct 30 20:57:43 2019 -0400
AVRO-2609 Send Minimal Build Context to Docker (#694)
* AVRO-2609: Avoid Unused Docker Build Context
* AVRO-2609: Move COPY to End of Dockerfile
---
build.sh | 42 ++++++++++++++++++------------------------
share/docker/Dockerfile | 8 ++++----
2 files changed, 22 insertions(+), 28 deletions(-)
diff --git a/build.sh b/build.sh
index 05ec171..838a5c4 100755
--- a/build.sh
+++ b/build.sh
@@ -15,24 +15,18 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-set -e # exit on error
+set -xe
+cd "${0%/*}"
-cd `dirname "$0"` # connect to root
-
-VERSION=`cat share/VERSION.txt`
+VERSION=$(<share/VERSION.txt)
DOCKER_XTRA_ARGS=""
-function usage {
+usage() {
echo "Usage: $0 {lint|test|dist|sign|clean|veryclean|docker [--args \"docker-args\"]|rat|githooks|docker-test}"
exit 1
}
-if [ $# -eq 0 ]
-then
- usage
-fi
-
-set -x # echo commands
+(( $# == 0 )) && usage
while (( "$#" ))
do
@@ -260,9 +254,7 @@ do
DOCKER_XTRA_ARGS=$2
shift 2
fi
- docker build -t avro-build-ci -f share/docker/Dockerfile .
- docker build -t avro-build -f share/docker/DockerfileLocal .
- if [ "$(uname -s)" == "Linux" ]; then
+ if [[ "$(uname -s)" = Linux ]]; then
USER_NAME=${SUDO_USER:=$USER}
USER_ID=$(id -u $USER_NAME)
GROUP_ID=$(id -g $USER_NAME)
@@ -271,12 +263,15 @@ do
USER_ID=1000
GROUP_ID=50
fi
- docker build -t avro-build-${USER_NAME} - <<UserSpecificDocker
-FROM avro-build
-RUN groupadd -g ${GROUP_ID} ${USER_NAME} || true
-RUN useradd -g ${GROUP_ID} -u ${USER_ID} -k /root -m ${USER_NAME} || true
-ENV HOME /home/${USER_NAME}
-UserSpecificDocker
+ {
+ cat share/docker/Dockerfile
+ grep -vF 'FROM avro-build-ci' share/docker/DockerfileLocal
+ echo "ENV HOME /home/$USER_NAME"
+ echo "RUN getent group $GROUP_ID || groupadd -g $GROUP_ID $USER_NAME"
+ echo "RUN getent passwd $USER_ID || useradd -g $GROUP_ID -u $USER_ID -k /root -m $USER_NAME"
+ } > Dockerfile
+ tar -cf- lang/ruby/Gemfile Dockerfile | docker build -t "avro-build-$USER_NAME" -
+ rm Dockerfile
# By mapping the .m2 directory you can do an mvn install from
# within the container and use the result on your normal
# system. And this also is a significant speedup in subsequent
@@ -308,7 +303,9 @@ UserSpecificDocker
;;
docker-test)
- docker build -t avro-test -f share/docker/Dockerfile .
+ tar -cf- share/docker/Dockerfile \
+ lang/ruby/Gemfile |
+ docker build -t avro-test -f share/docker/Dockerfile -
docker run --rm -v ${PWD}:/avro/ avro-test
;;
@@ -316,7 +313,4 @@ UserSpecificDocker
usage
;;
esac
-
done
-
-exit 0
diff --git a/share/docker/Dockerfile b/share/docker/Dockerfile
index 0107298..d5295d8 100644
--- a/share/docker/Dockerfile
+++ b/share/docker/Dockerfile
@@ -127,10 +127,6 @@ RUN python2 -m pip install --upgrade pip setuptools \
RUN python3 -m pip install --upgrade pip setuptools \
&& python3 -m pip install zstandard
-# Install Ruby modules
-COPY lang/ruby/Gemfile /tmp
-RUN bundle install --gemfile=/tmp/Gemfile
-
# Install .NET SDK
RUN curl -sSLO https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
@@ -139,3 +135,7 @@ RUN curl -sSLO https://packages.microsoft.com/config/ubuntu/16.04/packages-micro
&& apt-get -qqy install --no-install-recommends dotnet-sdk-2.2 \
&& apt-get -qqy clean \
&& rm -rf /var/lib/apt/lists
+
+# Install Ruby modules
+COPY lang/ruby/Gemfile /tmp
+RUN bundle install --gemfile=/tmp/Gemfile