Skip to content

Commit

Permalink
ci: [#28] First integration workflow
Browse files Browse the repository at this point in the history
- Build and dockerise application
- add actuator with liveness/readiness
  • Loading branch information
davdarras committed Jan 25, 2023
1 parent a7eb2bc commit 1b27c23
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 95 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: V2 Build Docker

on: push

env:
PE_BRANCH: feature/ci

jobs:
build:
runs-on: ubuntu-latest
outputs:
release-version: ${{ steps.version-step.outputs.pe-version }}
steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"

- name: Get current version
id: version-step
run: echo "::set-output name=pe-version::$(mvn -f pom.xml help:evaluate -Dexpression=project.version -q -DforceStdout)"

- name: Print PE Version
run: echo ${{ steps.version-step.outputs.pe-version }}

- name: Build PE
run: mvn package --no-transfer-progress

- name: Upload PE jar
uses: actions/upload-artifact@v3
with:
name: pe-jar
path: target/*.jar

docker:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Download PE jar
uses: actions/download-artifact@v3
with:
name: pe-jar
path: target/

- name: Publish to Docker Hub
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: inseefr/public-enemy-back-office
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
default_branch: feature/ci
tags: ${{ needs.build.outputs.release-version }}
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM eclipse-temurin:17-jre-alpine
WORKDIR /opt/pe/
COPY ./target/*.jar /opt/pe/pe.jar
ENTRYPOINT ["java", "-jar", "/opt/pe/pe.jar"]
13 changes: 8 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@
</dependency>

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<!-- JPA -->
Expand Down Expand Up @@ -101,7 +100,7 @@
<changeLogFile>src/main/resources/db/master.xml</changeLogFile>
<diffChangeLogFile>src/main/resources/db/changelog/db.changelog-master.xml</diffChangeLogFile>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:53941/public-enemy</url>
<url>jdbc:postgresql://localhost:53941/public-enemy-db</url>
<defaultSchemaName>public</defaultSchemaName>
<contexts>test,dev,prod</contexts>
<username>stromae</username>
Expand All @@ -112,6 +111,10 @@
<logging>debug</logging>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class AppConfig implements WebMvcConfigurer {
*/
@Bean
@ConditionalOnProperty(name="application.proxy.enable", havingValue="true")
public WebClient webClientProxy(@Value("${application.proxy.url}") String proxyUrl,
@Value("${application.proxy.port}") Integer proxyPort,
public WebClient webClientProxy(@Value("${application.proxy.url}") String proxyUrl,
@Value("${application.proxy.port}") Integer proxyPort,
WebClient.Builder builder) {
HttpClient httpClient = HttpClient.newBuilder()
.proxy(ProxySelector.of(new InetSocketAddress(proxyUrl, proxyPort)))
Expand Down
67 changes: 44 additions & 23 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# Configuration des urls
server:
error:
include-binding-errors: always
include-exception: true
include-message: always
include-stacktrace: always
application:
proxy:
enable: false
url:
port:
cors:
allowed-origins:
pogues:
url: https://pogues-url.insee.fr
eno:
url: https://eno-url.insee.fr

# LOGGING
logging:
file:
path: /home/xxx/logs
path: /var/log
name: publicenemy/publicenemy.log
maxHistory: 365
level:
Expand All @@ -30,10 +34,18 @@ logging:
spring:
# DB
datasource:
url: jdbc:postgresql://localhost:53941/public-enemy
username: stromae
password: stromaePassword
hikari.maximumPoolSize: 5
url: jdbc:postgresql://localhost:5432/public-enemy
username: public-enemy
password: public-enemy-password
hikari:
maximumPoolSize: 5
connection-timeout: 20000
jpa:
open-in-view: false
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialect

# LIQUIBASE
liquibase:
enabled: true
Expand All @@ -45,8 +57,6 @@ spring:
multipart:
max-file-size: -1
max-request-size: -1
jpa:
open-in-view: false
codec:
max-in-memory-size: 5000KB
# to make springfox work
Expand All @@ -57,12 +67,23 @@ springfox:
documentation:
enabled: true

application:
proxy:
enable: false
url:
port:
cors:
allowed-origins:
pogues:
url: https://pogues-url.insee.fr
management:
server:
port: 9090
endpoints:
web:
exposure:
include: info,health
endpoint:
health:
show-details: always
probes:
enabled: true
group:
readiness:
include: db, diskSpace
health:
livenessState:
enabled: true
readinessState:
enabled: true
62 changes: 61 additions & 1 deletion src/main/resources/db/changelog/db.changelog-master.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,64 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-4.6.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.6.xsd">

<changeSet author="SC7DS3 (generated)" id="1671097612135-1">
<createTable tableName="campaign">
<column autoIncrement="true" name="id" type="INTEGER">
<constraints nullable="false" primaryKey="true" primaryKeyName="campaign_pkey"/>
</column>
<column name="label" type="VARCHAR"/>
</createTable>
</changeSet>
<changeSet author="SC7DS3 (generated)" id="1671097612135-2">
<createTable tableName="context">
<column autoIncrement="true" name="id" type="INTEGER">
<constraints nullable="false" primaryKey="true" primaryKeyName="context_pkey"/>
</column>
<column name="name" type="VARCHAR"/>
<column name="value" type="VARCHAR"/>
</createTable>
</changeSet>
<changeSet author="SC7DS3 (generated)" id="1671097612135-3">
<createTable tableName="questionnaire">
<column autoIncrement="true" name="id" type="INTEGER">
<constraints nullable="false" primaryKey="true" primaryKeyName="questionnaire_pkey"/>
</column>
<column name="label" type="VARCHAR">
<constraints nullable="false"/>
</column>
<column name="campaign_id" type="INTEGER">
<constraints nullable="false"/>
</column>
<column name="creation_date" type="date">
<constraints nullable="false"/>
</column>
<column name="updated_date" type="date">
<constraints nullable="false"/>
</column>
<column name="questionnaire_pogues_id" type="VARCHAR">
<constraints nullable="false"/>
</column>
<column name="survey_unit_data" type="TEXT">
<constraints nullable="false"/>
</column>
<column name="context" type="VARCHAR">
<constraints nullable="false"/>
</column>
</createTable>
</changeSet>
<changeSet author="SC7DS3 (generated)" id="1671097612135-4">
<createTable tableName="questionnaire_mode">
<column name="questionnaire_id" type="INTEGER">
<constraints nullable="false"/>
</column>
<column name="mode" type="VARCHAR">
<constraints nullable="false"/>
</column>
</createTable>
</changeSet>
<changeSet author="SC7DS3 (generated)" id="1671097612135-5">
<addForeignKeyConstraint baseColumnNames="campaign_id" baseTableName="questionnaire" constraintName="campaign_id_fk" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="NO ACTION" referencedColumnNames="id" referencedTableName="campaign" validate="true"/>
</changeSet>
<changeSet author="SC7DS3 (generated)" id="1671097612135-6">
<addForeignKeyConstraint baseColumnNames="questionnaire_id" baseTableName="questionnaire_mode" constraintName="questionnaire_id_fk2" deferrable="false" initiallyDeferred="false" onDelete="CASCADE" onUpdate="NO ACTION" referencedColumnNames="id" referencedTableName="questionnaire" validate="true"/>
</changeSet>
</databaseChangeLog>
64 changes: 0 additions & 64 deletions src/main/resources/db/master.xml

This file was deleted.

0 comments on commit 1b27c23

Please sign in to comment.