diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..41390ae --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +## This is the kind of files that we want to ignore +bin +target +*.class +*.jar diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4005966 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,38 @@ +sudo: required +services: + - docker + +language: java +jdk: oraclejdk8 + +branches: + only: + - master + +before_install: + - docker version + - docker info + - node --version + - npm --version + +script: + - cd alma-server/src/main/resources + - pwd + - npm install -g gulp + - npm install + - gulp minify + - cd ../../../../ + - mvn clean verify -f alma-server/pom.xml -e + +after_success: + - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASSWORD + - docker images + - docker push labrasse/alma-server:latest + +deploy: + provider: releases + api_key: "32f1875d7f018e1af412a87a93d2a500e0a34a53" + file: "alma-server/target/alma-server-1.0.0-SNAPSHOT.jar" + skip_cleanup: true + on: + tags: true diff --git a/README.md b/README.md new file mode 100644 index 0000000..86d4972 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +### ALMA server + +This repository will contain the source code of the ALMA server based on Spring Boot. + diff --git a/alma-server/pom.xml b/alma-server/pom.xml new file mode 100644 index 0000000..cf31986 --- /dev/null +++ b/alma-server/pom.xml @@ -0,0 +1,84 @@ + + + 4.0.0 + + fr.univnantes + alma-server + 1.0.0-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-parent + 1.4.2.RELEASE + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-test + test + + + + + 1.8 + labrasse + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + com.spotify + docker-maven-plugin + 0.4.11 + + + build-image + package + + build + + + + tag-image + package + + tag + + + labrasse/alma-server:${project.version} + hub.docker.com/labrasse/alma-server:${project.version} + + + + + ${docker.image.prefix}/${project.artifactId} + ${project.basedir}/src/main/docker + + ${project.version} + latest + + + + / + ${project.build.directory} + ${project.build.finalName}.jar + + + + + + + + diff --git a/alma-server/src/main/docker/Dockerfile b/alma-server/src/main/docker/Dockerfile new file mode 100644 index 0000000..3fab1b4 --- /dev/null +++ b/alma-server/src/main/docker/Dockerfile @@ -0,0 +1,5 @@ +FROM frolvlad/alpine-oraclejdk8:slim +VOLUME /tmp +ADD alma-server-1.0.0-SNAPSHOT.jar app.jar +RUN sh -c 'touch /app.jar' +ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-Dspring.profiles.active=container","-jar","/app.jar"] diff --git a/alma-server/src/main/java/fr/univnantes/alma/server/Application.java b/alma-server/src/main/java/fr/univnantes/alma/server/Application.java new file mode 100644 index 0000000..f2e8740 --- /dev/null +++ b/alma-server/src/main/java/fr/univnantes/alma/server/Application.java @@ -0,0 +1,11 @@ +package fr.univnantes.alma.server; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/alma-server/src/main/java/fr/univnantes/alma/server/controllers/HelloController.java b/alma-server/src/main/java/fr/univnantes/alma/server/controllers/HelloController.java new file mode 100644 index 0000000..c030b09 --- /dev/null +++ b/alma-server/src/main/java/fr/univnantes/alma/server/controllers/HelloController.java @@ -0,0 +1,14 @@ +package fr.univnantes.alma.server.controllers; + +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.RequestMapping; + +@RestController +public class HelloController { + + @RequestMapping("/") + public String index() { + return "Greetings from Spring Boot!"; + } + +} diff --git a/alma-server/src/main/resources/.jshintrc b/alma-server/src/main/resources/.jshintrc new file mode 100644 index 0000000..e3a7f93 --- /dev/null +++ b/alma-server/src/main/resources/.jshintrc @@ -0,0 +1,21 @@ +{ + "esversion": 6, + "node": true, + "browser": true, + "bitwise": true, + "camelcase": true, + "curly": true, + "eqeqeq": true, + "immed": true, + "indent": 2, + "latedef": true, + "newcap": true, + "noarg": true, + "quotmark": "single", + "regexp": true, + "undef": true, + "unused": true, + "strict": true, + "trailing": true, + "smarttabs": true +} diff --git a/alma-server/src/main/resources/gulpfile.js b/alma-server/src/main/resources/gulpfile.js new file mode 100644 index 0000000..3eadcb6 --- /dev/null +++ b/alma-server/src/main/resources/gulpfile.js @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2016 . + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the MIT License which + * accompanies this distribution, and is available at + * https://opensource.org/licenses/MIT + *******************************************************************************/ + +'use strict'; + +let gulp = require('gulp'), + browserify = require('gulp-browserify'), + gulpUtil = require('gulp-util'); + +var $ = require('gulp-load-plugins')(); + +gulp.task('clean', () => { + return gulp.src([ + 'static/main.min.js', + 'static/main.browserify.js', + 'checkstyle.xml' + ]).pipe($.clean()); +}); + +gulp.task('scripts', ['clean'], () => { + return gulp.src( + [ + 'static/**/*.js' + ]) + .pipe($.jshint()) + .pipe($.jshint.reporter(require('jshint-stylish'))) + .pipe($.jshint.reporter(require('jshint-checkstyle-file-reporter'))) + .pipe($.size()); +}); + +gulp.task('browserify', ['scripts'], () => { + return gulp.src(['static/main.js']) + .pipe(browserify({insertGlobals: true})) + .pipe($.concat('main.browserify.js')) + .pipe(gulp.dest('static/')); +}); + +gulp.task('minify', ['browserify'], () => { + return gulp.src(['static/main.browserify.js']) + .pipe($.uglify().on('error', gulpUtil.log)) + .pipe($.rename('main.min.js')) + .pipe(gulp.dest('static')) +}); diff --git a/alma-server/src/main/resources/package.json b/alma-server/src/main/resources/package.json new file mode 100644 index 0000000..18e2da5 --- /dev/null +++ b/alma-server/src/main/resources/package.json @@ -0,0 +1,38 @@ +{ + "name": "alma-master", + "version": "0.1.0", + "description": "Simple web application", + "private": true, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/la-brasse/alma-m2-2016.git" + }, + "keywords": [ + "alma" + ], + "author": "Stéphane Bégaudeau", + "license": "MIT", + "bugs": { + "url": "https://github.com/la-brasse/alma-m2-2016/issues" + }, + "homepage": "https://github.com/la-brasse/alma-m2-2016#readme", + "devDependencies": { + "browserify": "^13.1.0", + "gulp": "^3.9.1", + "gulp-browserify": "^0.5.1", + "gulp-clean": "^0.3.2", + "gulp-concat": "^2.6.0", + "gulp-jshint": "^2.0.1", + "gulp-load-plugins": "^1.2.4", + "gulp-rename": "^1.2.2", + "gulp-size": "^2.1.0", + "gulp-uglify": "^2.0.0", + "gulp-util": "^3.0.7", + "jshint": "^2.9.3", + "jshint-checkstyle-file-reporter": "0.0.1", + "jshint-stylish": "^2.2.1" + } +} diff --git a/alma-server/src/main/resources/static/folder/greatFunction.js b/alma-server/src/main/resources/static/folder/greatFunction.js new file mode 100644 index 0000000..98600cc --- /dev/null +++ b/alma-server/src/main/resources/static/folder/greatFunction.js @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright (c) 2016 . + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the MIT License which + * accompanies this distribution, and is available at + * https://opensource.org/licenses/MIT + *******************************************************************************/ +(function () { + 'use strict'; + + var greatFunction = function () { + alert('This is great!'); + }; + + module.exports = greatFunction; +})(); diff --git a/alma-server/src/main/resources/static/index.html b/alma-server/src/main/resources/static/index.html new file mode 100644 index 0000000..b928733 --- /dev/null +++ b/alma-server/src/main/resources/static/index.html @@ -0,0 +1,16 @@ + + + +Static Resource + + + + +
+

Home

+

Some static content

+
+ + + + diff --git a/alma-server/src/main/resources/static/main.js b/alma-server/src/main/resources/static/main.js new file mode 100644 index 0000000..0628e8d --- /dev/null +++ b/alma-server/src/main/resources/static/main.js @@ -0,0 +1,13 @@ +/******************************************************************************* + * Copyright (c) 2016 . + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the MIT License which + * accompanies this distribution, and is available at + * https://opensource.org/licenses/MIT + *******************************************************************************/ +(function () { + 'use strict'; + + var greatFunction = require('./folder/greatFunction'); + greatFunction(); +})(); diff --git a/alma-server/src/test/java/fr/univnantes/alma/server/tests/HelloControllerTest.java b/alma-server/src/test/java/fr/univnantes/alma/server/tests/HelloControllerTest.java new file mode 100644 index 0000000..b1b8f5a --- /dev/null +++ b/alma-server/src/test/java/fr/univnantes/alma/server/tests/HelloControllerTest.java @@ -0,0 +1,31 @@ +package fr.univnantes.alma.server.tests; + +import static org.hamcrest.Matchers.equalTo; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; + +@RunWith(SpringRunner.class) +@SpringBootTest +@AutoConfigureMockMvc +public class HelloControllerTest { + + @Autowired + private MockMvc mvc; + + @Test + public void getHello() throws Exception { + mvc.perform(MockMvcRequestBuilders.get("/").accept(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(content().string(equalTo("Greetings from Spring Boot!"))); + } +}