Skip to content

Commit 6c48a68

Browse files
committed
feat: add g8 template
1 parent 09ce9de commit 6c48a68

40 files changed

+1201
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/main/g8/src/main/resources/* linguist-vendored=true

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
Akka-http graphQL Bootstrap
2+
=========================
3+
4+
[![travis-ci.org](https://travis-ci.org/innFactory/bootstrap-akka-graphql.svg?branch=master)](https://travis-ci.org/innFactory/bootstrap-akka-graphql)
5+
[![codecov.io](https://img.shields.io/codecov/c/github/innFactory/bootstrap-akka-graphql/master.svg?style=flat)](https://codecov.io/github/innFactory/bootstrap-akka-graphql)
6+
[![shields.io](http://img.shields.io/badge/license-Apache2-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt)
7+
[![jonato.de](https://img.shields.io/badge/Version-1.0-brightgreen.svg)](https://innFactory.de)
8+
9+
## Info
10+
This is a boilerplate template for a akka graphql microservice with slick and flyway database migration. You can use it to create your own GraphQL Services on top of the lightbend stack.
11+
12+
### Requirements
13+
* JDK8 [http://www.oracle.com/technetwork/java/javase/downloads/index.html](http://www.oracle.com/technetwork/java/javase/downloads/index.html))
14+
* sbt([http://www.scala-sbt.org/release/docs/Getting-Started/Setup.html](http://www.scala-sbt.org/release/docs/Getting-Started/Setup.html))
15+
* docker for dockerbuild ([https://www.docker.com/community-edition/](https://www.docker.com/community-edition/))
16+
* aws account if you want to use a cognito userpool for authentifaction ([https://aws.amazon.com/de/](https://aws.amazon.com/de/))
17+
18+
### Implemented Features
19+
20+
* Integration of *graphiql* ui ```localhost:8080```
21+
* Integration *sangria* for graphql
22+
* CRUD Repositorys via *slick-repo* with a sample service with get and add implemented
23+
* CORS Support via *akka-http-cors*
24+
* Implemented Authentication with AWS Cognito (JWK) and JWT Token via *nimbusds* (in *Java*) - For Tests All Requests are allowed
25+
* Test coverage with *ScalaTest* and *scoverage* code coverage report
26+
* Ready for *Docker* deployment and *CloudFormation* deployment
27+
* Config file with optional runtime parameters
28+
* In-Memory Postgres SQL database for tests
29+
* Flyway database migration
30+
* *HikariCP* as connection pool
31+
* Logging via *Log4j* with a xml template
32+
33+
## Configuration
34+
* Start a PostgreSQL Database via RDS, Docker or locally
35+
* Create a Userpool with AWS Cognito if you need AWS Authentication.
36+
* Configure your application.conf and the docker.conf (`src/main/resources/`) (application.conf in test has to stay as it is, for running in a in-memory postgresql instance)
37+
38+
### Environment variables
39+
- `SQL_URL` - database url by scheme `jdbc:postgresql://host:port/database-name`
40+
- `SQL_USER` - database user
41+
- `SQL_PASSWORD` - database password
42+
- `NIC_IP` - IP Address bounded to the http service default is 0.0.0.0
43+
- `NIC_PORT` - TCP Port used for the http service default is 8080
44+
- `USER_POOL` - Define an other cognito user pool than the preconfigured userpool
45+
46+
47+
## Run application
48+
To run application, call:
49+
```
50+
sbt run
51+
```
52+
If you wanna restart your application without reloading of sbt, use (*revolver* sbt plugin):
53+
```
54+
sbt re-start
55+
```
56+
57+
### Run in Docker
58+
For launching application in Docker, you must configure database docker instance and run docker image, generated by sbt.
59+
60+
Generating application docker image and publishing on localhost:
61+
```
62+
sbt docker:publishLocal
63+
```
64+
65+
Example of running, generated docker image:
66+
```
67+
docker run --name akkaHttp -e SQL_USER=dbuser -e SQL_PASSWORD=dbpass -e SQL_URL=jdbcURL -d -p 9090:9000 APPLICATION_IMAGE
68+
```
69+
- `APPLICATION_IMAGE` - id or name of application docker image
70+
71+
look at ```--link``` parameter if the database is also a docker container
72+
73+
## Test
74+
To run tests, call:
75+
```
76+
sbt test
77+
```
78+
79+
To run all tests, with codecoverage, call:
80+
81+
```sbt clean coverage test```
82+
83+
To generate a coverage report afterwars the testrun, call:
84+
85+
```sbt coverageReport```
86+
87+
## More Info
88+
We will write a blog post soon on innFactory about microservice development.
89+
90+
## Copyright & Contributers
91+
Tobias Jonas
92+
93+
Copyright (C) 2017 [innFactory Cloud- & DataEngineering](https://innFactory.de)
94+
95+
Published under the Apache 2 License.

build.sbt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This build is for this Giter8 template.
2+
// To test the template run `g8` or `g8Test` from the sbt session.
3+
// See http://www.foundweekends.org/giter8/testing.html#Using+the+Giter8Plugin for more details.
4+
lazy val root = (project in file(".")).
5+
settings(
6+
name := "bootstrap-akka-graphql",
7+
test in Test := {
8+
val _ = (g8Test in Test).toTask("").value
9+
},
10+
scriptedLaunchOpts ++= List("-Xms1024m", "-Xmx1024m", "-XX:ReservedCodeCacheSize=128m", "-XX:MaxPermSize=256m", "-Xss2m", "-Dfile.encoding=UTF-8"),
11+
resolvers += Resolver.url("typesafe", url("http://repo.typesafe.com/typesafe/ivy-releases/"))(Resolver.ivyStylePatterns)
12+
)

project/build.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=0.13.16-RC1

project/giter8.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("org.foundweekends.giter8" %% "sbt-giter8" % "0.9.0")

src/main/g8/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/main/resources/* linguist-vendored=true

src/main/g8/.travis.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
language: scala
2+
3+
scala:
4+
- 2.11.8
5+
6+
jdk:
7+
- oraclejdk8
8+
9+
branches:
10+
only:
11+
- master
12+
13+
notifications:
14+
email: false
15+
16+
script:
17+
- sbt clean coverage test coverageReport
18+
19+
after_success:
20+
- bash <(curl -s https://codecov.io/bash)
21+
File renamed without changes.

src/main/g8/README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
Akka-http graphQL Bootstrap
2+
=========================
3+
4+
[![travis-ci.org](https://travis-ci.org/innFactory/bootstrap-akka-graphql.svg?branch=master)](https://travis-ci.org/innFactory/bootstrap-akka-graphql)
5+
[![codecov.io](https://img.shields.io/codecov/c/github/innFactory/bootstrap-akka-graphql/master.svg?style=flat)](https://codecov.io/github/innFactory/bootstrap-akka-graphql)
6+
[![shields.io](http://img.shields.io/badge/license-Apache2-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt)
7+
[![jonato.de](https://img.shields.io/badge/Version-1.0-brightgreen.svg)](https://innFactory.de)
8+
9+
## Info
10+
This is a boilerplate template for a akka graphql microservice with slick and flyway database migration. You can use it to create your own GraphQL Services on top of the lightbend stack.
11+
12+
### Requirements
13+
* JDK8 [http://www.oracle.com/technetwork/java/javase/downloads/index.html](http://www.oracle.com/technetwork/java/javase/downloads/index.html))
14+
* sbt([http://www.scala-sbt.org/release/docs/Getting-Started/Setup.html](http://www.scala-sbt.org/release/docs/Getting-Started/Setup.html))
15+
* docker for dockerbuild ([https://www.docker.com/community-edition/](https://www.docker.com/community-edition/))
16+
* aws account if you want to use a cognito userpool for authentifaction ([https://aws.amazon.com/de/](https://aws.amazon.com/de/))
17+
18+
### Implemented Features
19+
20+
* Integration of *graphiql* ui ```localhost:8080```
21+
* Integration *sangria* for graphql
22+
* CRUD Repositorys via *slick-repo* with a sample service with get and add implemented
23+
* CORS Support via *akka-http-cors*
24+
* Implemented Authentication with AWS Cognito (JWK) and JWT Token via *nimbusds* (in *Java*) - For Tests All Requests are allowed
25+
* Test coverage with *ScalaTest* and *scoverage* code coverage report
26+
* Ready for *Docker* deployment and *CloudFormation* deployment
27+
* Config file with optional runtime parameters
28+
* In-Memory Postgres SQL database for tests
29+
* Flyway database migration
30+
* *HikariCP* as connection pool
31+
* Logging via *Log4j* with a xml template
32+
33+
## Configuration
34+
* Start a PostgreSQL Database via RDS, Docker or locally
35+
* Create a Userpool with AWS Cognito if you need AWS Authentication.
36+
* Configure your application.conf and the docker.conf (`src/main/resources/`) (application.conf in test has to stay as it is, for running in a in-memory postgresql instance)
37+
38+
### Environment variables
39+
- `SQL_URL` - database url by scheme `jdbc:postgresql://host:port/database-name`
40+
- `SQL_USER` - database user
41+
- `SQL_PASSWORD` - database password
42+
- `NIC_IP` - IP Address bounded to the http service default is 0.0.0.0
43+
- `NIC_PORT` - TCP Port used for the http service default is 8080
44+
- `USER_POOL` - Define an other cognito user pool than the preconfigured userpool
45+
46+
47+
## Run application
48+
To run application, call:
49+
```
50+
sbt run
51+
```
52+
If you wanna restart your application without reloading of sbt, use (*revolver* sbt plugin):
53+
```
54+
sbt re-start
55+
```
56+
57+
### Run in Docker
58+
For launching application in Docker, you must configure database docker instance and run docker image, generated by sbt.
59+
60+
Generating application docker image and publishing on localhost:
61+
```
62+
sbt docker:publishLocal
63+
```
64+
65+
Example of running, generated docker image:
66+
```
67+
docker run --name akkaHttp -e SQL_USER=dbuser -e SQL_PASSWORD=dbpass -e SQL_URL=jdbcURL -d -p 9090:9000 APPLICATION_IMAGE
68+
```
69+
- `APPLICATION_IMAGE` - id or name of application docker image
70+
71+
look at ```--link``` parameter if the database is also a docker container
72+
73+
## Test
74+
To run tests, call:
75+
```
76+
sbt test
77+
```
78+
79+
To run all tests, with codecoverage, call:
80+
81+
```sbt clean coverage test```
82+
83+
To generate a coverage report afterwars the testrun, call:
84+
85+
```sbt coverageReport```
86+
87+
## More Info
88+
We will write a blog post soon on innFactory about microservice development.
89+
90+
## Copyright & Contributers
91+
Tobias Jonas
92+
93+
Copyright (C) 2017 [innFactory Cloud- & DataEngineering](https://innFactory.de)
94+
95+
Published under the Apache 2 License.

src/main/g8/build.sbt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name := "bootstrap-akka-graphql"
2+
organization := "de.innfactory"
3+
version := "1.0.0"
4+
scalaVersion := Version.Scala
5+
6+
libraryDependencies ++= {
7+
Seq(
8+
Library.akkaActor,
9+
Library.akkaHttp,
10+
Library.akkaHttpCors,
11+
Library.akkaHttpSprayJson,
12+
Library.akkaStream,
13+
Library.log4jCore,
14+
Library.slf4jLog4jBridge,
15+
Library.akkaLog4j,
16+
Library.slick,
17+
Library.slickHikaricp,
18+
Library.postgresql,
19+
Library.slickRepo,
20+
Library.flywaydb,
21+
Library.nimbusds,
22+
Library.sangria,
23+
Library.sangriaSprayJson,
24+
TestLibrary.akkaTestkit,
25+
TestLibrary.akkaHttpTestkit,
26+
TestLibrary.postgresqlEmbedded,
27+
TestLibrary.scalaTest
28+
)
29+
}
30+
31+
Revolver.settings
32+
enablePlugins(JavaAppPackaging)
33+
enablePlugins(DockerPlugin)
34+
35+
dockerExposedPorts := Seq(8080)
36+
dockerEntrypoint := Seq("bin/%s" format executableScriptName.value, "-Dconfig.resource=docker.conf")

0 commit comments

Comments
 (0)