Commit 989dabcd authored by James Solum's avatar James Solum

Merge branch 'addSwarmBuildTarget' into 'master'

sm - add Swarm as a build target

See merge request !33
parents fad3a4e8 7cf2592c
Pipeline #71 passed with stages
in 1 minute and 45 seconds
target/
icing-database.h2.db
icing-database.trace.db
# Icing Node
## Install
### Prerequisites
#### Raspberry Pi
//Install CentOS using the instructions found [here](https://wiki.centos.org/SpecialInterestGroup/AltArch/Arm32/RaspberryPi3)
Install Fedora using the instructions found [here](https://fedoraproject.org/wiki/Architectures/ARM/Raspberry_Pi)
Follow the regular instructions for Fedora
#### Mac OS X
`//TODO: do we care?`
#### Fedora
1. `$ sudo dnf install java-1.8.0-openjdk-devel maven git`
#### CentOS
1. `$ sudo yum install java-1.8.0-openjdk-devel maven git`
#### Debian
1. `$ sudo apt-get install ???? git`
### Installation
2. `$ mkdir -p ~/git`
1. `$ cd ~/git`
1. `$ git clone 'http://gitlab.mccollum.enterprises/icing/media.git'`
1. `$ cd media`
## Run
### Standalone
Change to the directory (`$ cd ~/git/media`)
Run with:
`$ ./icing.sh`
(this will create database files named `icing-database.h2.db` and `icing-database.trace` to store your data)
### On App Server (like Wildfly)
Change to the directory (`$ cd ~/git/media`)
Create a war for deployment with:
`$ mvn clean -DskipTests package`
You will now find a file called `icing.war` in the `target` folder created by performing the package operation. This is the file you will be deploying.
Using the instructions for your app server (we are using Wildfly 10+ for development and testing), perform the following tasks:
1. Create a JPA data source with the JNDI name `java:/icing-media`
1. If using MySQL or MariaDB, perform the following database setup in the MySQL/MariaDB console (assuming your db is named `icing`):
1. `ALTER DATABASE icing DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;`
1. Deploy the `icing.war` file to your app server using the instructions on its website (different for Wildfly/JBoss, Glassfish/Payara, etc.)
## Update
1. Stop icing if it is running
1. Change to the directory where it exists (for example: `$ cd ~/git/media`)
1. `$ ./icing.sh update` #This will update icing and run it again
#!/bin/bash
###########################################################
# #
# Package this file in the same directory as your #
# project's output (media-swarm.jar) to run #
# it, automatically creating a database file if necessary #
# #
###########################################################
function build_icing(){
mvn -DskipTests clean package
}
# Check if a command has been provided
if ! [[ -z "$1" ]]; then
case "$1" in
update)
git pull
build_icing
;;
*)
echo "Invalid command $1"
;;
esac
fi
# Check if the jar exists, build it if not
if [[ ! -f 'target/icing-swarm.jar' ]]; then
echo "Icing jar not found. Building..."
build_icing
fi
java -Xmx512m -jar target/icing-swarm.jar #-Dswarm.ds.connection.url=jdbc:h2:file:media-database;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=TRUE
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>enterprises.mccollum.home</groupId>
<artifactId>media</artifactId>
<groupId>enterprises.mccollum.home.icing</groupId>
<artifactId>server-peer</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<version.wildfly.swarm>2017.6.0</version.wildfly.swarm>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
<!-- The DependencyManagement dependencies automatically set compatible versions on all of the dependencies below which don't have a version listed (important to ensure compatibility across Swarm components) -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>bom</artifactId>
<version>${version.wildfly.swarm}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>javax</groupId>
......@@ -84,11 +98,68 @@
<version>2.6.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<!-- WildFly Swarm Fractions (the thing that lets us run this in a single jar) -->
<dependency>
<!-- Allows use of @Inject (google Java CDI) -->
<groupId>org.wildfly.swarm</groupId>
<artifactId>cdi</artifactId>
</dependency>
<dependency>
<!-- ?, something to make CDI work, could be automatic classpath scanning -->
<groupId>org.wildfly.swarm</groupId>
<artifactId>cdi-config</artifactId>
</dependency>
<dependency>
<!-- Allows use of EJBs -->
<groupId>org.wildfly.swarm</groupId>
<artifactId>ejb</artifactId>
</dependency>
<dependency>
<!-- Allows the use of JPA (database access; google JPA) -->
<groupId>org.wildfly.swarm</groupId>
<artifactId>jpa</artifactId>
</dependency>
<dependency>
<!-- Adds a simple embedded database right into the application -->
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<!-- <version>1.4.195</version> -->
</dependency>
<dependency>
<!-- Provides the ability to host a Web UI -->
<groupId>org.wildfly.swarm</groupId>
<artifactId>jsf</artifactId>
</dependency>
<dependency>
<!-- Provides the ability to expose a ReST API (Jax-RS is the way to build ReST APIs in Java EE) -->
<groupId>org.wildfly.swarm</groupId>
<artifactId>jaxrs</artifactId>
<!-- <version>${version.wildfly.swarm}</version> -->
</dependency>
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-core</artifactId>
</dependency>
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-servlet</artifactId>
</dependency>
<!-- TEST DEPENDENCIES -->
<dependency>
<!-- Enable in-container testing with Arquillian -->
<groupId>org.wildfly.swarm</groupId>
<artifactId>arquillian</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<!-- JUnit Testing -->
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
......@@ -97,7 +168,6 @@
<version>2.8.47</version>
<scope>test</scope>
</dependency>
<!-- The following 2 dependencies are necessary for testing themoviedbapiclient, which uses the Jax-RS Client API -->
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client -->
<dependency>
......@@ -122,24 +192,18 @@
</dependencies>
<build>
<finalName>media</finalName>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>META-INF/persistence.xml</include>
</includes>
</resource>
</resources>
<finalName>icing</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<!-- Let Wildfly Swarm do it's magic when we package our jar -->
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-plugin</artifactId>
<version>${version.wildfly.swarm}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
<goal>package</goal>
</goals>
</execution>
</executions>
......
swarm:
datasources:
data-sources:
icing-media:
jndi-name: java:/icing-media
driver-name: h2
connection-url: jdbc:h2:file:icing-database;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=TRUE
username:
password:
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment