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

madhan pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 182c1bd  ATLAS-3934: docker scripts to build and run Apache Atlas in 
containers
182c1bd is described below

commit 182c1bdb35d3817ddb82511da1c39acd971eedbc
Author: Madhan Neethiraj <[email protected]>
AuthorDate: Fri Sep 11 00:11:27 2020 -0700

    ATLAS-3934: docker scripts to build and run Apache Atlas in containers
    
    (cherry picked from commit 9b1d4c387fb56d08bfc86150b0cff7d071540109)
---
 dev-support/atlas-docker/.dockerignore             |  4 ++
 dev-support/atlas-docker/Dockerfile.atlas          | 30 +++++++++
 dev-support/atlas-docker/Dockerfile.atlas-base     | 42 +++++++++++++
 dev-support/atlas-docker/Dockerfile.atlas-build    | 49 +++++++++++++++
 dev-support/atlas-docker/README.md                 | 73 +++++++++++++++-------
 dev-support/atlas-docker/dist/.gitignore           |  1 +
 .../atlas-docker/docker-compose.atlas-base.yml     | 12 ++++
 .../atlas-docker/docker-compose.atlas-build.yml    | 27 ++++++++
 dev-support/atlas-docker/docker-compose.atlas.yml  | 22 +++++++
 dev-support/atlas-docker/patches/.gitignore        |  1 +
 dev-support/atlas-docker/scripts/atlas-build.sh    | 62 ++++++++++++++++++
 dev-support/atlas-docker/scripts/atlas.sh          | 41 ++++++++++++
 12 files changed, 343 insertions(+), 21 deletions(-)

diff --git a/dev-support/atlas-docker/.dockerignore 
b/dev-support/atlas-docker/.dockerignore
new file mode 100644
index 0000000..d6a8480
--- /dev/null
+++ b/dev-support/atlas-docker/.dockerignore
@@ -0,0 +1,4 @@
+*
+!config
+!dist/apache-atlas-*-bin.tar.gz
+!scripts/*
diff --git a/dev-support/atlas-docker/Dockerfile.atlas 
b/dev-support/atlas-docker/Dockerfile.atlas
new file mode 100644
index 0000000..b90a1ca
--- /dev/null
+++ b/dev-support/atlas-docker/Dockerfile.atlas
@@ -0,0 +1,30 @@
+# 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 atlas-base:latest
+
+
+COPY ./scripts/atlas.sh                              ${ATLAS_SCRIPTS}/
+COPY ./dist/apache-atlas-${ATLAS_VERSION}-bin.tar.gz /tmp/
+
+RUN tar xfz /tmp/apache-atlas-${ATLAS_VERSION}-bin.tar.gz --directory=/opt/ && 
\
+    ln -s /opt/apache-atlas-${ATLAS_VERSION} ${ATLAS_HOME} && \
+    rm -f /tmp/apache-atlas-${ATLAS_VERSION}-bin.tar.gz && \
+    mkdir -p /var/run/atlas && \
+    mkdir -p /var/log/atlas && \
+    chown -R atlas:atlas ${ATLAS_HOME}/ /var/run/atlas/ /var/log/atlas/
+
+ENTRYPOINT [ "/home/atlas/scripts/atlas.sh" ]
diff --git a/dev-support/atlas-docker/Dockerfile.atlas-base 
b/dev-support/atlas-docker/Dockerfile.atlas-base
new file mode 100644
index 0000000..b7c86ab
--- /dev/null
+++ b/dev-support/atlas-docker/Dockerfile.atlas-base
@@ -0,0 +1,42 @@
+# 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 ubuntu:20.04
+
+
+ENV ATLAS_VERSION 3.0.0-SNAPSHOT
+
+# Install curl, wget, tzdata, Python, Java
+RUN apt-get update && \
+    DEBIAN_FRONTEND="noninteractive" apt-get -y install curl wget tzdata \
+    python python3 python3-pip openjdk-8-jdk bc iputils-ping ssh pdsh
+
+# Set environment variables
+ENV JAVA_HOME      /usr/lib/jvm/java-8-openjdk-amd64
+ENV ATLAS_DIST    /home/atlas/dist
+ENV ATLAS_HOME    /opt/atlas
+ENV ATLAS_SCRIPTS /home/atlas/scripts
+ENV PATH          
/usr/java/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+
+
+# setup groups, users, directories
+RUN groupadd atlas && \
+    useradd -g atlas -ms /bin/bash atlas && \
+    mkdir -p /home/atlas/dist && \
+    mkdir -p /home/atlas/scripts && \
+    chown -R atlas:atlas /home/atlas
+
+ENTRYPOINT [ "/bin/bash" ]
diff --git a/dev-support/atlas-docker/Dockerfile.atlas-build 
b/dev-support/atlas-docker/Dockerfile.atlas-build
new file mode 100644
index 0000000..58d127a
--- /dev/null
+++ b/dev-support/atlas-docker/Dockerfile.atlas-build
@@ -0,0 +1,49 @@
+# 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 atlas-base:latest
+
+
+# Install necessary packages to build Atlas
+RUN apt-get update && apt-get -y install git maven
+
+# Set environment variables
+ENV MAVEN_HOME /usr/share/maven
+ENV PATH       
/usr/java/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/apache-maven/bin
+
+# setup atlas group, and users
+RUN mkdir -p /home/atlas/git && \
+    mkdir -p /home/atlas/.m2 && \
+    mkdir -p /home/atlas/scripts && \
+    mkdir -p /home/atlas/patches && \
+    mkdir -p /home/atlas/dist && \
+       chown -R atlas:atlas /home/atlas
+
+COPY ./scripts/atlas-build.sh /home/atlas/scripts/
+
+VOLUME /home/atlas/.m2
+VOLUME /home/atlas/scripts
+VOLUME /home/atlas/patches
+VOLUME /home/atlas/dist
+VOLUME /home/atlas/src
+
+USER atlas
+
+WORKDIR /home/atlas/git
+
+RUN git clone https://github.com/apache/atlas.git
+
+ENTRYPOINT [ "/home/atlas/scripts/atlas-build.sh" ]
diff --git a/dev-support/atlas-docker/README.md 
b/dev-support/atlas-docker/README.md
index 5296f05..21f9b75 100644
--- a/dev-support/atlas-docker/README.md
+++ b/dev-support/atlas-docker/README.md
@@ -17,31 +17,62 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-# atlas_docker
-
 ## Overview
 
-The Dockerfile in this folder can be used to build a Docker image running
-the latest Atlas master branch in standalone mode. It does this by setting
-up necessary dependencies, checking out the master branch of Atlas from
-GitHub, and then building Atlas. By default, this image will start the Atlas
-on port 21000.
+Docker files in this folder create docker images and run them to build Apache 
Atlas, deploy Apache Atlas and dependent services in containers.
 
 ## Usage
 
+1. Ensure that you have recent version of Docker installed from 
[docker.io](http://www.docker.io) (as of this writing: Engine 19.03, Compose 
1.26.2).
 
-1. Ensure that you have a recent version of Docker installed from
-   [docker.io](http://www.docker.io).
 2. Set this folder as your working directory.
-3. Type `docker build -t atlas_docker .` to build a Docker image called 
**atlas_docker**.
-   This may take 20 minutes or more the first time you run the command since 
it will
-   create a Maven repository inside the image as well as checkout the master 
branch
-   of Atlas. Note that by default unit tests are skipped, to run unit tests 
within
-   the image remove the '-DskipTests' in the Dockerfile
-4. When this completes successfully, you can run `docker run -it -p 
21000:21000 atlas_docker`
-   to access an Atlas server running inside of a container created from the
-   **atlas_docker** image. Alternatively, you can type `docker run -it 
atlas_docker
-   bash` to start a container without a running Atlas. Within this environment,
-   Atlas is built in /root/atlas-bin.
-5. When you run command `docker run -it -p 21000:21000 atlas_docker` 
successfully, you can
-   access Atlas UI from a browser at http://localhost:21000.
+
+3. Using docker-compose is the simpler way to build and deploy Apache Atlas in 
containers.
+
+   3.1. Execute following command to build Apache Atlas:
+
+        docker-compose -f docker-compose.atlas-base.yml -f 
docker-compose.atlas-build.yml up
+
+   Time taken to complete the build might vary (upto an hour), depending on 
status of ${HOME}/.m2 directory cache.
+
+   3.2. Execute following command to install and start Atlas in a container:
+
+        docker-compose -f docker-compose.atlas-base.yml -f 
docker-compose.atlas.yml up -d
+
+   Apache Atlas will be installed at /opt/atlas/, and logs are at 
/opt/atlas/logs directory.
+
+4. Alternatively docker command can be used to build and deploy Apache Atlas.
+
+   4.1. Execute following command to build Docker image **atlas-base**:
+
+        docker build -f Dockerfile.atlas-base -t atlas-base .
+
+   This might take about 10 minutes to complete.
+
+   4.2. Execute following command to build Docker image **atlas-build**:
+
+        docker build -f Dockerfile.atlas-build -t atlas-build .
+
+   4.3. Build Apache Atlas in a container with one of the following commands:
+
+        # to build from a specific branch
+        docker run -it --rm -v ${HOME}/.m2:/home/atlas/.m2 -v 
$(pwd)/scripts:/home/atlas/scripts -v $(pwd)/patches:/home/atlas/patches -v 
$(pwd)/dist:/home/atlas/dist -e BRANCH=master -e PROFILE=dist,berkeley-solr -e 
SKIPTESTS=true atlas-build
+
+        # to build from local sources
+        docker run -it --rm -v ${HOME}/.m2:/home/atlas/.m2 -v 
$(pwd)/scripts:/home/atlas/scripts -v $(pwd)/../..:/home/atlas/src -v 
$(pwd)/dist:/home/atlas/dist -e PROFILE=dist,berkeley-solr -e SKIPTESTS=true 
atlas-build
+
+   Time taken to complete the build might vary (upto an hour), depending on 
status of ${HOME}/.m2 directory cache.
+
+   4.4. Execute following command to build Docker image **atlas**:
+
+        docker build -f Dockerfile.atlas -t atlas .
+
+   This might take about 10 minutes to complete.
+
+   4.8. Execute following command to install and run Atlas services in a 
container:
+
+        docker run -it -d --name atlas --hostname atlas.example.com -p 
21000:21000 atlas
+
+   This might take few minutes to complete.
+
+5. Atlas Admin can be accessed at http://localhost:21000 (admin/atlasR0cks!)
diff --git a/dev-support/atlas-docker/dist/.gitignore 
b/dev-support/atlas-docker/dist/.gitignore
new file mode 100644
index 0000000..72e8ffc
--- /dev/null
+++ b/dev-support/atlas-docker/dist/.gitignore
@@ -0,0 +1 @@
+*
diff --git a/dev-support/atlas-docker/docker-compose.atlas-base.yml 
b/dev-support/atlas-docker/docker-compose.atlas-base.yml
new file mode 100644
index 0000000..81c421a
--- /dev/null
+++ b/dev-support/atlas-docker/docker-compose.atlas-base.yml
@@ -0,0 +1,12 @@
+version: '3'
+services:
+  atlas-base:
+    build:
+      context: .
+      dockerfile: Dockerfile.atlas-base
+    image: atlas-base
+    networks:
+      - atlas
+
+networks:
+  atlas:
diff --git a/dev-support/atlas-docker/docker-compose.atlas-build.yml 
b/dev-support/atlas-docker/docker-compose.atlas-build.yml
new file mode 100644
index 0000000..a1bc2f7
--- /dev/null
+++ b/dev-support/atlas-docker/docker-compose.atlas-build.yml
@@ -0,0 +1,27 @@
+version: '3'
+services:
+  atlas-build:
+    build:
+      context: .
+      dockerfile: Dockerfile.atlas-build
+    image: atlas-build
+    container_name: atlas-build
+    hostname: atlas-build.example.com
+    stdin_open: true
+    tty: true
+    networks:
+      - atlas
+    volumes:
+      - ~/.m2:/home/atlas/.m2
+      - ./scripts:/home/atlas/scripts
+      - ./patches:/home/atlas/patches
+      - ./dist:/home/atlas/dist
+    depends_on:
+      - atlas-base
+    environment:
+      BRANCH: 'master'
+      SKIPTESTS: 'true'
+      PROFILE: 'dist,berkeley-solr'
+
+networks:
+  atlas:
diff --git a/dev-support/atlas-docker/docker-compose.atlas.yml 
b/dev-support/atlas-docker/docker-compose.atlas.yml
new file mode 100644
index 0000000..ccb1b72
--- /dev/null
+++ b/dev-support/atlas-docker/docker-compose.atlas.yml
@@ -0,0 +1,22 @@
+version: '3'
+services:
+  atlas:
+    build:
+      context: .
+      dockerfile: Dockerfile.atlas
+    image: atlas:latest
+    container_name: atlas
+    hostname: atlas.example.com
+    stdin_open: true
+    tty: true
+    networks:
+      - atlas
+    ports:
+      - "21000:21000"
+    depends_on:
+      - atlas-base
+    command:
+      - /home/atlas/scripts/atlas.sh
+
+networks:
+  atlas:
diff --git a/dev-support/atlas-docker/patches/.gitignore 
b/dev-support/atlas-docker/patches/.gitignore
new file mode 100644
index 0000000..72e8ffc
--- /dev/null
+++ b/dev-support/atlas-docker/patches/.gitignore
@@ -0,0 +1 @@
+*
diff --git a/dev-support/atlas-docker/scripts/atlas-build.sh 
b/dev-support/atlas-docker/scripts/atlas-build.sh
new file mode 100755
index 0000000..b920034
--- /dev/null
+++ b/dev-support/atlas-docker/scripts/atlas-build.sh
@@ -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.
+
+if [ "${BRANCH}" == "" ]
+then
+  BRANCH=master
+fi
+
+if [ "${PROFILE}" != "" ]
+then
+  ARG_PROFILES="-P${PROFILE}"
+fi
+
+if [ "${SKIPTESTS}" == "" ]
+then
+  ARG_SKIPTESTS="-DskipTests"
+else
+  ARG_SKIPTESTS="-DskipTests=${SKIPTESTS}"
+fi
+
+export MAVEN_OPTS="-Xms2g -Xmx2g"
+export M2=/home/atlas/.m2
+
+
+if [ -f /home/atlas/src/pom.xml ]
+then
+  echo "Building from /home/atlas/src"
+
+  cd /home/atlas/src
+else
+  echo "Building from /home/atlas/git/atlas"
+
+  cd /home/atlas/git/atlas
+
+  git checkout ${BRANCH}
+  git pull
+
+  for patch in `ls -1 /home/atlas/patches | sort`
+  do
+    echo "applying patch /home/atlas/patches/${patch}"
+    git apply /home/atlas/patches/${patch}
+  done
+fi
+
+mvn ${ARG_PROFILES} ${ARG_SKIPTESTS} -DskipDocs clean package
+
+mv -f distro/target/apache-atlas-${ATLAS_VERSION}-bin.tar.gz /home/atlas/dist/
diff --git a/dev-support/atlas-docker/scripts/atlas.sh 
b/dev-support/atlas-docker/scripts/atlas.sh
new file mode 100755
index 0000000..0c4a454
--- /dev/null
+++ b/dev-support/atlas-docker/scripts/atlas.sh
@@ -0,0 +1,41 @@
+#!/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.
+
+
+if [ ! -e ${ATLAS_HOME}/.setupDone ]
+then
+  SETUP_ATLAS=true
+else
+  SETUP_ATLAS=false
+fi
+
+if [ "${SETUP_ATLAS}" == "true" ]
+then
+  encryptedPwd=$(${ATLAS_HOME}/bin/cputil.py -g -u admin -p atlasR0cks! -s)
+
+  echo "admin=ADMIN::${encryptedPwd}" > 
${ATLAS_HOME}/conf/users-credentials.properties
+
+  chown -R atlas:atlas ${ATLAS_HOME}/
+
+  touch ${ATLAS_HOME}/.setupDone
+fi
+
+su -c "cd ${ATLAS_HOME}/bin && ./atlas_start.py" atlas
+
+# prevent the container from exiting
+/bin/bash

Reply via email to