Skip to content

Commit

Permalink
GEODE-60: Scripts to build geode in a docker environment.
Browse files Browse the repository at this point in the history
Contribution from Jun Aoki.

Splitting the existing Dockerfile for running geode into a base
Dockerfile, a Dockerfile for users to run geode, and a Dockerfile to
compile geode and run tests within docker.
  • Loading branch information
upthewaterspout committed Oct 16, 2015
1 parent 1cb906c commit 23cab23
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 36 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,12 @@ Geode applications can be written in a number of client technologies:
* [Python](https://github.com/gemfire/py-gemfire-rest)
* [REST](http://geode-docs.cfapps.io/docs/geode_rest/book_intro.html)
* [[memcached|Moving from memcached to gemcached]]


# Build environment in Docker
```
dev-tools/docker/compile/start-compile-docker.sh
```


54 changes: 54 additions & 0 deletions dev-tools/docker/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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.

FROM centos:centos7
MAINTAINER Geode Community <[email protected]>

LABEL Vendor="Apache Geode (incubating)"
LABEL version=unstable

# download JDK 8
ENV JAVA_HOME /jdk1.8.0_51

RUN yum install -y wget which tar git \
&& wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jdk-8u51-linux-x64.tar.gz" \
&& tar xf jdk-8u51-linux-x64.tar.gz \
&& rm -rf $JAVA_HOME/*src.zip \
$JAVA_HOME/lib/missioncontrol \
$JAVA_HOME/lib/visualvm \
$JAVA_HOME/lib/*javafx* \
$JAVA_HOME/jre/lib/plugin.jar \
$JAVA_HOME/jre/lib/ext/jfxrt.jar \
$JAVA_HOME/jre/bin/javaws \
$JAVA_HOME/jre/lib/javaws.jar \
$JAVA_HOME/jre/lib/desktop \
$JAVA_HOME/jre/plugin \
$JAVA_HOME/jre/lib/deploy* \
$JAVA_HOME/jre/lib/*javafx* \
$JAVA_HOME/jre/lib/*jfx* \
$JAVA_HOME/jre/lib/amd64/libdecora_sse.so \
$JAVA_HOME/jre/lib/amd64/libprism_*.so \
$JAVA_HOME/jre/lib/amd64/libfxplugins.so \
$JAVA_HOME/jre/lib/amd64/libglass.so \
$JAVA_HOME/jre/lib/amd64/libgstreamer-lite.so \
$JAVA_HOME/jre/lib/amd64/libjavafx*.so \
$JAVA_HOME/jre/lib/amd64/libjfx*.so \
jdk-8u51-linux-x64.tar.gz \
/usr/share/locale/* \
&& yum clean all

ENV PATH $PATH:$JAVA_HOME/bin

30 changes: 30 additions & 0 deletions dev-tools/docker/base/build-base-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/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 -x -u

BASE_SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

export DOCKER_ENV_VERSION="0.1"
export BASE_IMAGE_NAME="geode/base:${DOCKER_ENV_VERSION}"

pushd ${BASE_SCRIPT_DIR}

docker build --rm=true -t ${BASE_IMAGE_NAME} .

popd

21 changes: 21 additions & 0 deletions dev-tools/docker/compile/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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.

FROM geode/base:0.1
MAINTAINER Geode Community <[email protected]>

LABEL Vendor="Apache Geode (incubating)"
LABEL version=unstable
62 changes: 62 additions & 0 deletions dev-tools/docker/compile/start-compile-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/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 -x -u

SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source ${SCRIPT_DIR}/../base/build-base-docker.sh

IMAGE_NAME="geode/compile:${DOCKER_ENV_VERSION}"

pushd ${SCRIPT_DIR}

docker build -t ${IMAGE_NAME} .

popd

if [ "$(uname -s)" == "Linux" ]; then
USER_NAME=${SUDO_USER:=$USER}
USER_ID=$(id -u "${USER_NAME}")
GROUP_ID=$(id -g "${USER_NAME}")
else # boot2docker uid and gid
USER_NAME=$USER
USER_ID=1000
GROUP_ID=50
fi

docker build -t "${IMAGE_NAME}-${USER_NAME}" - <<UserSpecificDocker
FROM ${IMAGE_NAME}
RUN groupadd --non-unique -g ${GROUP_ID} ${USER_NAME}
RUN useradd -g ${GROUP_ID} -u ${USER_ID} -k /root -m ${USER_NAME}
ENV HOME /home/${USER_NAME}
UserSpecificDocker

# Go to root
pushd ${SCRIPT_DIR}/../../..

docker run -i -t \
--rm=true \
-w "/home/${USER_NAME}/incubator-geode" \
-u "${USER_NAME}" \
-v "$PWD:/home/${USER_NAME}/incubator-geode" \
-v "/home/${USER_NAME}/.m2:/home/${USER_NAME}/.m2" \
${IMAGE_NAME}-${USER_NAME} \
bash

popd

56 changes: 23 additions & 33 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,48 +1,38 @@
FROM centos:latest
MAINTAINER William Markito <[email protected]>
# 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.

FROM geode/base:0.1
MAINTAINER Geode Community <[email protected]>

LABEL Vendor="Apache Geode (incubating)"
LABEL version=unstable

# download JDK 8
ENV JAVA_HOME /jdk1.8.0_51
# ENV JAVA_HOME /jdk1.8.0_51

RUN yum install -y wget which tar git \
&& wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jdk-8u51-linux-x64.tar.gz" \
&& tar xf jdk-8u51-linux-x64.tar.gz \
&& git clone -b develop https://github.com/apache/incubator-geode.git \
RUN git clone -b develop https://github.com/apache/incubator-geode.git \
&& cd incubator-geode \
&& ./gradlew build -Dskip.tests=true \
&& ls /incubator-geode | grep -v gemfire-assembly | xargs rm -rf \
&& rm -rf /root/.gradle/ \
&& rm -rf /incubator-geode/gemfire-assembly/build/distributions/ \
&& rm -rf /jdk-8u51-linux-x64.tar.gz \
&& rm -rf $JAVA_HOME/*src.zip \
$JAVA_HOME/lib/missioncontrol \
$JAVA_HOME/lib/visualvm \
$JAVA_HOME/lib/*javafx* \
$JAVA_HOME/jre/lib/plugin.jar \
$JAVA_HOME/jre/lib/ext/jfxrt.jar \
$JAVA_HOME/jre/bin/javaws \
$JAVA_HOME/jre/lib/javaws.jar \
$JAVA_HOME/jre/lib/desktop \
$JAVA_HOME/jre/plugin \
$JAVA_HOME/jre/lib/deploy* \
$JAVA_HOME/jre/lib/*javafx* \
$JAVA_HOME/jre/lib/*jfx* \
$JAVA_HOME/jre/lib/amd64/libdecora_sse.so \
$JAVA_HOME/jre/lib/amd64/libprism_*.so \
$JAVA_HOME/jre/lib/amd64/libfxplugins.so \
$JAVA_HOME/jre/lib/amd64/libglass.so \
$JAVA_HOME/jre/lib/amd64/libgstreamer-lite.so \
$JAVA_HOME/jre/lib/amd64/libjavafx*.so \
$JAVA_HOME/jre/lib/amd64/libjfx*.so \
&& rm -rf /usr/share/locale/* \
&& yum remove -y perl \
&& yum clean all
&& yum remove -y perl

ENV GEODE_HOME /incubator-geode/gemfire-assembly/build/install/apache-geode
ENV PATH $PATH:$GEODE_HOME/bin:$JAVA_HOME/bin
ENV PATH $PATH:$GEODE_HOME/bin

# Default ports:
# RMI/JMX 1099
Expand All @@ -53,4 +43,4 @@ ENV PATH $PATH:$GEODE_HOME/bin:$JAVA_HOME/bin
EXPOSE 8080 10334 40404 1099 7070
VOLUME ["/data/"]
CMD ["gfsh"]
#ENTRYPOINT ["gfsh"]

6 changes: 3 additions & 3 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Building the container image

The current Dockerfile is based on a CentOS 6 image, downloads JDK 8, clone the Apache Geode git repository, starts a build and execute the basic tests.
The current Dockerfile is based on a CentOS 7 image, downloads JDK 8, clone the Apache Geode git repository, starts a build and execute the basic tests.

```
docker build -t apachegeode/geode:unstable .
./build-runtime-docker.sh
```

This may take a while depending on your internet connection, but it's worth since this is a one time step and you endup with a container that is tested and ready to be used for development. It will download Gradle and as part of the build, project dependencies as well.
Expand All @@ -13,7 +13,7 @@ This may take a while depending on your internet connection, but it's worth sinc
1. Then you can start gfsh as well in order to perform more commands:

```
docker run -it -p 10334:10334 -p 7575:7575 -p 1099:1099 apachegeode/geode:unstable gfsh
docker run --rm=true -it -p 10334:10334 -p 7575:7575 -p 1099:1099 geode/runtime:0.1 gfsh
```


Expand Down
32 changes: 32 additions & 0 deletions docker/build-runtime-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/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 -x -u

SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

source ${SCRIPT_DIR}/../dev-tools/docker/base/build-base-docker.sh

IMAGE_NAME="geode/runtime:${DOCKER_ENV_VERSION}"

pushd ${SCRIPT_DIR}

# Build runtime image
docker build --rm=true -t ${IMAGE_NAME} .

popd

0 comments on commit 23cab23

Please sign in to comment.