You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2020/10/01 22:13:01 UTC

[atlas] branch master updated: ATLAS-3934: Dockerfile: moved environment variables to .env file - #3

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

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


The following commit(s) were added to refs/heads/master by this push:
     new ac573f3  ATLAS-3934: Dockerfile: moved environment variables to .env file - #3
ac573f3 is described below

commit ac573f33c72f5cf9b75b50453ad85dd3abadcb15
Author: Madhan Neethiraj <ma...@apache.org>
AuthorDate: Tue Sep 29 13:00:08 2020 -0700

    ATLAS-3934: Dockerfile: moved environment variables to .env file - #3
---
 dev-support/atlas-docker/.env                      |  7 +++++
 dev-support/atlas-docker/Dockerfile.atlas          |  3 ++
 dev-support/atlas-docker/Dockerfile.atlas-base     |  2 --
 dev-support/atlas-docker/Dockerfile.atlas-build    |  5 +---
 dev-support/atlas-docker/README.md                 | 32 ++++++++++------------
 .../atlas-docker/docker-compose.atlas-base.yml     |  2 ++
 .../atlas-docker/docker-compose.atlas-build.yml    |  9 ++++--
 dev-support/atlas-docker/docker-compose.atlas.yml  |  4 +++
 dev-support/atlas-docker/scripts/atlas-build.sh    | 14 +++++++++-
 9 files changed, 51 insertions(+), 27 deletions(-)

diff --git a/dev-support/atlas-docker/.env b/dev-support/atlas-docker/.env
new file mode 100644
index 0000000..19443ad
--- /dev/null
+++ b/dev-support/atlas-docker/.env
@@ -0,0 +1,7 @@
+BUILD_HOST_SRC=true
+SKIPTESTS=true
+GIT_URL=https://github.com/apache/atlas.git
+BRANCH=master
+PROFILE=dist,berkeley-solr
+
+ATLAS_VERSION=3.0.0-SNAPSHOT
diff --git a/dev-support/atlas-docker/Dockerfile.atlas b/dev-support/atlas-docker/Dockerfile.atlas
index b90a1ca..e2dea77 100644
--- a/dev-support/atlas-docker/Dockerfile.atlas
+++ b/dev-support/atlas-docker/Dockerfile.atlas
@@ -16,6 +16,7 @@
 
 FROM atlas-base:latest
 
+ARG ATLAS_VERSION
 
 COPY ./scripts/atlas.sh                              ${ATLAS_SCRIPTS}/
 COPY ./dist/apache-atlas-${ATLAS_VERSION}-bin.tar.gz /tmp/
@@ -25,6 +26,8 @@ RUN tar xfz /tmp/apache-atlas-${ATLAS_VERSION}-bin.tar.gz --directory=/opt/ && \
     rm -f /tmp/apache-atlas-${ATLAS_VERSION}-bin.tar.gz && \
     mkdir -p /var/run/atlas && \
     mkdir -p /var/log/atlas && \
+    rm -rf ${ATLAS_HOME}/logs && \
+    ln -s /var/log/atlas ${ATLAS_HOME}/logs && \
     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
index b7c86ab..36e8f0f 100644
--- a/dev-support/atlas-docker/Dockerfile.atlas-base
+++ b/dev-support/atlas-docker/Dockerfile.atlas-base
@@ -17,8 +17,6 @@
 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 \
diff --git a/dev-support/atlas-docker/Dockerfile.atlas-build b/dev-support/atlas-docker/Dockerfile.atlas-build
index bc27e9f..4b381c1 100644
--- a/dev-support/atlas-docker/Dockerfile.atlas-build
+++ b/dev-support/atlas-docker/Dockerfile.atlas-build
@@ -27,10 +27,7 @@ ENV PATH       /usr/java/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/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
+    chown -R atlas:atlas /home/atlas
 
 COPY ./scripts/atlas-build.sh /home/atlas/scripts/
 
diff --git a/dev-support/atlas-docker/README.md b/dev-support/atlas-docker/README.md
index 9e56fa1..de64447 100644
--- a/dev-support/atlas-docker/README.md
+++ b/dev-support/atlas-docker/README.md
@@ -27,52 +27,50 @@ Docker files in this folder create docker images and run them to build Apache At
 
 2. Set this folder as your working directory.
 
-3. Using docker-compose is the simpler way to build and deploy Apache Atlas in containers.
+3. Update environment variables in .env file, if necessary
 
-   3.1. Execute following command to build Apache Atlas:
+4. Using docker-compose is the simpler way to build and deploy Apache Atlas in containers.
+
+   4.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:
+   4.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.
+   Apache Atlas will be installed at /opt/atlas/, and logs are at /var/logs/atlas directory.
 
-4. Alternatively docker command can be used to build and deploy Apache Atlas.
+5. Alternatively docker command can be used to build and deploy Apache Atlas.
 
-   4.1. Execute following command to build Docker image **atlas-base**:
+   5.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**:
+   5.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:delegated -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
+   5.3. Build Apache Atlas in a container with one of the following commands:
 
-        # to build from local sources
-        docker run -it --rm -v ${HOME}/.m2:/home/atlas/.m2:delegated -v $(pwd)/scripts:/home/atlas/scripts -v $(pwd)/../..:/home/atlas/src:delegated -v $(pwd)/dist:/home/atlas/dist -e PROFILE=dist,berkeley-solr -e SKIPTESTS=true atlas-build
+        docker run -it --rm -v ${HOME}/.m2:/home/atlas/.m2:delegated -v $(pwd)/scripts:/home/atlas/scripts -v $(pwd)/../..:/home/atlas/src:delegated -v $(pwd)/patches:/home/atlas/patches -v $(pwd)/dist:/home/atlas/dist --env-file ./.env 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**:
+   5.4. Execute following command to build Docker image **atlas**:
 
-        docker build -f Dockerfile.atlas -t atlas .
+        docker build -f Dockerfile.atlas --build-arg ATLAS_VERSION=3.0.0-SNAPSHOT -t atlas .
 
    This might take about 10 minutes to complete.
 
-   4.8. Execute following command to install and run Atlas services in a container:
+   5.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!)
+6. Atlas Admin can be accessed at http://localhost:21000 (admin/atlasR0cks!)
diff --git a/dev-support/atlas-docker/docker-compose.atlas-base.yml b/dev-support/atlas-docker/docker-compose.atlas-base.yml
index 81c421a..baaeecf 100644
--- a/dev-support/atlas-docker/docker-compose.atlas-base.yml
+++ b/dev-support/atlas-docker/docker-compose.atlas-base.yml
@@ -7,6 +7,8 @@ services:
     image: atlas-base
     networks:
       - atlas
+    environment:
+      - ATLAS_VERSION
 
 networks:
   atlas:
diff --git a/dev-support/atlas-docker/docker-compose.atlas-build.yml b/dev-support/atlas-docker/docker-compose.atlas-build.yml
index c72b7d1..c29588f 100644
--- a/dev-support/atlas-docker/docker-compose.atlas-build.yml
+++ b/dev-support/atlas-docker/docker-compose.atlas-build.yml
@@ -20,9 +20,12 @@ services:
     depends_on:
       - atlas-base
     environment:
-      BRANCH: 'master'
-      SKIPTESTS: 'true'
-      PROFILE: 'dist,berkeley-solr'
+      - ATLAS_VERSION
+      - BRANCH
+      - BUILD_HOST_SRC
+      - GIT_URL
+      - PROFILE
+      - SKIPTESTS
 
 networks:
   atlas:
diff --git a/dev-support/atlas-docker/docker-compose.atlas.yml b/dev-support/atlas-docker/docker-compose.atlas.yml
index ccb1b72..92bd1ed 100644
--- a/dev-support/atlas-docker/docker-compose.atlas.yml
+++ b/dev-support/atlas-docker/docker-compose.atlas.yml
@@ -4,6 +4,8 @@ services:
     build:
       context: .
       dockerfile: Dockerfile.atlas
+      args:
+        - ATLAS_VERSION=${ATLAS_VERSION}
     image: atlas:latest
     container_name: atlas
     hostname: atlas.example.com
@@ -15,6 +17,8 @@ services:
       - "21000:21000"
     depends_on:
       - atlas-base
+    environment:
+      - ATLAS_VERSION
     command:
       - /home/atlas/scripts/atlas.sh
 
diff --git a/dev-support/atlas-docker/scripts/atlas-build.sh b/dev-support/atlas-docker/scripts/atlas-build.sh
index eafe4bd..316ef41 100755
--- a/dev-support/atlas-docker/scripts/atlas-build.sh
+++ b/dev-support/atlas-docker/scripts/atlas-build.sh
@@ -38,12 +38,24 @@ else
   ARG_SKIPTESTS="-DskipTests=${SKIPTESTS}"
 fi
 
+if [ "${BUILD_HOST_SRC}" == "" ]
+then
+  BUILD_HOST_SRC=true
+fi
+
 export MAVEN_OPTS="-Xms2g -Xmx2g"
 export M2=/home/atlas/.m2
 
 
-if [ -f /home/atlas/src/pom.xml ]
+if [ "${BUILD_HOST_SRC}" == "true" ]
 then
+  if [ ! -f /home/atlas/src/pom.xml ]
+  then
+    echo "ERROR: BUILD_HOST_SRC=${BUILD_HOST_SRC}, but /home/atlas/src/pom.xml is not found "
+
+	exit 1
+  fi
+
   echo "Building from /home/atlas/src"
 
   cd /home/atlas/src