Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
139 commits
Select commit Hold shift + click to select a range
f203dbd
Updated with Guice/JPA/Jersey
mqprichard Jun 22, 2016
d3b6469
Added README.md
mqprichard Jun 22, 2016
1d41530
Update README with basic instructions
mqprichard Jun 22, 2016
fec6690
Formatting MD
mqprichard Jun 22, 2016
b60734a
Added example to README
mqprichard Jun 22, 2016
b0f841d
Updated jackson dependencies
mqprichard Jun 22, 2016
d5477e1
Added Apache 2.0 license
mqprichard Jun 22, 2016
6c13aba
Added alana's branch
Jun 22, 2016
a2651a3
test pull request
Jun 23, 2016
008845d
added appdynamics sample app
Jun 23, 2016
cccba6e
Merge pull request #2 from alanaanderson/alana
Jun 23, 2016
09a5498
Add web direcotry
Jun 23, 2016
8059cbe
Move src to rest
Jun 23, 2016
801ca9e
Build and run with docker-compose
Jun 23, 2016
d950c17
add web stuff
Jun 23, 2016
0d001f6
Merge remote-tracking branch 'upstream/master'
Jun 23, 2016
3c8b542
Add web direcotry
Jun 23, 2016
3a5f127
Move src to rest
Jun 23, 2016
20aa9c3
Build and run with docker-compose
Jun 23, 2016
837fc61
Fix exceptions
Jun 23, 2016
4445d97
Merge dev and master
Jun 23, 2016
22fea7a
Modify SampleApp.java
Jun 23, 2016
74e4d39
Added Agent installation to startup
mqprichard Jun 23, 2016
35762b7
Added App Server Agent install
mqprichard Jun 23, 2016
ead9cda
Added OpenJDK 8 as default
mqprichard Jun 23, 2016
7802545
web prototype
Jun 23, 2016
5fa1bf6
remove extraneous files and folders from Sample App
Jun 23, 2016
981dd66
Merge remote-tracking branch 'upstream/master'
Jun 23, 2016
cfe9d59
post request works
Jun 24, 2016
82d0565
move body-parser to node_module folder
Jun 24, 2016
573748d
Merge pull request #4 from Stephanie-Chou/master
Jun 24, 2016
b40fbd6
Style and Content Changes
Jun 24, 2016
4dd401d
Bug Fix: Save New Product shows newly added product without refresh
Jun 24, 2016
ea65bd9
add header text to sample application instructions
Jun 24, 2016
1da1949
Sample App Edits and Clean up
Jun 24, 2016
90f55f3
Moved sample-app to docker container
mqprichard Jun 24, 2016
e27b1d1
merge
Jun 24, 2016
447df53
Modify README
Jun 24, 2016
52fb97c
test pull request
Jun 23, 2016
f3b6ff4
added appdynamics sample app
Jun 23, 2016
2d980d1
add web stuff
Jun 23, 2016
c569f0d
web prototype
Jun 23, 2016
9b7e5f4
remove extraneous files and folders from Sample App
Jun 23, 2016
8401aae
post request works
Jun 24, 2016
2421b04
move body-parser to node_module folder
Jun 24, 2016
49993c4
Style and Content Changes
Jun 24, 2016
ad1b5e6
Bug Fix: Save New Product shows newly added product without refresh
Jun 24, 2016
3d87766
add header text to sample application instructions
Jun 24, 2016
37f5ab2
Sample App Edits and Clean up
Jun 24, 2016
bd5eca7
Moved sample-app to docker container
mqprichard Jun 24, 2016
5b230a9
Added node.js dynamics configuration
mqprichard Jun 24, 2016
002cb95
Using npm to load modules
mqprichard Jun 24, 2016
31df9b0
Removed node_modules
mqprichard Jun 24, 2016
160f286
Edit readme
Jun 24, 2016
526debe
Add screenshot
Jun 24, 2016
ef12893
Modify README
Jun 24, 2016
bef09c5
Cleaned up README
mqprichard Jun 24, 2016
f4a21a6
Fixed README
mqprichard Jun 24, 2016
a9580a0
Fixed .gitignore for node-properties.txt
mqprichard Jun 24, 2016
c780834
Removed appd.coffee
mqprichard Jun 24, 2016
719404f
Remove Tomcat utility webapps
mqprichard Jun 24, 2016
3b4c507
Added Response return types to RESTExceptions
mqprichard Jun 25, 2016
4eed480
clean up code
Jun 27, 2016
6539108
Added logging injection
mqprichard Jun 27, 2016
d54608a
merge
Jun 28, 2016
2791286
Added README for rest service
mqprichard Jun 28, 2016
cfca9db
Renamed web project to portal
mqprichard Jun 28, 2016
a2b891b
Renamed sample-app to web
mqprichard Jun 28, 2016
b390080
Fixed link in README.md
mqprichard Jun 28, 2016
9482e29
Updated docker-compose.yml
mqprichard Jun 28, 2016
ee594ce
Renamed web service
mqprichard Jun 28, 2016
898b5e0
Moved AppD agent config and start commands to exec scripts
mqprichard Jul 1, 2016
6b00093
Added -it flag to log tail instructions and comments
mqprichard Jul 1, 2016
2eae018
Sample App Server Code Clean Up and Button Functionality
Jul 5, 2016
4611c2b
Added README for rest service
mqprichard Jun 28, 2016
cf2254b
Renamed web project to portal
mqprichard Jun 28, 2016
51cc2f5
Renamed sample-app to web
mqprichard Jun 28, 2016
c908fc0
Fixed link in README.md
mqprichard Jun 28, 2016
6304e0f
Updated docker-compose.yml
mqprichard Jun 28, 2016
fd5bdd8
Renamed web service
mqprichard Jun 28, 2016
25c09e6
Moved AppD agent config and start commands to exec scripts
mqprichard Jul 1, 2016
682599a
Added -it flag to log tail instructions and comments
mqprichard Jul 1, 2016
6c85041
test pull request
Jun 23, 2016
2f97197
add web stuff
Jun 23, 2016
9ad5e1e
web prototype
Jun 23, 2016
f0694e7
Style and Content Changes
Jun 24, 2016
c362d24
Moved sample-app to docker container
mqprichard Jun 24, 2016
d7291f8
Sample App Server Code Clean Up and Button Functionality
Jul 5, 2016
983cc1c
Merge
Jul 6, 2016
8f7998b
merge remove portal
Jul 6, 2016
e47ed40
Modify web to start with docker exec
Jul 6, 2016
9cc9cb3
Remove redundant files
Jul 6, 2016
ec8318e
Merge conflicts
Jul 6, 2016
745e494
Merge branch 'Stephanie-Chou-master' into merge
Jul 6, 2016
333a9e8
Update Dockerfile and package.json
Jul 7, 2016
206655a
Modified README
Jul 11, 2016
0d4944a
Update README
Jul 11, 2016
11f5219
Bug Fix: java and sql exceptions should be thrown
Jul 18, 2016
5e691ff
Merge pull request #8 from Stephanie-Chou/master
Jul 18, 2016
191d1f2
Bug Fix: Java and Sql exceptions were not thrown from node app
Jul 18, 2016
b5781de
Enable connection through ssl
Jul 20, 2016
e9b9db8
Enable ssl for web
Jul 20, 2016
f1154e8
Modify readme and small fix
Jul 21, 2016
de46839
Fix ssl logic for rest and web
Jul 26, 2016
66bd22b
Bug Fix: delete and update always effect last product, not selected p…
Aug 1, 2016
3755b54
Rename start to start-all
Aug 2, 2016
06ec0df
Edit README
Aug 2, 2016
461defe
App Clean Up
Aug 3, 2016
150217d
Added environment variables for controller and portal properties
mqprichard Aug 10, 2016
a27f3a9
Added environment variables to web container
mqprichard Aug 10, 2016
d1a1615
Added import.sql and GenerationType.IDENTITY
mqprichard Aug 10, 2016
b5e429f
Sample App Style Redesign
Aug 10, 2016
e9abcb6
Added appd-controller.js to web container
mqprichard Aug 12, 2016
b7bd6fb
Sample App Style Redesign
Aug 17, 2016
71fc2b2
Sample App Style Redesign
Aug 17, 2016
0d9a36c
Sample App Style Redesign
Aug 17, 2016
53dad73
Add ApplicationId
Aug 25, 2016
02133f0
add -o to unzip, avoid check for existing files
Aug 22, 2016
75c6070
Added Controller API call to retrieve app id
mqprichard Aug 26, 2016
887b41e
Added Controller credentials for API calls
mqprichard Aug 26, 2016
fc2c437
Fixed typo in usage message
mqprichard Aug 26, 2016
4a418e4
Removed Controller API call, added checks to install scripts
mqprichard Aug 29, 2016
8f22ad3
Added Jennifer's changes to pick up app id
mqprichard Aug 29, 2016
92c766f
Fixed typo in docker-compose.yml
mqprichard Aug 29, 2016
2eeb757
Move flowmap to business transaction section
Aug 29, 2016
47dca52
Small changes of text and added favicon
Aug 29, 2016
5cde019
Fix favicon path
Aug 29, 2016
bd0553d
Formatted script output
mqprichard Aug 29, 2016
dba1c85
Fix typos
Aug 30, 2016
e363972
Modify yml file to pull from Docker Hub
Aug 30, 2016
c77b758
Modify README
Sep 16, 2016
d6c94ee
Update Readme
Sep 16, 2016
2a4ce22
Modify link url to include accountName
Sep 18, 2016
5e87970
Add Infographic
Sep 23, 2016
0d185e7
remove include line. sample app was not loading
Sep 27, 2016
87d0313
Updated UI to include screenshots, button pattern, removed slow trans…
Oct 6, 2016
15a90d8
Fix add and delete buttons
Oct 6, 2016
65d8537
Update view to multiple pages, add CTA to Getting Started, error hand…
Oct 10, 2016
9bc509f
Adjust Typos
Nov 19, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
jdk-*
tomcat-users.xml
target
AppServerAgent.zip
node-properties.txt
69 changes: 0 additions & 69 deletions Dockerfile

This file was deleted.

40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Docker based Sample Application with Java REST server, MySQL database and Node.js frontend.

### Project Setup
1. Copy [docker-compose.yml](https://github.com/Appdynamics/SampleApp/blob/master/docker-compose.yml) and save to local
2. Fill in environment variables:
- **CONTROLLER_URL** : For example: xxx.saas.appdynamics.com
- **CONTROLLER_PORT** : 443 (SaaS controller), 8090 (or whichever port you set for on-prem controller)
- **CONTROLLER_ACCOUNT_NAME** : Get from License information
- **CONTROLLER_ACCESS_KEY**: Get from License information
- **PORTAL_USERNAME**: Your appdynamics.com account (required for downloading agents)
- **PORTAL_PASSWORD**: Your appdynamics.com password (required for downloading agents)
- **AGENT_VERSION**: Your 4 digit controller version, for example: 4.2.3.2.
- **APP_ID**: Not applicable if trying from GitHub source. Leave empty. (Note, some features are not availble with APP_ID left empty)

> **Note**: If you want to build Docker images from source code, clone the project and uncomment line 7 and line 34 in docker-compose.yml.

### Deploy

1. Start the application from docker-compose.yml directory by running:

```docker-compose up -d```
2. Once you see "... Creating web", run this command to install AppDynamics agents:

```docker exec -it rest install-appdynamics; docker exec rest start-all```
3. Now your app is running (your default Docker host may not be 192.168.99.100):
* Java REST server: [192.168.99.100:8080/SampleApp/products](http://192.168.99.100:8080/SampleApp/products)
* Node.js web frontend: [192.168.99.100:3000](http://192.168.99.100:3000/#)

Open frontend in browser, you will see this:

![alt tag](https://github.com/Appdynamics/SampleApp/blob/master/web/src/public/img/sampleapp.png)
### Clean up
* Stop and remove all the running containers:

```docker-compose down```
* Remove all the images:

``` docker rmi -f appdynamics/sample-app-rest appdynamics/sample-app-web mysql```
* Delete docker-compose.yml
* Your enviroment is clean now!
47 changes: 47 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version: '2'

services:
rest:
#Uncomment line below if you want to build from Github source code
#Otherwise it will pull pre-built images from Docker Hub
#build: ./rest
container_name: rest
image: appdynamics/sample-app-rest
environment:
- CONTROLLER_URL=
- CONTROLLER_PORT=
- CONTROLLER_ACCOUNT_NAME=
- CONTROLLER_ACCESS_KEY=
- PORTAL_USERNAME=
- PORTAL_PASSWORD=
- AGENT_VERSION=
links:
- db
ports:
- "8080:8080"

db:
container_name: db
image: mysql
environment:
- MYSQL_ROOT_PASSWORD=secretquery
ports:
- "3306:3306"

web:
#Uncomment line below if you want to build from Github source code
#Otherwise it will pull pre-built images from Docker Hub
#build: ./web
container_name: web
image: appdynamics/sample-app-web
environment:
- CONTROLLER_URL=
- CONTROLLER_PORT=
- CONTROLLER_ACCOUNT_NAME=
- CONTROLLER_ACCESS_KEY=
- APP_ID=
links:
- rest
- db
ports:
- "3000:3000"
72 changes: 0 additions & 72 deletions pom.xml

This file was deleted.

96 changes: 96 additions & 0 deletions rest/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
FROM centos:centos6
MAINTAINER alana.anderson@appdynamics.com

# Install Oracle Java JDK 8
# Download the Oracle JDK from http://www.oracle.com/technetwork/java/javase/downloads
# Download the 64-bit Linux RPM distribution, copy to the directory containing this file and set the version below
#ENV JDK8_VERSION 92
#ADD jdk-8u${JDK8_VERSION}-linux-x64.rpm /jdk-linux-x64.rpm
#RUN yum install -y jdk-linux-x64.rpm
#RUN rm jdk-linux-x64.rpm
#ENV JAVA_HOME /usr/java/jdk1.8.0_${JDK8_VERSION}
#ENV PATH $JAVA_HOME/bin:$PATH

# Install OpenJDK 8
RUN yum install -y java-1.8.0-openjdk-devel
ENV JAVA_HOME /usr/lib/jvm/jre-1.8.0-openjdk.x86_64
ENV PATH $JAVA_HOME/bin:$PATH

# set timezone to UTC
RUN mv /etc/localtime /etc/localtime.bak
RUN ln -s /usr/share/zoneinfo/Etc/UTC /etc/localtime

# Install OS packages
RUN yum install -y wget unzip rsyslog

# Environment vars: Tomcat
ENV TOMCAT_MAJOR_VERSION 8
ENV TOMCAT_MINOR_VERSION 8.0.14
ENV CATALINA_HOME /tomcat

# Install Tomcat
RUN curl -O -k https://archive.apache.org/dist/tomcat/tomcat-${TOMCAT_MAJOR_VERSION}/v${TOMCAT_MINOR_VERSION}/bin/apache-tomcat-${TOMCAT_MINOR_VERSION}.tar.gz \
&& curl -O -k https://archive.apache.org/dist/tomcat/tomcat-${TOMCAT_MAJOR_VERSION}/v${TOMCAT_MINOR_VERSION}/bin/apache-tomcat-${TOMCAT_MINOR_VERSION}.tar.gz.md5 \
&& md5sum apache-tomcat-${TOMCAT_MINOR_VERSION}.tar.gz.md5 \
&& tar zxf apache-tomcat-*.tar.gz \
&& rm apache-tomcat-*.tar.gz* \
&& mv apache-tomcat-${TOMCAT_MINOR_VERSION} tomcat
RUN cd ${CATALINA_HOME}/bin;chmod +x *.sh
RUN rm -rf ${CATALINA_HOME}/webapps/*

# Install Maven
RUN wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo
RUN sed -i s/\$releasever/6/g /etc/yum.repos.d/epel-apache-maven.repo
RUN yum install -y apache-maven
RUN mvn --version

# Build sample project
ENV PROJECT_NAME SampleApp
ENV APP_NAME SampleApp
RUN mkdir ${APP_NAME}
ADD pom.xml /${APP_NAME}/
ADD src /${APP_NAME}/src/
RUN cd /${APP_NAME}; mvn clean install

# Copy war file to Tomcat
RUN cp ${PROJECT_NAME}/target/${APP_NAME}.war ${CATALINA_HOME}/webapps/
RUN yum install -y unzip

# Scripts to install AppDynamics Agents
ADD install-appdynamics.sh /usr/local/bin/install-appdynamics
RUN chmod +x /usr/local/bin/install-appdynamics

ENV MACHINE_AGENT_HOME /machineagent
ENV MACHINE_AGENT_OUTPUT ${MACHINE_AGENT_HOME}/machine-agent.out
ENV DB_AGENT_HOME /dbagent
ENV DB_AGENT_OUTPUT ${DB_AGENT_HOME}/dbagent.out

# Scripts to start Tomcat and AppDynamics Database/Machine Agents
ADD start-db-agent.sh /usr/local/bin/start-db-agent
ADD start-machine-agent.sh /usr/local/bin/start-machine-agent
ADD start-tomcat.sh /usr/local/bin/start-tomcat
ADD start-all.sh /usr/local/bin/start-all

RUN chmod +x /usr/local/bin/start-db-agent
RUN chmod +x /usr/local/bin/start-machine-agent
RUN chmod +x /usr/local/bin/start-tomcat
RUN chmod +x /usr/local/bin/start-all

# Scripts to tail log file output from AppDynamics Agents
ADD tail-db-agent.sh /usr/local/bin/tail-db-agent
ADD tail-machine-agent.sh /usr/local/bin/tail-machine-agent
ADD tail-java-agent.sh /usr/local/bin/tail-java-agent

RUN chmod +x /usr/local/bin/tail-db-agent
RUN chmod +x /usr/local/bin/tail-machine-agent
RUN chmod +x /usr/local/bin/tail-java-agent

# AppDynamics Agent configuration
RUN touch /env.sh
RUN chmod +x /env.sh

# Tail syslog to keep container running
CMD tail -f /var/log/messages

# Tomcat listen port
EXPOSE 8080
53 changes: 53 additions & 0 deletions rest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
*NOTE: these examples assume that your local DOCKER_HOST is mapped to localdocker, change as necessary to suit your local environment*

### Using the REST Interface - Products
This application implements a simple REST web service that allows you to create, update, delete, list and view Products: the Product object has a simple JSON structure, e.g:

{
"id": 1,
"name": "iPhone",
"stock": 1
}

The id field is automatically generated when you create the object. The service is implemented in Java using [Jersey](https://jersey.java.net/), [Jackson](https://github.com/FasterXML/jackson) and [Guice](https://github.com/google/guice) and persistence is implemented using [MySQL](https://www.mysql.com/) and [Hibernate](http://hibernate.org/orm/).

The simple examples below use curl, but you can [Postman](https://www.getpostman.com/apps) or other REST clients for POST, PUT and DELETE operations and your browser for GET requests.

CREATE

- `curl -X POST -H "Content-Type:application/json" localdocker:8080/SampleApp/products -d '{"name":"iPhone", "stock":1 }'`

UPDATE

- `curl -X PUT -H "Content-Type:application/json" localdocker:8080/SampleApp/products/1 -d '{"name":"iPad", "stock":3 }'`

DELETE

- `curl -X DELETE localdocker:8080/SampleApp/products/1`

LIST

- `curl -X GET localdocker:8080/SampleApp/products`

VIEW

- `curl -X GET localdocker:8080/SampleApp/products/1`

### Using the REST Interface - Exceptions
There is also a REST interface to trigger Java and SQL Exceptions and to run a slow transaction:

Trigger a Java Exception

- `curl -v localdocker:8080/SampleApp/exceptions/java`
- returns `HTTP/1.1 500 Internal Server Error`

Trigger a SQL Exception

- `curl -v localdocker:8080/SampleApp/exceptions/sql`
- returns `HTTP/1.1 500 Internal Server Error`

Trigger a Slow Transaction

- `curl -v localdocker:8080/SampleApp/exceptions/slow/10`
- Path Param specifies number of seconds to complete
- returns `HTTP/1.1 200 OK`
Loading