Skip to content

Commit

Permalink
Merge pull request #34 from nokia-wroclaw/travis_heroku
Browse files Browse the repository at this point in the history
Travis heroku
  • Loading branch information
MarJack8 authored Jan 31, 2020
2 parents e47412a + 4396b07 commit 4a4fa51
Show file tree
Hide file tree
Showing 9 changed files with 133 additions and 9 deletions.
9 changes: 6 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ services:
depends_on:
- db # This service depends on mysql. Start that first.
environment: # Pass environment variables to the service
SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/db3s
#SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/db3s
#?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: 1q2w3e4r
#SPRING_DATASOURCE_USERNAME: root
#SPRING_DATASOURCE_PASSWORD: 1q2w3e4r
SPRING_DATASOURCE_URL: jdbc:mysql://b8e819c239af2b:[email protected]/heroku_7013a700c5d03a4?reconnect=true
SPRING_DATASOURCE_USERNAME: b8e819c239af2b
SPRING_DATASOURCE_PASSWORD: ce5382cc

volumes:
- /var/run/docker.sock:/var/run/docker.sock
Expand Down
11 changes: 11 additions & 0 deletions front/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:12.2.0 as build-node
WORKDIR /front
COPY . .
RUN npm install
RUN npm run build --prod
RUN npm install express
FROM nginx:1.15
COPY default.conf /etc/nginx/conf.d/default.conf
WORKDIR /usr/share/nginx/html
COPY dist/front .
CMD sed -i -e 's/$PORT/'"$PORT"'/g' /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'
2 changes: 1 addition & 1 deletion front/default.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
server {
listen 4200;
listen $PORT;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
Expand Down
2 changes: 1 addition & 1 deletion front/e2e/protractor.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports.config = {
browserName: 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
baseUrl: 'https://nokia3s-front.herokuapp.com/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
Expand Down
2 changes: 1 addition & 1 deletion front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"start": "ng serve --port $PORT --host 0.0.0.0 --disable-host-check",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
Expand Down
16 changes: 16 additions & 0 deletions server/Dockerfile.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM maven:3.5.2-jdk-8-alpine AS MAVEN_BUILD

WORKDIR /server
COPY . .
RUN mvn -Dmaven.test.skip=true package

FROM openjdk:8-jdk-alpine

WORKDIR /server
#.jar file name depends on pom.xml project.build.finalName property, eg. <finalName>SpringApp</finalName>
COPY --from=MAVEN_BUILD /server/target/server-0.0.1-SNAPSHOT.jar ./

RUN apk update && apk add docker
CMD java -Xms256m -Xmx400m -jar ./server-0.0.1-SNAPSHOT.jar
EXPOSE 8080:8080

27 changes: 27 additions & 0 deletions server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,33 @@
<properties>
<java.version>1.8</java.version>
</properties>

<repositories>
<repository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<url>http://repo.spring.io/milestone</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/snapshot</url>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<url>http://repo.spring.io/milestone</url>
</pluginRepository>
</pluginRepositories>



<dependencies>
<dependency>
Expand Down
18 changes: 15 additions & 3 deletions server/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@


## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
spring.datasource.url = jdbc:mysql://localhost:3306/db3s


#spring.datasource.url = jdbc:mysql://localhost:3306/db3s
#?useSSL=false
spring.datasource.username = root
spring.datasource.password = 1q2w3e4r
#spring.datasource.username = root
#spring.datasource.password = 1q2w3e4r

spring.datasource.url = jdbc:mysql://b8e819c239af2b:[email protected]/heroku_7013a700c5d03a4?reconnect=true
spring.datasource.username = b8e819c239af2b
spring.datasource.password = ce5382cc

spring.datasource.hikari.connectionTimeout=30000
spring.datasource.hikari.idleTimeout=600000
spring.datasource.hikari.maxLifetime=27000000

spring.session.jdbc.initialize-schema: always


## Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
Expand Down
55 changes: 55 additions & 0 deletions travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
language: java
jdk:
- openjdk8
install: true
env:
-HEROKU_API_KEY=$HEROKU_TOKEN
-TAG=test
services:
- docker
before_install:
- npm install -g @angular/cli
stages:
- name: test
- name: build
- name: deploy
jobs:
include:
- stage: test
script:
- cd server
- chmod +x mvnw
#- mvn test
- cd ..
- echo "test stage works"
- stage: build
script:
- cd front
- npm install
- npm install express
- ng build --prod
- cd ..
- cd server
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
- echo "build stage works"
- stage: deploy
script:
- curl https://cli-assets.heroku.com/install-standalone.sh | sh
- docker login --username=_ --password=$HEROKU_TOKEN registry.heroku.com
- cd server
- mvn package -DskipTests=true
- docker build -t registry.heroku.com/nokia3s-server/web -f Dockerfile.prod .
- cd ..
- cd front
- npm install
- npm install express
- ng build --prod
- docker build -t registry.heroku.com/nokia3s-front/web -f Dockerfile.prod .
- docker push registry.heroku.com/nokia3s-server/web
- docker push registry.heroku.com/nokia3s-front/web
- /usr/local/bin/heroku container:release web -a nokia3s-server
- /usr/local/bin/heroku container:release web -a nokia3s-front
- echo "deploy stage works"
cache:
directories:
- $HOME/.m2

0 comments on commit 4a4fa51

Please sign in to comment.