You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2022/06/16 23:29:40 UTC

[commons-crypto] branch sebb-docker created (now 03fa61d)

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a change to branch sebb-docker
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git


      at 03fa61d  Sample build of native code

This branch includes the following new commits:

     new 03fa61d  Sample build of native code

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[commons-crypto] 01/01: Sample build of native code

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch sebb-docker
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git

commit 03fa61d15dcdbcfb24608fe7bf3ac463c9d5f080
Author: Sebb <se...@apache.org>
AuthorDate: Fri Jun 17 00:29:33 2022 +0100

    Sample build of native code
    
    Props to Alex Remily for the Dockerfile here:
    https://github.com/aremily/commons-crypto
---
 src/docker/Dockerfile          | 92 ++++++++++++++++++++++++++----------------
 src/docker/README.md           |  9 ++++-
 src/docker/build.sh            | 29 +++++++++++++
 src/docker/docker-compose.yaml | 24 +++++++++++
 4 files changed, 118 insertions(+), 36 deletions(-)

diff --git a/src/docker/Dockerfile b/src/docker/Dockerfile
index 964cfd3..f16e58b 100644
--- a/src/docker/Dockerfile
+++ b/src/docker/Dockerfile
@@ -1,11 +1,9 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
 #
 #     http://www.apache.org/licenses/LICENSE-2.0
 #
@@ -14,30 +12,54 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-#
-FROM ubuntu:bionic-20220401
-RUN dpkg --add-architecture i386
-RUN apt update
-RUN apt-get -y install gcc
-RUN apt-get -y install g++
-RUN apt-get -y install make
-RUN apt-get -y install wget curl
-RUN apt-get -y install git
-RUN apt-get -y install openjdk-8-jdk
-RUN apt-get -y -oDebug::pkgAcquire::Worker=1 install openjdk-11-jdk 
-RUN apt-get install -y mingw-w64
-# This package is documented in BUILDING.txt, but doesn't appear to be available.
-# RUN apt-get install -y x86_64-w64-mingw32-gcc
-RUN apt-get install -y gcc-mingw-w64-i686
-RUN apt-get install -y libssl-dev:i386 libssl-dev
-RUN apt-get install -y g++-multilib
-RUN mkdir -p /usr/local/build
-WORKDIR /usr/local/build
-RUN wget https://dlcdn.apache.org/maven/maven-3/3.8.5/binaries/apache-maven-3.8.5-bin.tar.gz
-RUN tar xzf apache-maven-3.8.5-bin.tar.gz
-RUN ln -s ../build/apache-maven-3.8.5/bin/mvn /usr/local/bin
-RUN git clone https://gitbox.apache.org/repos/asf/commons-crypto.git commons-crypto
-WORKDIR /usr/local/build/commons-crypto
-RUN VERSION=1.1.1-SNAPSHOT JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 make
-RUN mvn
-CMD bash
+
+# This file runs builds for the Linux-x86_64, Linux aarch64, Linux-arm, Linux-armfh and Win64 
+# architectures.  It copies the contents of the build host's project directory (commons-crypto) 
+# into the docker image, builds and tests the x86_64 build natively, and then cross compiles the 
+# remaining builds.  If you run this script from a Mac after a successful Mac build, the build in  
+# the resuing Docker image will also include the Mac build by virtue of the initial project directory
+# copy.
+
+FROM ubuntu:18.04
+
+ENV JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
+ENV MAVEN_HOME=/opt/maven
+ENV PATH=${MAVEN_HOME}/bin:${PATH}
+# Install 64-bit dependencies and tooling.
+RUN apt-get update && apt-get --assume-yes install software-properties-common \
+      && add-apt-repository ppa:openjdk-r/ppa && apt-get update \
+      && apt-get --assume-yes install openjdk-8-jdk \
+      && apt-get --assume-yes install build-essential \
+      && apt-get --assume-yes install libssl-dev \
+      && apt-get --assume-yes install gcc-aarch64-linux-gnu \
+      && apt-get --assume-yes install g++-aarch64-linux-gnu \
+      && apt-get --assume-yes install mingw-w64 \
+      && apt-get --assume-yes install wget \
+# Bug workaround see https://github.com/docker-library/openjdk/issues/19.
+      && /var/lib/dpkg/info/ca-certificates-java.postinst configure \
+# Copy the opensslconf.h file to the base openssl include directory.
+      && cp /usr/include/x86_64-linux-gnu/openssl/opensslconf.h /usr/include/openssl
+
+# Install 32-bit dependencies and tooling.
+RUN dpkg --add-architecture i386 && apt-get update \
+      && apt-get --assume-yes install libssl-dev:i386 \
+      && apt-get --assume-yes install gcc-arm-linux-gnueabi \
+      && apt-get --assume-yes install g++-arm-linux-gnueabi \
+      && apt-get --assume-yes install gcc-arm-linux-gnueabihf \
+      && apt-get --assume-yes install g++-arm-linux-gnueabihf
+
+RUN wget https://dlcdn.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz \
+&& tar xf apache-maven-*.tar.gz -C /opt && ln -s /opt/apache-maven-3.6.3 /opt/maven
+
+WORKDIR /home/build
+
+COPY build.sh .
+
+CMD /bin/bash
+
+# How to build:
+# cd docker
+# docker compose build [crypto]
+
+# To run:
+# docker compose run [--entrypoint ./build.sh] crypto
\ No newline at end of file
diff --git a/src/docker/README.md b/src/docker/README.md
index f623c99..50f7aaa 100644
--- a/src/docker/README.md
+++ b/src/docker/README.md
@@ -18,5 +18,12 @@
 # Building with Docker
 
 ```
-  docker image build -t apache/commons-crypto:<VERSION>
+  docker compose build crypto
 ```
+
+# Running with Docker
+
+```
+  docker compose run crypto # run shell
+  docker compose run --entrypoint ./build.sh crypto # run build
+```
\ No newline at end of file
diff --git a/src/docker/build.sh b/src/docker/build.sh
new file mode 100755
index 0000000..030234a
--- /dev/null
+++ b/src/docker/build.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -e
+
+cd /home/crypto # must agree with virtual mount in docker-compose.yaml
+
+# Run the 64-bit builds.
+mvn package
+mvn -DskipTests package -P linux-aarch64
+mvn -DskipTests package -P win64
+
+# Run the 32-bit builds.
+mvn -DskipTests package -P linux-armhf
+mvn -DskipTests package -P linux-arm
diff --git a/src/docker/docker-compose.yaml b/src/docker/docker-compose.yaml
new file mode 100644
index 0000000..31c54ae
--- /dev/null
+++ b/src/docker/docker-compose.yaml
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+version: '3'
+services:
+  crypto:
+    image: commons-crypto
+    build: .
+    # mount the source and Maven repo
+    volumes:
+      - ..:/home/crypto
+      - ~/.m2/repository:/root/.m2/repository