Wednesday, November 2, 2016

Run Docker JBoss Wildfly image on AWS ECS

Install Docker on AWS ECS
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html


       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2016.09-release-notes/
[ec2-user@ip-172-31-31-199 ~]$ sudo yum update -y
Loaded plugins: priorities, update-motd, upgrade-helper
No packages marked for update
[ec2-user@ip-172-31-31-199 ~]$  sudo yum install -y docker
Loaded plugins: priorities, update-motd, upgrade-helper
Resolving Dependencies
--> Running transaction check
---> Package docker.x86_64 0:1.11.2-1.6.amzn1 will be installed
--> Processing Dependency: xfsprogs for package: docker-1.11.2-1.6.amzn1.x86_64
--> Running transaction check
---> Package xfsprogs.x86_64 0:3.2.2-2.20.amzn1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package         Arch          Version                   Repository        Size
================================================================================
Installing:
 docker          x86_64        1.11.2-1.6.amzn1          amzn-main         17 M
Installing for dependencies:
 xfsprogs        x86_64        3.2.2-2.20.amzn1          amzn-main        1.7 M

Transaction Summary
================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 18 M
Installed size: 59 M
Downloading packages:
(1/2): docker-1.11.2-1.6.amzn1.x86_64.rpm                |  17 MB     00:00     
(2/2): xfsprogs-3.2.2-2.20.amzn1.x86_64.rpm              | 1.7 MB     00:00     
--------------------------------------------------------------------------------
Total                                               21 MB/s |  18 MB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : xfsprogs-3.2.2-2.20.amzn1.x86_64                             1/2 
  Installing : docker-1.11.2-1.6.amzn1.x86_64                                                        2/2 
  Verifying  : docker-1.11.2-1.6.amzn1.x86_64                                                        1/2 
  Verifying  : xfsprogs-3.2.2-2.20.amzn1.x86_64                                                      2/2 

Installed:
  docker.x86_64 0:1.11.2-1.6.amzn1                                                                       

Dependency Installed:
  xfsprogs.x86_64 0:3.2.2-2.20.amzn1                                                                     

Complete!
[ec2-user@ip-172-31-31-199 ~]$ sudo service docker start
Starting cgconfig service:                                 [  OK  ]
Starting docker:    .                                  [  OK  ]
[ec2-user@ip-172-31-31-199 ~]$ sudo usermod -a -G docker ec2-user
[ec2-user@ip-172-31-31-199 ~]$ 

Verify Docker status

[ec2-user@ip-172-31-31-199 ~]$ docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.11.2
Storage Driver: devicemapper
 Pool Name: docker-202:1-394626-pool
 Pool Blocksize: 65.54 kB
 Base Device Size: 10.74 GB
 Backing Filesystem: xfs
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 11.8 MB
 Data Space Total: 107.4 GB
 Data Space Available: 7.223 GB
 Metadata Space Used: 581.6 kB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.147 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Deferred Deletion Enabled: false
 Deferred Deleted Device Count: 0
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 WARNING: Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
 Library Version: 1.02.93-RHEL7 (2015-01-28)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins: 
 Volume: local
 Network: null host bridge
Kernel Version: 4.4.23-31.54.amzn1.x86_64
Operating System: Amazon Linux AMI 2016.09
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 995.4 MiB
Name: ip-172-31-31-199
ID: IEGJ:BLTG:7DGR:PNN7:SDZS:3M7H:L6LR:CB3M:52IV:SG2R:O3KF:NZPI
Docker Root Dir: /var/lib/docker
Debug mode (client): false
Debug mode (server): false
Registry: https://index.docker.io/v1/
[ec2-user@ip-172-31-31-199 ~]$ 


Run JBoss Wildfly Docker image

[ec2-user@ip-172-31-31-199 ~]$ docker run -it -p 8080:8080 jboss/wildfly 
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/jboss/wildfly

  JAVA: /usr/lib/jvm/java/bin/java

  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true

=========================================================================

21:14:22,924 INFO  [org.jboss.modules] (main) JBoss Modules version 1.5.2.Final
21:14:23,279 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final
21:14:23,368 INFO  [org.jboss.as] (MSC service thread 1-1) WFLYSRV0049: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) starting


List Docker processes

[ec2-user@ip-172-31-31-199 ~]$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
0a5959e5cd9e        jboss/wildfly       "/opt/jboss/wildfly/b"   9 minutes ago       Up 9 minutes        0.0.0.0:8080->8080/tcp   adoring_allen


Connect to Wildfly with links browser from other shell

Install links and connect to http:localhost:8080



[ec2-user@ip-172-31-31-199 ~]$ yum install links

[ec2-user@ip-172-31-31-199 ~]$ links http://localhost:8080




Tuesday, November 1, 2016

Install Java EE7 application using JBoss Wildfly Docker image


Docker and WildFly Part 1 - Deployment via Docker volumes 

 
Docker and WildFly Part 2 - Deployment over management API


https://github.com/goldmann/wildfly-docker-deployment-example

Download JBoss Wildfly image
https://hub.docker.com/r/jboss/wildfly/


[dave@localhost wildfly]$ docker run -it jboss/wildfly
Unable to find image 'jboss/wildfly:latest' locally
latest: Pulling from jboss/wildfly

8d30e94188e7: Pull complete 
183bb107e46a: Pull complete 
9ea1527ac190: Pull complete 
d632efeddd98: Pull complete 
11af01a2d795: Pull complete 
Digest: sha256:2bed1e7a68245509de5837435b6250491efe61a86533f5ce6bf94927814076fb
Status: Downloaded newer image for jboss/wildfly:latest
=========================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: /opt/jboss/wildfly

  JAVA: /usr/lib/jvm/java/bin/java

  JAVA_OPTS:  -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true

=========================================================================


Use port redirect to see Wildfly running in the browser

[dave@localhost wildfly]$ docker run -it -p 8080:8080 jboss/wildfly 

Wildfly home page
Add access to console using own Dockerfile

[dave@localhost wildfly]$ more Dockerfile 
FROM jboss/wildfly:latest

USER jboss
RUN /opt/jboss/wildfly/bin/add-user.sh admin MY_PASSWORD_TO_ACCESS --silent
CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"]


Build the Docker image

[dave@localhost wildfly]$ docker build --tag=wildfly-mgmt .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM jboss/wildfly:latest
 ---> 4c99bd2cd264
Step 2 : USER jboss
 ---> Running in de10054221e5
 ---> f3b3e54e823b
Removing intermediate container de10054221e5
Step 3 : RUN /opt/jboss/wildfly/bin/add-user.sh admin MY_PASSWORD_TO_ACCESS --silent
 ---> Running in 9af7cd245555
 ---> 5a29ccf7bef0
Removing intermediate container 9af7cd245555
Step 4 : CMD /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0 -bmanagement 0.0.0.0
 ---> Running in 642784343b49
 ---> 3ea63bcef45a
Removing intermediate container 642784343b49
Successfully built 3ea63bcef45a


Start with port 8080 and 9990 redirected

[dave@localhost wildfly]$ docker run -it -p 8080:8080 -p 9990:9990  wildfly-mgmt

Check the console access via browser on 9990


Deploy Java EE7 app using Maven

Source code for the application GitHub https://github.com/dveselka/wildfly/tree/master/dave-java-ee7-wildfly-full

[dave@localhost dave-java-ee7-wildfly-full]$  mvn clean package wildfly:deploy
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] dave-java-ee7-wildfly-full
[INFO] dave-java-ee7-wildfly-full: EJB Module
[INFO] dave-java-ee7-wildfly-full: WAR Module
[INFO] dave-java-ee7-wildfly-full: EAR Module
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building dave-java-ee7-wildfly-full 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ dave-java-ee7-wildfly-full ---
[INFO] 
[INFO] >>> wildfly-maven-plugin:1.0.2.Final:deploy (default-cli) > package @ dave-java-ee7-wildfly-full >>>
[INFO] 
[INFO] <<< wildfly-maven-plugin:1.0.2.Final:deploy (default-cli) < package @ dave-java-ee7-wildfly-full <<<
[INFO] 
[INFO] --- wildfly-maven-plugin:1.0.2.Final:deploy (default-cli) @ dave-java-ee7-wildfly-full ---

Deployment in Docker Widlfy

05:32:38,366 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) started in 4639ms - Started 331 of 577 services (393 services are lazy, passive or on-demand)
05:43:49,778 INFO  [org.jboss.as.repository] (management-handler-thread - 1) WFLYDR0001: Content added at location /opt/jboss/wildfly/standalone/data/content/a1/58abbd7beeb79e23f10486bbefb72f55dc5368/content
05:43:49,861 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "dave-java-ee7-wildfly-full-ear.ear" (runtime-name: "dave-java-ee7-wildfly-full-ear.ear")
05:43:50,006 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0207: Starting subdeployment (runtime-name: "dave-java-ee7-wildfly-full-web.war")
05:43:50,006 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-7) WFLYSRV0207: Starting subdeployment (runtime-name: "dave-java-ee7-wildfly-full-ejb.jar")
05:43:50,168 WARN  [org.jboss.as.connector] (MSC service thread 1-1) WFLYJCA0091: -ds.xml file deployments are deprecated. Support may be removed in a future version.
05:43:50,620 INFO  [org.jboss.as.jpa] (MSC service thread 1-5) WFLYJPA0002: Read persistence.xml for primary
05:43:50,900 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) WFLYJCA0001: Bound data source [java:jboss/datasources/dave-java-ee7-wildfly-fullDS]
05:43:50,966 INFO  [org.jboss.as.jpa] (ServerService Thread Pool -- 69) WFLYJPA0010: Starting Persistence Unit (phase 1 of 2) Service 'dave-java-ee7-wildfly-full-ear.ear/dave-java-ee7-wildfly-full-ejb.jar#primary'
05:43:50,977 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) WFLYWELD0003: Processing weld deployment dave-java-ee7-wildfly-full-ear.ear
05:43:51,095 INFO  [org.hibernate.jpa.internal.util.LogHelper] (ServerService Thread Pool -- 69) HHH000204: Processing PersistenceUnitInfo [
    name: primary
    ...]
05:43:51,494 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-1) HV000001: Hibernate Validator 5.2.4.Final
05:43:51,653 INFO  [org.hibernate.Version] (ServerService Thread Pool -- 69) HHH000412: Hibernate Core {5.0.10.Final}
05:43:51,655 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 69) HHH000206: hibernate.properties not found
05:43:51,664 INFO  [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 69) HHH000021: Bytecode provider name : javassist
05:43:51,864 INFO  [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 69) HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
05:43:52,082 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) WFLYWELD0003: Processing weld deployment dave-java-ee7-wildfly-full-ejb.jar
05:43:52,090 INFO  [org.jboss.weld.deployer] (MSC service thread 1-5) WFLYWELD0003: Processing weld deployment dave-java-ee7-wildfly-full-web.war
05:43:52,120 INFO  [org.jboss.as.ejb3.deployment] (MSC service thread 1-1) WFLYEJB0473: JNDI bindings for session bean named 'MemberRegistration' in deployment unit 'subdeployment "dave-java-ee7-wildfly-full-ejb.jar" of deployment "dave-java-ee7-wildfly-full-ear.ear"' are as follows:

    java:global/dave-java-ee7-wildfly-full-ear/dave-java-ee7-wildfly-full-ejb/MemberRegistration!dave.service.MemberRegistration
    java:app/dave-java-ee7-wildfly-full-ejb/MemberRegistration!dave.service.MemberRegistration
    java:module/MemberRegistration!dave.service.MemberRegistration
    java:global/dave-java-ee7-wildfly-full-ear/dave-java-ee7-wildfly-full-ejb/MemberRegistration
    java:app/dave-java-ee7-wildfly-full-ejb/MemberRegistration
    java:module/MemberRegistration


Check the application in the browser

Tuesday, October 25, 2016

Run Arquillian test on JBoss EAP 7/ Wildfly 10 using Arquillian Chameleon Container

Arqullian

http://arquillian.org/guides/getting_started/

Arquillian Chameleon Container

 https://github.com/arquillian/arquillian-container-chameleon

 http://discuss.arquillian.org/t/proxy-container-for-all-jboss-as-jboss-eap-wildfly/124/7

 Add Maven dependency ( check for latest version )

<dependency>
    <groupId>org.arquillian.container</groupId>
    <artifactId>arquillian-container-chameleon</artifactId>
    <version>1.0.0.Alpha7</version>
</dependency>

Add container configuration into arquillian.xml file

<arquillian xmlns="http://jboss.org/schema/arquillian"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
    
     <container qualifier="chameleon" default="true">
        <configuration>
            <property name="chameleonTarget">jboss eap:7.0.1:remote</property>
            <property name="managementAddress">localhost</property>
            <property name="managementPort">9990</property>
            <property name="username">${jboss.admin.user}</property>
            <property name="password">${jboss.admin.password}!</property>
        </configuration>
    </container>
   
</arquillian>


Add Maven dependencies in multi-module project using shrinkwrap-resolver-impl-maven http://stackoverflow.com/questions/13001371/adding-all-maven-dependencies-to-arquillian

https://github.com/shrinkwrap/resolver


Add Chameleon container dependency ( using runTests profile )

<profile>
            <id>runTests</id>
            <activation>
                <property>
                    <name>runTests</name>
                    <value>true</value>
                </property>
            </activation>
            <dependencies>
                <dependency>
                     <groupId>org.arquillian.container</groupId>
                     <artifactId>arquillian-container-chameleon</artifactId>
                 </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skipTests>false</skipTests>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

Run the single test using Maven command line

$ mvn clean install -PrunTests  -Dtest=ArqTestCase

Tuesday, October 11, 2016

Install Citrix receiver on Fedora

Citrix Workspace app 1910 for Linux


Download und install
https://www.citrix.com/downloads/workspace-app/linux/workspace-app-for-linux-latest.html

sudo dnf install ~/Downloads/ICAClientWeb-rhel-19.10.0.15-0.x86_64.rpm 
sudo dnf install gtk-murrine-engine libidn1.34

cp /usr/share/applications/wfica.desktop ~/.local/share/applications/

sed -i  's/^Exec=/Exec=env LD_PRELOAD="\/lib64\/libcrypto.so.1.0.2o" /g' ~/.local/share/applications/wfica.desktop




Download latest Citrix reciever from Citrix web - decommissioned

https://www.citrix.com/downloads/citrix-receiver/linux/receiver-for-linux-latest.html

Install Citrix Receiver

[root@linux ~]# dnf info ICAClient
Last metadata expiration check: 1:56:02 ago on Tue Oct 11 14:24:35 2016.
Installed Packages
Name        : ICAClient
Arch        : x86_64
Epoch       : 0
Version     : 13.4.0.10109380
Release     : 0
Size        : 45 M
Repo        : @System
From repo   : @commandline
Summary     : Citrix Receiver for Linux
URL         : http://www.citrix.com/
License     : Commercial
Description : Citrix Receiver lets you access your enterprise files, applications, and
            : desktops from your favorite device wherever you are. Just ask your IT
            : department how to get started.


If you see SSL error on connection attemt
https://newspaint.wordpress.com/2015/10/05/linux-citrix-receiver-ssl-error-addtrust-external-ca-root/

Extract  AddTrustExternalCARoot from Firefox -> Preferences -> Advanced -> Certificates -> CA certs ->
Export CA cert AddTrustExternalCARoot to disk

Or download CA certificate from Comodo
https://support.comodo.com/index.php?/Knowledgebase/Article/View/853/74/addtrustexternalcaroot

Copy CA certificate into Citrix installation

[root@linux ~]# cp AddTrustExternalCARoot.crt /opt/Citrix/ICAClient/keystore/cacerts/


Use Google Chrome to connect

Sunday, October 9, 2016

Install and configure Docker on Fedora

Installation guide for Fedora

https://docs.docker.com/engine/installation/linux/fedora/

Install Docker using DNF

Enable docker service and start it

[root@localhost ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.


[root@localhost ~]# systemctl start docker
[root@localhost ~]# ps -aef |grep docker
root      6785     1  2 10:32 ?        00:00:00 /usr/bin/dockerd
root      6796  6785  0 10:32 ?        00:00:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --runtime docker-runc

Run the hello world

[root@localhost ~]# docker run --rm hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c04b14da8d14: Pull complete 
Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

Create group docker and add own user 

[root@localhost ~]# usermod -aG docker dave

It is necessary to reboot to get rights as non-root user

[dave@localhost docker]$ docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/
Paste your text here.

Run Ubuntu image

[dave@localhost docker]$ docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
cad964aed91d: Pull complete 
3a80a22fea63: Pull complete 
50de990d7957: Pull complete 
61e032b8f2cb: Pull complete 
9f03ce1741bf: Pull complete 
Digest: sha256:28d4c5234db8d5a634d5e621c363d900f8f241240ee0a6a978784c978fe9c737
Status: Downloaded newer image for ubuntu:latest
root@e0fdce56f046:/# hostname
e0fdce56f046
root@e0fdce56f046:/# more /etc/issue
Ubuntu 16.04.1 LTS \n \l

root@e0fdce56f046:/# 

Running processes in hosting Fedora system

[root@localhost ~]# ps -aef |grep docker
root      1732     1  1 13:09 ?        00:00:08 /usr/bin/dockerd
root      1901  1732  0 13:09 ?        00:00:00 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-interval=0 --start-timeout 2m --state-dir /var/run/docker/libcontainerd/containerd --runtime docker-runc
dave      3643  3343  0 13:15 pts/0    00:00:00 docker run -it ubuntu bash
root      3855  1901  0 13:15 ?        00:00:00 docker-containerd-shim e0fdce56f046997246242db8c1ad224337dc4915f3ee497c8ae66e321c1f445f /var/run/docker/libcontainerd/e0fdce56f046997246242db8c1ad224337dc4915f3ee497c8ae66e321c1f445f docker-runc
[root@localhost ~]# 

List containers
[root@localhost ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
e0fdce56f046        ubuntu              "bash"              5 minutes ago       Up 5 minutes                                   furious_heisenberg
04899e84663d        hello-world         "/hello"            9 minutes ago       Exited (0) 9 minutes ago                       big_newton

Create own image
 ( using tutorial https://docs.docker.com/engine/getstarted/step_four/ )

[dave@localhost docker]$ cat Dockerfile 
FROM docker/whalesay:latest
RUN apt-get -y update && apt-get install -y fortunes
CMD /usr/games/fortune -a | cowsay

[dave@localhost docker]$ docker build -t docker-whale .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM docker/whalesay:latest
 ---> 6b362a9f73eb
Step 2 : RUN apt-get -y update && apt-get install -y fortunes
 ---> Running in a2501bfa86f4
Ign http://archive.ubuntu.com trusty InRelease
Get:1 http://archive.ubuntu.com trusty-updates InRelease [65.9 kB]
Get:2 http://archive.ubuntu.com trusty-security InRelease [65.9 kB]
Hit http://archive.ubuntu.com trusty Release.gpg
Hit http://archive.ubuntu.com trusty Release
Get:3 http://archive.ubuntu.com trusty-updates/main Sources [474 kB]
Get:4 http://archive.ubuntu.com trusty-updates/restricted Sources [5247 B]
Get:5 http://archive.ubuntu.com trusty-updates/universe Sources [209 kB]
Get:6 http://archive.ubuntu.com trusty-updates/main amd64 Packages [1125 kB]
Get:7 http://archive.ubuntu.com trusty-updates/restricted amd64 Packages [23.5 kB]
Get:8 http://archive.ubuntu.com trusty-updates/universe amd64 Packages [485 kB]
Get:9 http://archive.ubuntu.com trusty-security/main Sources [153 kB]
Get:10 http://archive.ubuntu.com trusty-security/restricted Sources [3944 B]
Get:11 http://archive.ubuntu.com trusty-security/universe Sources [51.3 kB]
Get:12 http://archive.ubuntu.com trusty-security/main amd64 Packages [662 kB]
Get:13 http://archive.ubuntu.com trusty-security/restricted amd64 Packages [20.2 kB]
Get:14 http://archive.ubuntu.com trusty-security/universe amd64 Packages [180 kB]
Hit http://archive.ubuntu.com trusty/main Sources
Hit http://archive.ubuntu.com trusty/restricted Sources
Hit http://archive.ubuntu.com trusty/universe Sources
Hit http://archive.ubuntu.com trusty/main amd64 Packages
Hit http://archive.ubuntu.com trusty/restricted amd64 Packages
Hit http://archive.ubuntu.com trusty/universe amd64 Packages
Fetched 3525 kB in 3s (1060 kB/s)
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  fortune-mod fortunes-min librecode0
Suggested packages:
  x11-utils bsdmainutils
The following NEW packages will be installed:
  fortune-mod fortunes fortunes-min librecode0
0 upgraded, 4 newly installed, 0 to remove and 87 not upgraded.
Need to get 1961 kB of archives.
After this operation, 4817 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu/ trusty/main librecode0 amd64 3.6-21 [771 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ trusty/universe fortune-mod amd64 1:1.99.1-7 [39.5 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ trusty/universe fortunes-min all 1:1.99.1-7 [61.8 kB]
Get:4 http://archive.ubuntu.com/ubuntu/ trusty/universe fortunes all 1:1.99.1-7 [1089 kB]
debconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin: 
Fetched 1961 kB in 0s (2729 kB/s)
Selecting previously unselected package librecode0:amd64.
(Reading database ... 13116 files and directories currently installed.)
Preparing to unpack .../librecode0_3.6-21_amd64.deb ...
Unpacking librecode0:amd64 (3.6-21) ...
Selecting previously unselected package fortune-mod.
Preparing to unpack .../fortune-mod_1%3a1.99.1-7_amd64.deb ...
Unpacking fortune-mod (1:1.99.1-7) ...
Selecting previously unselected package fortunes-min.
Preparing to unpack .../fortunes-min_1%3a1.99.1-7_all.deb ...
Unpacking fortunes-min (1:1.99.1-7) ...
Selecting previously unselected package fortunes.
Preparing to unpack .../fortunes_1%3a1.99.1-7_all.deb ...
Unpacking fortunes (1:1.99.1-7) ...
Setting up librecode0:amd64 (3.6-21) ...
Setting up fortune-mod (1:1.99.1-7) ...
Setting up fortunes-min (1:1.99.1-7) ...
Setting up fortunes (1:1.99.1-7) ...
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
 ---> d32c0f1dd6fd
Removing intermediate container a2501bfa86f4
Step 3 : CMD /usr/games/fortune -a | cowsay
 ---> Running in 4be6a9e302e6
 ---> 04c2ee13ff82
Removing intermediate container 4be6a9e302e6
Successfully built 04c2ee13ff82


Run own image

[dave@localhost docker]$ docker run docker-whale
 ______________________________________ 
/ Now Denial:                          \
|                                      |
| To tell oneself that the only time   |
| worth living in is the past and that |
| the only time that may ever be       |
| interesting again is the future.     |
|                                      |
| -- Douglas Coupland, "Generation X:  |
| Tales for an Accelerated             |
|                                      |
\ Culture"                             /
 -------------------------------------- 
    \
     \
      \     
                    ##        .            
              ## ## ##       ==            
           ## ## ## ##      ===            
       /""""""""""""""""___/ ===        
  ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~   
       \______ o          __/            
        \    \        __/             
          \____\______/   

Saturday, September 24, 2016

AWS IAM setup for CodeDeploy

Create new IAM user using AWS console


https://console.aws.amazon.com/iam/home#users

Create new user awsdave



Download user credentials into file


 

Create new policies using AWS console


 Create new custom policy CodeDeploy and
EC2CodeDeploy

 


Create new roles using AWS console

 https://console.aws.amazon.com/iam/home#roles

Create roles and assign policy as described in AWS tutorial video
https://www.youtube.com/watch?v=qZa5JXmsWZs&list=LLl1AVDEQMsLIiTYI5M-v0ow&index=1



Create role CodeDeploy
Create role EC2CodeDeploy


Edit trust relationship for the created Role if needed



Launch EC2 instance 

 

Select EC2 instance IAM role EC2CodeDeploy



Policy CodeDeploy

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Action": [
                "autoscaling:PutLifecycleHook",
                "autoscaling:DeleteLifecycleHook",
                "autoscaling:RecordLifecycleActionHeartbeat",
                "autoscaling:CompleteLifecycleAction",
                "autoscaling:DescribeAutoscalingGroups",
                "autoscaling:PutInstanceInStandby",
                "autoscaling:PutInstanceInService",
                "autoscaling:DescribeLifecycleHooks",
                "ec2:Describe*"
            ],
            "Effect": "Allow",
            "Resource": "*"
        }
    ]
}

Trust Relationship


{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "Service": [
          "codedeploy.us-east-1.amazonaws.com",
          "codedeploy.us-west-2.amazonaws.com",
          "codedeploy.ap-northeast-2.amazonaws.com",
          "codedeploy.ap-southeast-2.amazonaws.com",
          "codedeploy.ap-southeast-1.amazonaws.com",
          "codedeploy.us-west-1.amazonaws.com",
          "codedeploy.eu-west-1.amazonaws.com",
          "codedeploy.ap-south-1.amazonaws.com",
          "codedeploy.eu-central-1.amazonaws.com",
          "codedeploy.ap-northeast-1.amazonaws.com",
          "codedeploy.sa-east-1.amazonaws.com"
        ]
      },
      "Action": "sts:AssumeRole"
    }
  ]
}



Thursday, August 4, 2016

Deploy Java application from GitHub to AWS

HOWTO from AWS tutorial


AWS tutorial video  Code Deploy Setup (IAM, EC2)
https://www.youtube.com/watch?v=qZa5JXmsWZs

GitHub for AWS tutorial video https://github.com/andrewpuch/code_deploy_example/

AWS CodeDeploy tutorial video https://www.youtube.com/watch?v=jcR9iIWdU7E

Steps to create running AWS EC2 instance


Create AWS free account

Getting started :
https://aws.amazon.com/free/

Create AWS account




Create own Linux instance
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EC2_GetStarted.html


Connect to AWS Linux instance via ssh

[dave@localhost aws]$ chmod 400 dave_amazon.pem
[dave@localhost aws]$ ssh -i "dave_amazon.pem" ec2-user@ec2-11-123-765-44.us-west-2.compute.amazonaws.com


       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2016.03-release-notes/
8 package(s) needed for security, out of 17 available
Run "sudo yum update" to apply all updates.


Install AWS tools on Fedora

https://fedoramagazine.org/aws-tools-fedora/

[root@localhost ~]# dnf install  awscli
Dependencies resolved.
=================================================================================================
 Package                  Arch         Version                               Repository     Size
=================================================================================================
Installing:
 awscli                   noarch       1.10.45-1.fc23                        updates       868 k
 python3-botocore         noarch       1.4.35-1.fc23                         updates       1.8 M
 python3-colorama         noarch       0.3.2-2.fc23                          fedora         29 k
 python3-docutils         noarch       0.12-0.3.20140510svn7747.fc23         fedora        1.5 M
 python3-jmespath         noarch       0.9.0-1.fc23                          updates        43 k
 python3-pyasn1           noarch       0.1.8-1.fc23                          fedora        108 k
 python3-rsa              noarch       3.4.1-1.fc23                          updates        72 k
 python3-s3transfer       noarch       0.0.1-2.fc23                          updates        29 k

Transaction Summary
=================================================================================================
Install  8 Packages

Total download size: 4.5 M
Installed size: 27 M
Is this ok [y/N]: 
Paste your text here.

  

[dave@localhost aws]$ aws --version
aws-cli/1.10.45 Python/3.4.3 Linux/4.5.7-200.fc23.x86_64 botocore/1.4.35

 Add AWS IAM access keys

[dave@localhost aws]$ aws configure

Check running instances 

[dave@localhost aws]$ aws ec2 describe-instances 
{
    "Reservations": [
        {
            "Instances": [
                {
                    "PublicDnsName":

Integrating AWS CodeDeploy with GitHub

https://docs.aws.amazon.com/codedeploy/latest/userguide/github-integ.html


Setup roles in IAM
https://docs.aws.amazon.com/codedeploy/latest/userguide/getting-started-setup.html



Amazon AWS Java samples
https://github.com/aws/aws-sdk-java/tree/master/src/samples



Create GitHub repository with sample application
https://github.com/dveselka/aws-java-sample

User guide GitHub - AWS integration
https://docs.aws.amazon.com/codedeploy/latest/userguide/github-integ-tutorial.html 

Create application - see tutorial page
  Step 5: Deploy the Application to the Instance


Connect with GitHub


Deploy AWS sample Linux
https://github.com/dveselka/aws-sample-linux


Check AWS CodeDeploy console

Deploy fails with HEALTH_CONSTRAINTS

It is necessary to install CodeDeploy on instance
Follow this tutorial :

Install or reinstall the AWS CodeDeploy agent for Amazon Linux or RHEL

https://docs.aws.amazon.com/codedeploy/latest/userguide/how-to-run-agent-install.html#how-to-run-agent-install-linux

[ec2-user@ip-172-31-21-129 ~]$ wget https://aws-codedeploy-eu-central-1.s3.amazonaws.com/latest/install
--2016-08-07 13:45:20--  https://aws-codedeploy-eu-central-1.s3.amazonaws.com/latest/install
Resolving aws-codedeploy-eu-central-1.s3.amazonaws.com (aws-codedeploy-eu-central-1.s3.amazonaws.com)... 54.231.193.44
Connecting to aws-codedeploy-eu-central-1.s3.amazonaws.com (aws-codedeploy-eu-central-1.s3.amazonaws.com)|54.231.193.44|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13359 (13K) []
Saving to: ‘install’

install                    100%[======================================>]  13.05K  78.6KB/s    in 0.2s    

2016-08-07 13:45:21 (78.6 KB/s) - ‘install’ saved [13359/13359]


Check installation success
[ec2-user@ip-172-31-21-129 ~]$ sudo service codedeploy-agent status
The AWS CodeDeploy agent is running as PID 2660


Deploy application from GithHub  using CodeDeploy - Deployments


Access application using public IP address





Check log on EC2 instance

c2-user]# tail -500f /var/log/httpd/access_log 
189.278.189.245 - - [24/Sep/2016:18:03:53 +0000] "GET / HTTP/1.1" 200 911 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0"



Sample app Linux
https://github.com/awslabs/aws-codedeploy-samples/tree/master/applications/SampleApp_Linux

Sample Tomcat application on GitHub
https://github.com/awslabs/aws-codedeploy-sample-tomcat


You can also download sample app from Amazon S3
[dave@localhost aws]$ aws s3 cp s3://aws-codedeploy-eu-central-1/samples/latest/SampleApp_Linux.zip . --region eu-central-1
download: s3://aws-codedeploy-eu-central-1/samples/latest/SampleApp_Linux.zip to ./SampleApp_Linux.zip

[dave@localhost aws]$ unzip -l SampleApp_Linux.zip 
Archive:  SampleApp_Linux.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
       34  11-03-2014 22:42   scripts/install_dependencies
       33  11-03-2014 22:43   scripts/start_server
      105  11-03-2014 22:43   scripts/stop_server
      359  11-03-2014 22:42   appspec.yml
      717  11-03-2014 22:42   index.html
    10884  11-03-2014 22:42   LICENSE.txt
---------                     -------
    12132                     6 files

Thursday, April 21, 2016

Scala - setup environment - sbt, Scala IDE

Download sbt http://www.scala-sbt.org/download.html


Configure https proxy
 export JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyHost=webproxy -Dhttp.proxyPort=8080"  


Change sbt repository root
 export _JAVA_OPTIONS='-Duser.home=/d/vesedan/sbt-repository'  


Start sbt
 $ sbt  
 Getting org.scala-sbt sbt 0.13.11 ...  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/0.13.11/jars/sbt.jar ...  
     [SUCCESSFUL ] org.scala-sbt#sbt;0.13.11!sbt.jar (2209ms)  
 downloading https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.10.6/scala-library-2.10.6.jar ...  
     [SUCCESSFUL ] org.scala-lang#scala-library;2.10.6!scala-library.jar (36565ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/main/0.13.11/jars/main.jar ...  
     [SUCCESSFUL ] org.scala-sbt#main;0.13.11!main.jar (14438ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/compiler-interface/0.13.11/jars/compiler-interface.jar ...  
     [SUCCESSFUL ] org.scala-sbt#compiler-interface;0.13.11!compiler-interface.jar (3732ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/actions/0.13.11/jars/actions.jar ...  
     [SUCCESSFUL ] org.scala-sbt#actions;0.13.11!actions.jar (4983ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/main-settings/0.13.11/jars/main-settings.jar ...  
     [SUCCESSFUL ] org.scala-sbt#main-settings;0.13.11!main-settings.jar (189535ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/interface/0.13.11/jars/interface.jar ...  
     [SUCCESSFUL ] org.scala-sbt#interface;0.13.11!interface.jar (2385ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/io/0.13.11/jars/io.jar ...  
     [SUCCESSFUL ] org.scala-sbt#io;0.13.11!io.jar (3836ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/ivy/0.13.11/jars/ivy.jar ...  
     [SUCCESSFUL ] org.scala-sbt#ivy;0.13.11!ivy.jar (10631ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/logging/0.13.11/jars/logging.jar ...  
     [SUCCESSFUL ] org.scala-sbt#logging;0.13.11!logging.jar (2493ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/logic/0.13.11/jars/logic.jar ...  
     [SUCCESSFUL ] org.scala-sbt#logic;0.13.11!logic.jar (2893ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/process/0.13.11/jars/process.jar ...  
     [SUCCESSFUL ] org.scala-sbt#process;0.13.11!process.jar (3226ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/run/0.13.11/jars/run.jar ...  
     [SUCCESSFUL ] org.scala-sbt#run;0.13.11!run.jar (4793ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/command/0.13.11/jars/command.jar ...  
     [SUCCESSFUL ] org.scala-sbt#command;0.13.11!command.jar (3569ms)  
 downloading https://repo1.maven.org/maven2/org/scala-sbt/launcher-interface/1.0.0-M1/launcher-interface-1.0.0-M1.jar ...  
     [SUCCESSFUL ] org.scala-sbt#launcher-interface;1.0.0-M1!launcher-interface.jar (265ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/classpath/0.13.11/jars/classpath.jar ...  
     [SUCCESSFUL ] org.scala-sbt#classpath;0.13.11!classpath.jar (2508ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/completion/0.13.11/jars/completion.jar ...  
     [SUCCESSFUL ] org.scala-sbt#completion;0.13.11!completion.jar (4228ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/api/0.13.11/jars/api.jar ...  
     [SUCCESSFUL ] org.scala-sbt#api;0.13.11!api.jar (6932ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/compiler-integration/0.13.11/jars/compiler-integration.jar ...  
     [SUCCESSFUL ] org.scala-sbt#compiler-integration;0.13.11!compiler-integration.jar (2715ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/compiler-ivy-integration/0.13.11/jars/compiler-ivy-integration.jar ...  
     [SUCCESSFUL ] org.scala-sbt#compiler-ivy-integration;0.13.11!compiler-ivy-integration.jar (2659ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/relation/0.13.11/jars/relation.jar ...  
     [SUCCESSFUL ] org.scala-sbt#relation;0.13.11!relation.jar (2618ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/task-system/0.13.11/jars/task-system.jar ...  
     [SUCCESSFUL ] org.scala-sbt#task-system;0.13.11!task-system.jar (2604ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/tasks/0.13.11/jars/tasks.jar ...  
     [SUCCESSFUL ] org.scala-sbt#tasks;0.13.11!tasks.jar (3010ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/tracking/0.13.11/jars/tracking.jar ...  
     [SUCCESSFUL ] org.scala-sbt#tracking;0.13.11!tracking.jar (2193ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/testing/0.13.11/jars/testing.jar ...  
     [SUCCESSFUL ] org.scala-sbt#testing;0.13.11!testing.jar (3076ms)  
 downloading https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.10.6/scala-compiler-2.10.6.jar ...  
     [SUCCESSFUL ] org.scala-lang#scala-compiler;2.10.6!scala-compiler.jar (100258ms)  
 downloading https://repo1.maven.org/maven2/org/scala-lang/scala-reflect/2.10.6/scala-reflect-2.10.6.jar ...  
     [SUCCESSFUL ] org.scala-lang#scala-reflect;2.10.6!scala-reflect.jar (10966ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/control/0.13.11/jars/control.jar ...  
     [SUCCESSFUL ] org.scala-sbt#control;0.13.11!control.jar (2203ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/collections/0.13.11/jars/collections.jar ...  
     [SUCCESSFUL ] org.scala-sbt#collections;0.13.11!collections.jar (4384ms)  
 downloading https://repo1.maven.org/maven2/jline/jline/2.13/jline-2.13.jar ...  
     [SUCCESSFUL ] jline#jline;2.13!jline.jar (1690ms)  
 downloading https://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.11/jansi-1.11.jar ...  
     [SUCCESSFUL ] org.fusesource.jansi#jansi;1.11!jansi.jar (1058ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/classfile/0.13.11/jars/classfile.jar ...  
     [SUCCESSFUL ] org.scala-sbt#classfile;0.13.11!classfile.jar (2419ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/incremental-compiler/0.13.11/jars/incremental-compiler.jar ...  
     [SUCCESSFUL ] org.scala-sbt#incremental-compiler;0.13.11!incremental-compiler.jar (4280ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/compile/0.13.11/jars/compile.jar ...  
     [SUCCESSFUL ] org.scala-sbt#compile;0.13.11!compile.jar (3685ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/persist/0.13.11/jars/persist.jar ...  
     [SUCCESSFUL ] org.scala-sbt#persist;0.13.11!persist.jar (2781ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbinary/sbinary_2.10/0.4.2/jars/sbinary_2.10.jar ...  
     [SUCCESSFUL ] org.scala-tools.sbinary#sbinary_2.10;0.4.2!sbinary_2.10.jar (2939ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/cross/0.13.11/jars/cross.jar ...  
     [SUCCESSFUL ] org.scala-sbt#cross;0.13.11!cross.jar (2050ms)  
 downloading https://repo1.maven.org/maven2/org/scala-sbt/ivy/ivy/2.3.0-sbt-2cc8d2761242b072cedb0a04cb39435c4fa24f9a/ivy-2.3.0-sbt-2cc8d2761242b072cedb0a04cb39435c4fa24f9a.jar ...  
     [SUCCESSFUL ] org.scala-sbt.ivy#ivy;2.3.0-sbt-2cc8d2761242b072cedb0a04cb39435c4fa24f9a!ivy.jar (5077ms)  
 downloading https://repo1.maven.org/maven2/com/jcraft/jsch/0.1.46/jsch-0.1.46.jar ...  
     [SUCCESSFUL ] com.jcraft#jsch;0.1.46!jsch.jar (1399ms)  
 downloading https://repo1.maven.org/maven2/org/scala-sbt/serialization_2.10/0.1.2/serialization_2.10-0.1.2.jar ...  
     [SUCCESSFUL ] org.scala-sbt#serialization_2.10;0.1.2!serialization_2.10.jar (2002ms)  
 downloading https://repo1.maven.org/maven2/org/scala-lang/modules/scala-pickling_2.10/0.10.1/scala-pickling_2.10-0.10.1.jar ...  
     [SUCCESSFUL ] org.scala-lang.modules#scala-pickling_2.10;0.10.1!scala-pickling_2.10.jar (2997ms)  
 downloading https://repo1.maven.org/maven2/org/json4s/json4s-core_2.10/3.2.10/json4s-core_2.10-3.2.10.jar ...  
     [SUCCESSFUL ] org.json4s#json4s-core_2.10;3.2.10!json4s-core_2.10.jar (2953ms)  
 downloading https://repo1.maven.org/maven2/org/spire-math/jawn-parser_2.10/0.6.0/jawn-parser_2.10-0.6.0.jar ...  
     [SUCCESSFUL ] org.spire-math#jawn-parser_2.10;0.6.0!jawn-parser_2.10.jar (699ms)  
 downloading https://repo1.maven.org/maven2/org/spire-math/json4s-support_2.10/0.6.0/json4s-support_2.10-0.6.0.jar ...  
     [SUCCESSFUL ] org.spire-math#json4s-support_2.10;0.6.0!json4s-support_2.10.jar (122ms)  
 downloading https://repo1.maven.org/maven2/org/scalamacros/quasiquotes_2.10/2.0.1/quasiquotes_2.10-2.0.1.jar ...  
     [SUCCESSFUL ] org.scalamacros#quasiquotes_2.10;2.0.1!quasiquotes_2.10.jar (2490ms)  
 downloading https://repo1.maven.org/maven2/org/json4s/json4s-ast_2.10/3.2.10/json4s-ast_2.10-3.2.10.jar ...  
     [SUCCESSFUL ] org.json4s#json4s-ast_2.10;3.2.10!json4s-ast_2.10.jar (774ms)  
 downloading https://repo1.maven.org/maven2/com/thoughtworks/paranamer/paranamer/2.6/paranamer-2.6.jar ...  
     [SUCCESSFUL ] com.thoughtworks.paranamer#paranamer;2.6!paranamer.jar (764ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/cache/0.13.11/jars/cache.jar ...  
     [SUCCESSFUL ] org.scala-sbt#cache;0.13.11!cache.jar (2837ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/test-agent/0.13.11/jars/test-agent.jar ...  
     [SUCCESSFUL ] org.scala-sbt#test-agent;0.13.11!test-agent.jar (2668ms)  
 downloading https://repo1.maven.org/maven2/org/scala-sbt/test-interface/1.0/test-interface-1.0.jar ...  
     [SUCCESSFUL ] org.scala-sbt#test-interface;1.0!test-interface.jar (634ms)  
 downloading https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/apply-macro/0.13.11/jars/apply-macro.jar ...  
     [SUCCESSFUL ] org.scala-sbt#apply-macro;0.13.11!apply-macro.jar (2501ms)  
 :: retrieving :: org.scala-sbt#boot-app  
     confs: [default]  
     49 artifacts copied, 0 already retrieved (17330kB/137ms)  
 Getting Scala 2.10.6 (for sbt)...  
 downloading https://repo1.maven.org/maven2/org/scala-lang/jline/2.10.6/jline-2.10.6.jar ...  
     [SUCCESSFUL ] org.scala-lang#jline;2.10.6!jline.jar (1016ms)  
 downloading https://repo1.maven.org/maven2/org/fusesource/jansi/jansi/1.4/jansi-1.4.jar ...  
     [SUCCESSFUL ] org.fusesource.jansi#jansi;1.4!jansi.jar (1034ms)  
 :: retrieving :: org.scala-sbt#boot-scala  
     confs: [default]  
     5 artifacts copied, 0 already retrieved (24494kB/62ms)  
 [info] Set current project to sbt (in build file:/D:/vesedan/sbt/)  


Start Scala console
 > console  
 [info] Updating {file:/D:/vesedan/sbt/}sbt...  
 [info] Resolving org.fusesource.jansi#jansi;1.4 ...  
 [info] Done updating.  
 [info] 'compiler-interface' not yet compiled for Scala 2.10.6. Compiling...  
 [info]  Compilation completed in 16.541 s  
 [info] Starting scala interpreter...  
 [info]  
 Welcome to Scala version 2.10.6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_74).  
 Type in expressions to have them evaluated.  
 Type :help for more information.  
 scala>  
 scala>  
 scala> println("Hi!")  
 Hi!
 scala>  

Download  Scala IDE
 http://scala-ide.org/download/sdk.html

Tuesday, March 8, 2016

Openshift - deploy Java EE7 application onto Wildlfy10

OpenShift  Wildfly  https://developers.openshift.com/en/wildfly-getting-started.html

 Create OpenShift account https://openshift.redhat.com/app/account/new?then=%2Fapp%2Faccount

Install RedHat RHC  client tools  https://developers.openshift.com/en/managing-client-tools.html


sudo yum install rubygems
rhc setup

Create application via web console or using RHC tools

Write down admin password to access cloud via SSH

Open application URL in browser http://ee7full-testjavaee.rhcloud.com/




[dave@localhost ee7full.git]$ rhc apps
ee7full @ http://ee7full-testjavaee.rhcloud.com/ (uuid: 56d97e36454545636454540026f)
---------------------------------------------------------------------------------
  Domain:          testjavaee
  Created:         Mar 04  1:23 PM
  Gears:           1 (defaults to small)
  Git URL:         ssh://5645454545367a00026f@ee7full-testjavaee.rhcloud.com/~/git/ee7full.git/
  Initial Git URL: https://github.com/dveselka/wildfly/#master
  SSH:             5645454545367a00026f@ee7full-testjavaee.rhcloud.com
  Deployment:      auto (on git push)

  jboss-wildfly-10 (WildFly Application Server 10)
  ------------------------------------------------
    From:    https://raw.github.com/openshift-cartridges/openshift-wildfly-cartridge/wildfly-10/metadata/manifest.yml
    Website: http://www.wildfly.org
    Gears:   1 small

You have access to 1 application.
[dave@localhost ee7full.git]$ 


Initial source code is taken from existing GitHub code https://github.com/dveselka/wildfly


Clone Git Repository

git clone ssh://56d93434343445456f@ee7full-testjavaee.rhcloud.com/~/git/ee7full.git/


Forward ports to local host https://developers.openshift.com/en/managing-port-forwarding.html

[dave@localhost openshift]$ rhc port-forward -a ee7full
Checking available ports ... done
Forwarding ports ...

To connect to a service running on OpenShift, use the Local address

Service Local               OpenShift
------- -------------- ---- -----------------
java    127.0.0.1:3528  =>  127.5.77.129:3528
java    127.0.0.1:3529  =>  127.5.77.129:3529
java    127.0.0.1:8080  =>  127.5.37.129:8080
java    127.0.0.1:9990  =>  127.5.77.129:9990

Press CTRL-C to terminate port forwarding



Deploy application using Maven deploy plugin

dave@localhost dave-java-ee7-wildfly-full]$ pwd
/home/dave/openshift/ee7full.git/dave-java-ee7-wildfly-full
[dave@localhost dave-java-ee7-wildfly-full]$ mvn clean package wildfly:deploy


[INFO] --- wildfly-maven-plugin:1.0.2.Final:deploy (default-cli) @ dave-java-ee7-wildfly-full-ear ---
Mar 08, 2016 7:49:14 AM org.xnio.Xnio <clinit>
INFO: XNIO version 3.2.2.Final
Mar 08, 2016 7:49:14 AM org.xnio.nio.NioXnio <clinit>
INFO: XNIO NIO Implementation Version 3.2.2.Final
Mar 08, 2016 7:49:14 AM org.jboss.remoting3.EndpointImpl <clinit>
INFO: JBoss Remoting version 4.0.3.Final
Authenticating against security realm: ManagementRealm
Username:


Check application server logs

2016-03-08 01:52:43,915 INFO  [org.jboss.as.repository] (management-handler-thread - 5) WFLYDR0001: Content added at location /var/lib/openshift/56d9454545450026f/wildfly/standalone/data/content/62/75d7af5656565656573/content
2016-03-08 01:52:43,934 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "dave-java-ee7-wildfly-full-ear.ear" (runtime-name: "dave-java-ee7-wildfly-full-ear.ear")
2016-03-08 01:52:44,090 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0207: Starting subdeployment (runtime-name: "dave-java-ee7-wildfly-full-ejb.jar")
2016-03-08 01:52:44,091 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0207: Starting subdeployment (runtime-name: "dave-java-ee7-wildfly-full-web.war")
2



Access application via browser using public URL  http://ee7full-testjavaee.rhcloud.com/dave-java-ee7-wildfly-full-web/