Skip to content

Commit e51dd69

Browse files
authored
feat: local developer setup (#62)
1 parent c0d6949 commit e51dd69

16 files changed

+1959
-124
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@ The individual modules like "Reporting" require some setup and environment varia
1616

1717
- **[Reporting](./docs/modules/reporting.md)**: Calculate aggregated reports and run queries on all data, accessible for external services for API integrations of systems
1818
- **[Export](./docs/modules/export.md)**: Template based file export API. Uses [carbone.io](https://carbone.io) as templating engine.
19+
20+
## Development
21+
The developer README provides detailed instructions how to set up a local testing environment: [docs/developer/README.md](docs/developer/README.md)

application/aam-backend-service/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ out/
3838

3939
### Kotlin ###
4040
.kotlin
41+
/src/main/resources/reverse-proxy.crt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.aamdigital.aambackendservice.security
2+
3+
import org.springframework.boot.ssl.SslBundles
4+
import org.springframework.boot.web.client.RestTemplateBuilder
5+
import org.springframework.context.annotation.Bean
6+
import org.springframework.context.annotation.Configuration
7+
import org.springframework.context.annotation.Profile
8+
import org.springframework.security.oauth2.jwt.JwtDecoder
9+
import org.springframework.security.oauth2.jwt.NimbusJwtDecoder
10+
import org.springframework.web.client.RestTemplate
11+
12+
@Configuration
13+
class LocalDevelopmentConfiguration {
14+
@Bean
15+
@Profile("local-development")
16+
fun restTemplate(restTemplateBuilder: RestTemplateBuilder, sslBundles: SslBundles): RestTemplate {
17+
return restTemplateBuilder.setSslBundle(sslBundles.getBundle("local-development")).build()
18+
}
19+
20+
@Bean
21+
@Profile("local-development")
22+
fun sslCheckDisabledJwtDecoder(
23+
restTemplate: RestTemplate
24+
): JwtDecoder {
25+
return NimbusJwtDecoder
26+
.withIssuerLocation(
27+
"https://aam.localhost/auth/realms/dummy-realm"
28+
)
29+
.restOperations(restTemplate)
30+
.build()
31+
}
32+
}

application/aam-backend-service/src/main/resources/application.yaml

+17-9
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,13 @@ spring:
7575
oauth2:
7676
resourceserver:
7777
jwt:
78-
issuer-uri: http://localhost:8080/realms/dummy-realm
78+
issuer-uri: https://aam.localhost/auth/realms/dummy-realm
79+
ssl:
80+
bundle:
81+
pem:
82+
local-development:
83+
truststore:
84+
certificate: "classpath:reverse-proxy.crt" # this is the certificate of the local running caddy proxy
7985
rabbitmq:
8086
virtual-host: local
8187
listener:
@@ -93,6 +99,8 @@ spring:
9399
password: docker
94100

95101
server:
102+
servlet:
103+
context-path: /
96104
error:
97105
include-message: always
98106
include-binding-errors: always
@@ -116,26 +124,26 @@ aam-render-api-client-configuration:
116124
# scope: <needs-environment-configuration>
117125

118126
couch-db-client-configuration:
119-
base-path: http://localhost:5984
127+
base-path: https://aam.localhost/db/couchdb
120128
basic-auth-username: admin
121129
basic-auth-password: docker
122130

123131
sqs-client-configuration:
124-
base-path: http://localhost:4984
132+
base-path: https://aam.localhost/sqs
125133
basic-auth-username: admin
126134
basic-auth-password: docker
127135

128136
skilllab-api-client-configuration:
129137
api-key: skilllab-api-key
130138
project-id: dummy-project
131-
base-path: http://localhost:9005/skilllab
139+
base-path: https://aam.localhost/skilllab
132140
response-timeout-in-seconds: 15
133141

134142
features:
135143
export-api:
136144
enabled: false
137145
skill-api:
138-
mode: skilllab
146+
mode: disabled
139147

140148
crypto-configuration:
141149
secret: super-duper-secret
@@ -156,7 +164,7 @@ sentry:
156164
application:
157165
version: local-dev-build
158166

159-
management:
160-
otlp:
161-
tracing:
162-
endpoint: http://localhost:4318/v1/traces
167+
#management:
168+
# otlp:
169+
# tracing:
170+
# endpoint: http://localhost:4318/v1/traces
Loading

docs/assets/keychain-access-1.png

89.3 KB
Loading

docs/assets/keychain-access-2.png

73.4 KB
Loading

docs/developer/.env.example

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
APP_VERSION=latest
2+
AAM_BACKEND_SERVICE_VERSION=latest
3+
REPLICATION_BACKEND_PUBLIC_KEY=<the-content-of-"public_key"-from-here-https://localhost/auth/realms/dummy-realm>
4+
# (macos only)
5+
JAVA_TOOL_OPTIONS="-XX:UseSVE=0"

docs/developer/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
container-data/
2+
.env
3+
secrets.env

docs/developer/Caddyfile

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
local_certs
3+
auto_https disable_redirects
4+
}
5+
6+
aam.localhost:80, aam.localhost:443 {
7+
handle_path /auth* {
8+
reverse_proxy keycloak:8080 {
9+
header_up Host {host}
10+
}
11+
}
12+
13+
handle_path /db/couchdb* {
14+
reverse_proxy db-couch:5984
15+
}
16+
17+
handle_path /db* {
18+
reverse_proxy replication-backend:5984
19+
}
20+
21+
handle_path /accounts-backend* {
22+
# activate this line instead of the existing if your account-backend is running locally
23+
# reverse_proxy http://host.docker.internal:3000
24+
25+
# activate this line when account-backend is running as docker container (default)
26+
reverse_proxy accounts-backend:3000
27+
}
28+
29+
handle_path /replication-backend* {
30+
reverse_proxy replication-backend:5984
31+
}
32+
33+
handle_path /api* {
34+
# reverse_proxy http://host.docker.internal:9000 # local running app
35+
reverse_proxy aam-backend-service:8080 # docker container
36+
}
37+
38+
handle_path /sqs* {
39+
reverse_proxy sqs:4984
40+
}
41+
42+
handle_path /rabbitmq/* {
43+
reverse_proxy rabbitmq:15672
44+
}
45+
46+
handle_path /nominatim/* {
47+
reverse_proxy https://nominatim.openstreetmap.org
48+
}
49+
50+
handle_path /maildev/* {
51+
reverse_proxy maildev:1080
52+
}
53+
54+
handle_path /hello {
55+
respond "Hello. This is aam-digital-reverse-proxy." 200
56+
}
57+
58+
# redirect all other traffic to the locally running angular app (on host machine)
59+
# on linux this may need some additional configuration. See README.md
60+
handle_path /* {
61+
reverse_proxy http://host.docker.internal:4200
62+
}
63+
}

0 commit comments

Comments
 (0)