Thursday, July 9, 2020

Steps to Simple Docker File creation with centos 7 images includes jdk, node, maven and push to AWS ECS

Steps to Simple Docker File to create centos 7 install node, maven

$ vi Dockerfile
FROM centos:7
RUN yum -y update ; yum -y install java-1.8.0-openjdk-devel wget which
RUN yum install -y gcc gcc-c++ \
                   libtool libtool-ltdl \
                   make cmake \
                   git \
                   pkgconfig \
                   sudo \
                   automake autoconf \
                   yum-utils rpm-build && \
    yum clean all
RUN curl -sL https://rpm.nodesource.com/setup_10.x | bash - 
RUN yum -y install nodejs
RUN npm install -g @angular/cli
RUN wget https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
RUN tar xvf apache-maven-3.6.3-bin.tar.gz -C /usr/lib/
RUN echo 'M2_HOME="/usr/lib/apache-maven-3.6.3"' >> /etc/profile
RUN echo 'export M2_HOME' >> /etc/profile
RUN echo 'M2="$M2_HOME/bin"' >> /etc/profile
RUN echo 'MAVEN_OPTS="-Xms512m -Xmx1024m"' >> /etc/profile
RUN echo 'export M2 MAVEN_OPTS' >> /etc/profile
RUN echo 'PATH=$M2:$PATH' >> /etc/profile
RUN echo 'export PATH' >> /etc/profile
RUN echo "source /etc/profile" >> /root/.bashrc
ENV FLAVOR=rpmbuild OS=centos DIST=el7
CMD ["/bin/bash"]


Build docker image and push to AWS. Make sure docker and AWS CLI installed

1. Create repository in AWS ECS. 
2. In AWS select repository (view push commands) to see the commands 

Retrieve an authentication token and authenticate your Docker client to your registry.

aws ecr get-login-password --region us-west-2 --profile <profile> | docker login --username AWS --password-stdin gubendran.dkr.ecr.us-west-2.amazonaws.com

Note: If you receive an error using the AWS CLI, make sure that you have the latest version of the AWS CLI and Docker installed.

Build your Docker image using the following command. For information on building a Docker file from scratch see the instructions here . You can skip this step if your image is already built:

docker build -t test_build:2.5.0 .

After the build completes, tag your image so you can push the image to this repository:
docker tag test_build:2.5.0 gubendran.dkr.ecr.us-west-2.amazonaws.com/test_build:2.5.0

Run the following command to push this image to your newly created AWS repository:

docker push gubendran.dkr.ecr.us-west-2.amazonaws.com/test_build:2.5.0

Describe AWS ECR image from the repository created
aws ecr describe-images --repository-name test_build

Install NPM HighCharts, Elastic Dump

Install NPM HighCharts

Verify node and npm. If missing then install 

node -v

npm -v

Install

curl -sL https://rpm.nodesource.com/setup_10.x | bash - 
yum -y install nodejs

node -v
npm -v
yum install bzip2
yum install fontconfig freetype freetype-devel fontconfig-devel libstdc++
npm install -g highcharts-export-server --ignore-scripts 
cd /usr/lib/node_modules/highcharts-export-server/node_modules/phantomjs-prebuilt/ 
node install.js
cd /usr/lib/node_modules/highcharts-export-server 
node build.js
To Start highcharts-export-server
highcharts-export-server -enableServer 1 &


ElasticDump

npm install -g elasticdump


// Below script tag for SyntaxHighLighter