Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:machbarschaft/service-api-ng int…
Browse files Browse the repository at this point in the history
…o develop
  • Loading branch information
wirths committed Dec 20, 2020
2 parents e99fa75 + dfac117 commit 7bdba53
Show file tree
Hide file tree
Showing 46 changed files with 548 additions and 92 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/nightly.yml → .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# This is a basic workflow to help you get started with Actions

name: CI/CD Nightly
name: CI/CD Staging

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [ develop ]
branches:
- '**'
- '!master'

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand All @@ -20,7 +20,8 @@ jobs:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- uses: actions/setup-java@v1
- name: Java Setup
uses: actions/setup-java@v1
with:
java-version: 11

Expand All @@ -30,22 +31,21 @@ jobs:
arguments: clean assemble

- name: Prepare Cloud Build
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
uses: google-github-actions/setup-gcloud@master
with:
service_account_key: ${{ secrets.GCLOUD_AUTH }}
service_account_key: ${{ secrets.GCLOUD_AUTH_STA }}

- name: Cloud Run Deployment
run: |
touch empty.ignore
gcloud config set project model-link-272316
gcloud builds submit --ignore-file=empty.ignore --tag gcr.io/model-link-272316/colivery-api-ng:nightly
gcloud run deploy service-api-ng-nightly \
--image gcr.io/model-link-272316/colivery-api-ng:nightly \
--concurrency=default \
--memory=512Mi \
--set-env-vars=^:^MaxRAM=512m:profiles_active=cloudsql:database_password=$database_password:database_name=nightly:google_maps_api_key=$google_maps_api_key \
--region=europe-west1 \
--platform=managed
gsutil cp gs://keystorage-${PROJECT_ID_STA}/credentials.json credentials.json
gcloud config set project ${PROJECT_ID_STA}
gcloud builds submit --ignore-file empty.ignore --tag gcr.io/${PROJECT_ID_STA}/machbarschaft-api:develop
gcloud run deploy machbarschaft-api-sta \
--image gcr.io/${PROJECT_ID_STA}/machbarschaft-api:develop \
--update-env-vars google_maps_api_key=$google_maps_api_key \
--region europe-west1 \
--platform managed
env:
database_password: ${{ secrets.DEVELOP_DB_PASSWORD }}
google_maps_api_key: ${{ secrets.google_maps_api_key }}
PROJECT_ID_STA: ${{ secrets.PROJECT_ID_STA }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ build/
!**/src/main/**
!**/src/test/**

### Terraform ###
.terraform*
terraform.tfstate.d/
secrets.auto.tfvars

### STS ###
.apt_generated
.classpath
Expand Down
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM adoptopenjdk/openjdk11:slim
VOLUME /tmp
COPY build/libs/service-api-ng-*.jar app.jar
ENTRYPOINT java -jar /app.jar --server.port=$PORT
COPY build/libs/service-api-ng-*.jar /app.jar
COPY credentials.json /credentials.json
CMD ["java", "-jar", "/app.jar"]
EXPOSE 8080
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ fun toAnonymizedUserResource(user: UserEntity) =
zipCode = user.zipCode,
city = user.city,
locationGeoHash = user.locationGeoHash,
centerOfLocationGeoHash = decodeGeoHash(user.locationGeoHash),
centerOfLocationGeoHash = user.locationGeoHash?.let { decodeGeoHash(it) },
source = user.source
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fun toUserResource(user: UserEntity) =
zipCode = user.zipCode,
city = user.city,
email = user.email,
location = user.location.toGeoPointResource(),
location = user.location?.toGeoPointResource(),
locationGeoHash = user.locationGeoHash,
phone = user.phone,
createdAt = user.createdAt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ data class UserEntity(
@Column(nullable = true)
var streetNo: String?,

@Column(nullable = false)
var zipCode: String,
@Column(nullable = true)
var zipCode: String?,

@Column(nullable = false)
var city: String,
@Column(nullable = true)
var city: String?,

@Column(nullable = true)
var email: String?,

@Column(nullable = false)
var location: Point,
@Column(nullable = true)
var location: Point?,

@Column(nullable = false)
var locationGeoHash: String,
@Column(nullable = true)
var locationGeoHash: String?,

@Column(nullable = false)
var phone: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,14 @@ data class CreateUserDto(
val firstName: String?,
@field:NotEmpty(groups = [App::class])
val lastName: String?,
@field:NotEmpty(groups = [App::class])
val street: String?,
@field:NotEmpty(groups = [App::class])
val streetNo: String?,
@field:NotEmpty
val zipCode: String,
@field:NotEmpty
val city: String,
val zipCode: String?,
val city: String?,
@field:NotEmpty(groups = [App::class])
@field:Email(groups = [App::class])
val email: String?,
@field:NotNull
val location: GeoPointResource,
val location: GeoPointResource?,
@field:NotEmpty
val phone: String,
@field:NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import java.util.*
data class AnonymizedUserResource(
val id: UUID?,
val firstName: String?,
val zipCode: String,
val city: String,
val locationGeoHash: String,
val centerOfLocationGeoHash: GeoPointResource,
val zipCode: String?,
val city: String?,
val locationGeoHash: String?,
val centerOfLocationGeoHash: GeoPointResource?,
val source: Source
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ data class UserResource(
val lastName: String?,
val street: String?,
val streetNo: String?,
val zipCode: String,
val city: String,
val zipCode: String?,
val city: String?,
val email: String?,
val location: GeoPointResource,
val locationGeoHash: String,
val location: GeoPointResource?,
val locationGeoHash: String?,
val phone: String,
val createdAt: LocalDateTime,
val updatedAt: LocalDateTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ class UserRestService(
city = createUserDto.city,
email = createUserDto.email,
firebaseUid = firebaseToken.uid,
location = createUserDto.location.toGeoPoint(this.geometryFactory),
locationGeoHash = encodeGeoHash(createUserDto.location),
location = createUserDto.location?.toGeoPoint(this.geometryFactory),
locationGeoHash = createUserDto.location?.let { encodeGeoHash(it) },
phone = createUserDto.phone,
source = createUserDto.source
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class SecurityConfiguration(
val corsConfig = CorsConfiguration()
// note: allowed origins have to be declared without / at the end
// corsConfig.allowedOrigins = this.corsAllowedOrigins.toList()
corsConfig.allowedOrigins = listOf("https://machbarschaft-dashboard-test.web.app","https://colivery-app.web.app")
corsConfig.allowedOrigins = listOf("https://ds.machbarschaft.jetzt","https://ds-sta.machbarschaft.jetzt")
corsConfig.allowedHeaders = listOf("*")
corsConfig.allowedMethods = listOf("*")

Expand Down
15 changes: 7 additions & 8 deletions src/main/resources/application-cloudsql.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
spring.datasource.username =postgres
spring.datasource.password =${database_password}
spring.cloud.gcp.sql.enabled =true
spring.cloud.gcp.sql.instance-connection-name=model-link-272316:europe-west3:colivery-develop
spring.cloud.gcp.sql.database-name =${database_name}
spring.datasource.continue-on-error =true
# Enforces database initialization
spring.datasource.initialization-mode =always
spring.cloud.gcp.sql.enabled =true
spring.cloud.gcp.sql.instance-connection-name =${database_instance_connection_name}
spring.cloud.gcp.sql.database-name =${database_name}
spring.datasource.username =${database_user}
spring.datasource.password =${database_password}
spring.datasource.continue-on-error =true
spring.datasource.initialization-mode =always
1 change: 1 addition & 0 deletions src/main/resources/application-prd.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
liquibase.contexts =baseline,prd
2 changes: 2 additions & 0 deletions src/main/resources/application-sdk.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
firebase.project.id =${FIREBASE_PROJECT_ID}
firebase.credentials.path=credentials.json
1 change: 1 addition & 0 deletions src/main/resources/application-sta.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
liquibase.contexts =baseline,sta
10 changes: 7 additions & 3 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ spring.jpa.properties.hibernate.dialect=org.hibernate.spatial.dialect.postgis.Po
# Disable Firestore module in Spring Cloud since we use the dedicated admin sdk
spring.cloud.gcp.firestore.enabled =false
# Required for Firebase authentication
firebase.database.url =https://colivery-app.firebaseio.com
firebase.project.id =colivery-app
firebase.database.url =
firebase.project.id =
firebase.credentials.path =
spring.profiles.active =${profiles_active}
# Esri api configuration
esri.find-addresses-url =https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/findAddressCandidates
google.geocode-url =https://maps.googleapis.com/maps/api/geocode/json
google.api-key =${google_maps_api_key}
# CORS Configuration - override this in your application-dev.properties for local development :-)
colivery.security.allowedOrigins =https://colivery-app.web.app,https://machbarschaft-dashboard-test.web.app
colivery.security.allowedOrigins =https://colivery-app.web.app,https://machbarschaft-dashboard-test.web.app,https://ds-sta.machbarschaft.jetzt,https://ds.machbarschaft.jetzt
# moved server port from Dockerfile
server.port =8080

liquibase.contexts =baseline
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet id="create_base_structure" author="nschoellhorn">
<changeSet id="create_base_structure" author="nschoellhorn" context="baseline">
<sql dbms="postgresql">
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "postgis";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet author="fbrueck" id="add_firebase_uid">
<changeSet author="fbrueck" id="add_firebase_uid" context="baseline">
<addColumn tableName="user">
<column name="firebase_uid" type="varchar(128)">
<constraints nullable="false" unique="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet author="gmaia" id="add_user_role">
<changeSet author="gmaia" id="add_user_role" context="baseline">
<addColumn tableName="user">
<column name="role" type="varchar(20)" defaultValue="USER">
<constraints nullable="false"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet author="fbrueck" id="introduce_source_type">
<changeSet author="fbrueck" id="introduce_source_type" context="baseline">
<addColumn tableName="user">
<column name="source" type="varchar(16)" defaultValue="APP">
<constraints nullable="false"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet author="fbrueck" id="drop_constraint_street_not_null">
<changeSet author="fbrueck" id="drop_constraint_street_not_null" context="baseline">
<dropNotNullConstraint columnName="street"
tableName="user"/>
</changeSet>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet author="fbrueck" id="drop_constraints">
<changeSet author="fbrueck" id="drop_constraints" context="baseline">
<dropNotNullConstraint columnName="first_name"
tableName="user"/>
<dropNotNullConstraint columnName="last_name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet id="create_help_seeker_table" author="nschoellhorn">
<changeSet id="create_help_seeker_table" author="nschoellhorn" context="baseline">
<sql dbms="postgresql">
CREATE TYPE source_platform AS ENUM ('HOTLINE', 'ADMIN');
</sql>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
<changeSet author="nschoellhorn" id="create_help_request_table">
<changeSet author="nschoellhorn" id="create_help_request_table" context="baseline">
<sql dbms="postgresql">
CREATE TYPE request_status AS ENUM ('OPEN', 'WIP', 'CLOSED');
</sql>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
<changeSet author="nschoellhorn" id="create_help_request_table">
<changeSet author="nschoellhorn" id="create_help_request_table" context="baseline">
<dropNotNullConstraint tableName="help_seeker" columnName="geo_hash"/>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
<changeSet author="ahodes" id="add_help_seeker_column">
<changeSet author="ahodes" id="add_help_seeker_column" context="baseline">
<addColumn tableName="help_request">
<column name="help_seeker_id" type="UUID">
<constraints nullable="false" foreignKeyName="fk_159279190" referencedTableName="help_seeker" referencedColumnNames="id" />
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">

<changeSet author="wirths" id="drop_constraints_location">
<changeSet author="wirths" id="drop_constraints_location" context="baseline">
<dropNotNullConstraint columnName="zip_code"
tableName="user"/>
<dropNotNullConstraint columnName="city"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
<changeSet author="wirths" id="add_admin_user" context="sta">
<sql>
INSERT INTO public.user
(first_name, last_name, email, phone, created_at, updated_at, role, firebase_uid)
VALUES ('Super Sta', 'Admin', '[email protected]', '911', '2020-12-12', '2020-12-12', 'ADMIN', 'tvtVTwsvpFMySt6PLMm7eqC5P413');
</sql>
</changeSet>
</databaseChangeLog>
Loading

0 comments on commit 7bdba53

Please sign in to comment.