Skip to content

Commit 74b5be2

Browse files
committed
dockerize
1 parent a753acb commit 74b5be2

9 files changed

Lines changed: 303 additions & 4 deletions

File tree

auth/microcks-auth.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
auth:
2+
- name: "ADMIN_1"
3+
loginEndpointAuth:
4+
payloadRaw: "username=admin&password=microcks123&grant_type=password&client_id=microcks-serviceaccount&client_secret=ab54d329-e435-41ae-a900-ec6b3fe15c54"
5+
- name: "ADMIN_2"
6+
loginEndpointAuth:
7+
payloadRaw: "username=admin2&password=microcks123&grant_type=password&client_id=microcks-serviceaccount&client_secret=ab54d329-e435-41ae-a900-ec6b3fe15c54"
8+
9+
authTemplate:
10+
loginEndpointAuth:
11+
verb: POST
12+
externalEndpointURL: "http://localhost:8081/realms/microcks/protocol/openid-connect/token"
13+
contentType: application/x-www-form-urlencoded
14+
token:
15+
extractFromField: /access_token
16+
httpHeaderName: Authorization
17+
headerPrefix: "Bearer "

dockerfiles/microcks.dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM amazoncorretto:21-alpine-jdk
2+
3+
COPY ./dist/microcks-sut.jar .
4+
COPY ./dist/jacocoagent.jar .
5+
6+
7+
8+
#ENV TOOL="undefined"
9+
#ENV RUN="0"
10+
11+
ENTRYPOINT \
12+
java \
13+
# unfortunately dumponexit is completely unreliable in Docker :(
14+
# -javaagent:jacocoagent.jar=destfile=./jacoco/microcks__${TOOL}__${RUN}__jacoco.exec,append=false,dumponexit=true \
15+
-javaagent:jacocoagent.jar=output=tcpserver,address=*,port=6300,append=false,dumponexit=false \
16+
-DPOSTMAN_RUNNER_URL=http://postman:3000 -DSERVICES_UPDATE_INTERVAL='0 0 0/2 * * *' -DKEYCLOAK_URL=http://keycloak:8080 -DKEYCLOAK_PUBLIC_URL=http://localhost:${HOST_PORT:-8081} -DENABLE_CORS_POLICY=false -DCORS_REST_ALLOW_CREDENTIALS=true -DTEST_CALLBACK_URL=http://localhost:${HOST_PORT:-8080} -jar microcks-sut.jar \
17+
--server.port=8080 --spring.profiles.active=prod --grpc.server.port=0 --spring.data.mongodb.uri=mongodb://mongodb:27017/test --spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:${HOST_PORT:-8081}/realms/microcks --spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://keycloak:${HOST_PORT:-8080}/realms/microcks/protocol/openid-connect/certs

dockerfiles/microcks.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
services:
2+
sut-microcks:
3+
build:
4+
dockerfile: ./dockerfiles/microcks.dockerfile
5+
context: ..
6+
# environment:
7+
# TOOL: ${TOOL:-undefined}
8+
# RUN: ${RUN:-0}
9+
ports:
10+
- "${HOST_PORT:-8080}:8080"
11+
- "${JACOCO_PORT:-6300}:6300"
12+
# volumes:
13+
# default env does not work on volumes
14+
# - ${JACOCODIR}:/jacoco
15+
16+
mongodb:
17+
image: mongo:7.0
18+
tmpfs:
19+
- '/data/db'
20+
21+
22+
environment:
23+
MONGODB_REPLICA_SET_MODE: primary
24+
ALLOW_EMPTY_PASSWORD: yes
25+
26+
27+
28+
29+
30+
31+
32+
33+
keycloak:
34+
image: quay.io/keycloak/keycloak:26.0.0
35+
36+
37+
environment:
38+
KEYCLOAK_ADMIN: 'admin'
39+
KEYCLOAK_ADMIN_PASSWORD: 'admin'
40+
KC_HEALTH_ENABLED: 'true'
41+
KC_METRICS_ENABLED: 'true'
42+
43+
44+
45+
volumes:
46+
- ../scripts/dockerize/data/additional_files/microcks/microcks-realm-sample.json:/opt/keycloak/data/import/microcks-realm.json
47+
48+
49+
50+
healthcheck:
51+
test: ['CMD', 'sh', '-c', "echo -e 'GET /health/live HTTP/1.1\r\nHost: localhost\r\n\r\n' > /dev/tcp/localhost/9000"]
52+
interval: 30s
53+
timeout: 30s
54+
retries: 3
55+
56+
57+
ports:
58+
- '${HOST_PORT:-8081}:8080'
59+
60+
61+
62+
command: ['start-dev', '--hostname=http://localhost:${HOST_PORT:-8081}', '--import-realm', '--health-enabled=true']
63+
64+
65+
postman:
66+
image: quay.io/microcks/microcks-postman-runtime:0.6.0
67+
68+
69+
70+
71+
healthcheck:
72+
test: ['CMD', 'curl', '-f', 'http://localhost:3000/health']
73+
interval: 30s
74+
timeout: 30s
75+
retries: 3
76+
77+
78+
79+
80+

jdk_21_maven/em/embedded/rest-gui/microcks/src/main/java/em/embedded/microcks/EmbeddedEvoMasterController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public List<DbSpecification> getDbSpecifications() {
175175
@Override
176176
public List<AuthenticationDto> getInfoForAuthentication() {
177177
//http://localhost:{port}/realms/microcks/protocol/openid-connect/token
178-
String postEndpoint = "http://localhost:" + keycloakContainer.getMappedPort(KEYCLOAK_PORT) + "/realms/microcks/protocol/openid-connect/token";
178+
String postEndpoint = "http://" + keycloakContainer.getContainerIpAddress() + ":" + keycloakContainer.getMappedPort(KEYCLOAK_PORT) + "/realms/microcks/protocol/openid-connect/token";
179179

180180
String payloadTemplate = "username=%s&password=microcks123&grant_type=password&client_id=microcks-serviceaccount&client_secret=ab54d329-e435-41ae-a900-ec6b3fe15c54";
181181

jdk_21_maven/em/external/rest-gui/microcks/src/main/java/em/external/microcks/ExternalEvoMasterController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public SutInfoDto.OutputFormat getPreferredOutputFormat() {
266266
@Override
267267
public List<AuthenticationDto> getInfoForAuthentication() {
268268
//http://localhost:{port}/realms/microcks/protocol/openid-connect/token
269-
String postEndpoint = "http://localhost:" + keycloakContainer.getMappedPort(KEYCLOAK_PORT) + "/realms/microcks/protocol/openid-connect/token";
269+
String postEndpoint = "http://" + keycloakContainer.getContainerIpAddress() + ":" + keycloakContainer.getMappedPort(KEYCLOAK_PORT) + "/realms/microcks/protocol/openid-connect/token";
270270

271271
String payloadTemplate = "username=%s&password=microcks123&grant_type=password&client_id=microcks-serviceaccount&client_secret=ab54d329-e435-41ae-a900-ec6b3fe15c54";
272272

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
{
2+
"id": "microcks",
3+
"realm": "microcks",
4+
"displayName": "Microcks",
5+
"enabled": true,
6+
"sslRequired": "none",
7+
"registrationAllowed": false,
8+
"users" : [
9+
{
10+
"username" : "admin",
11+
"enabled": true,
12+
"credentials" : [
13+
{ "type" : "password",
14+
"value" : "microcks123" }
15+
],
16+
"realmRoles": [],
17+
"applicationRoles": {
18+
"realm-management": [ "manage-users", "manage-clients" ],
19+
"account": [ "manage-account" ],
20+
"microcks-app": [ "user", "manager", "admin"]
21+
}
22+
},
23+
{
24+
"username" : "admin2",
25+
"enabled": true,
26+
"credentials" : [
27+
{ "type" : "password",
28+
"value" : "microcks123" }
29+
],
30+
"realmRoles": [],
31+
"applicationRoles": {
32+
"realm-management": [ "manage-users", "manage-clients" ],
33+
"account": [ "manage-account" ],
34+
"microcks-app": [ "user", "manager", "admin"]
35+
}
36+
},
37+
{
38+
"username": "service-account-microcks-serviceaccount",
39+
"enabled": true,
40+
"serviceAccountClientId": "microcks-serviceaccount",
41+
"clientRoles": {
42+
"microcks-app": ["manager"]
43+
}
44+
}
45+
],
46+
"roles": {
47+
"realm": [],
48+
"client": {
49+
"microcks-app": [
50+
{
51+
"name": "user",
52+
"composite": false,
53+
"clientRole": true,
54+
"containerId": "microcks"
55+
},
56+
{
57+
"name": "admin",
58+
"composite": false,
59+
"clientRole": true,
60+
"containerId": "microcks"
61+
},
62+
{
63+
"name": "manager",
64+
"composite": false,
65+
"clientRole": true,
66+
"containerId": "microcks"
67+
}
68+
]
69+
}
70+
},
71+
"groups": [
72+
{
73+
"name": "microcks",
74+
"path": "/microcks",
75+
"attributes": {},
76+
"realmRoles": [],
77+
"clientRoles": {},
78+
"subGroups": [
79+
{
80+
"name": "manager",
81+
"path": "/microcks/manager",
82+
"attributes": {},
83+
"realmRoles": [],
84+
"clientRoles": {},
85+
"subGroups": []
86+
}
87+
]
88+
}
89+
],
90+
"defaultRoles": [],
91+
"requiredCredentials": [ "password" ],
92+
"scopeMappings": [],
93+
"clientScopeMappings": {
94+
"microcks-app": [
95+
{
96+
"client": "microcks-app-js",
97+
"roles": [
98+
"manager",
99+
"admin",
100+
"user"
101+
]
102+
}
103+
],
104+
"realm-management": [
105+
{
106+
"client": "microcks-app-js",
107+
"roles": [
108+
"manage-users",
109+
"manage-clients"
110+
]
111+
}
112+
]
113+
},
114+
"clients": [
115+
{
116+
"clientId": "microcks-app-js",
117+
"enabled": true,
118+
"publicClient": true,
119+
"redirectUris": [
120+
"*"
121+
],
122+
"webOrigins": [
123+
"*"
124+
],
125+
"fullScopeAllowed": false,
126+
"protocolMappers": [
127+
{
128+
"name": "microcks-group-mapper",
129+
"protocol": "openid-connect",
130+
"protocolMapper": "oidc-group-membership-mapper",
131+
"consentRequired": false,
132+
"config": {
133+
"full.path": "true",
134+
"id.token.claim": "true",
135+
"access.token.claim": "true",
136+
"claim.name": "microcks-groups",
137+
"userinfo.token.claim": "true"
138+
}
139+
}
140+
]
141+
}
142+
],
143+
"applications": [
144+
{
145+
"name": "microcks-app",
146+
"enabled": true,
147+
"bearerOnly": true,
148+
"defaultRoles": [
149+
"user"
150+
]
151+
},
152+
{
153+
"name": "microcks-serviceaccount",
154+
"secret": "ab54d329-e435-41ae-a900-ec6b3fe15c54",
155+
"enabled": true,
156+
"bearerOnly": false,
157+
"publicClient": false,
158+
"standardFlowEnabled": false,
159+
"directAccessGrantsEnabled": true,
160+
"serviceAccountsEnabled": true,
161+
"clientAuthenticatorType": "client-secret"
162+
}
163+
],
164+
"requiredActions": [
165+
{
166+
"alias": "VERIFY_PROFILE",
167+
"name": "Verify Profile",
168+
"providerId": "VERIFY_PROFILE",
169+
"enabled": false,
170+
"defaultAction": false,
171+
"priority": 90,
172+
"config": {}
173+
}
174+
],
175+
"keycloakVersion": "10.0.1"
176+
}

scripts/dockerize/data/sut.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ swagger-petstore,TRUE,"",8080,http://localhost:8080/api/v3/openapi.json,http://l
3434
http-patch-spring,TRUE,"",--server.port=8080,http://localhost:8080/v3/api-docs,http://localhost:8080,FALSE,FALSE,"",
3535
spring-ecommerce,TRUE,-Dfile.encoding=ISO-8859-1,--server.port=8080 --spring.datasource.host=mongodb --spring.datasource.port=27017 --spring.datasource.database=test --spring.data.mongodb.uri=mongodb://mongodb:27017/test --spring.redis.host=redis --spring.redis.port=6379 --spring.data.elasticsearch.cluster-name=elasticsearch --spring.data.elasticsearch.cluster-nodes=elasticsearch:9300 --spring.elasticsearch.rest.uris=elasticsearch:9200 --spring.data.elasticsearch.host=elasticsearch --spring.data.elasticsearch.port=9300 --spring.cache.type=NONE,http://localhost:8080/v2/api-docs,http://localhost:8080,FALSE,FALSE,"","[{""name"": ""mongodb"", ""image_name"": ""mongo:7.0"", ""port"": 27017.0, ""tmp_fs"": ""/data/db"", ""environment"": ""MONGODB_REPLICA_SET_MODE: primary;ALLOW_EMPTY_PASSWORD: yes"", ""volume"": ""../scripts/dockerize/data/additional_files/spring-ecommerce/mongo_import.sh:/docker-entrypoint-initdb.d/mongo_import.sh;../scripts/dockerize/data/additional_files/spring-ecommerce/init.json:/fixtures/init.json"", ""health_check_command"": """"}, {""name"": ""redis"", ""image_name"": ""redis:7.0.11"", ""port"": 6379, ""tmp_fs"": """", ""environment"": """", ""volume"": """", ""health_check_command"": """"}, {""name"": ""elasticsearch"",""image_name"": ""docker.elastic.co/elasticsearch/elasticsearch:6.8.23"", ""port"": 9300, ""tmp_fs"": ""/usr/share/elasticsearch/data"", ""environment"": ""- discovery.type=single-node;- cluster.name=elasticsearch;- ES_JAVA_OPTS=-Xms512m -Xmx512m;- xpack.security.enabled=false"", ""volume"": """", ""health_check_command"": """"}]"
3636
quartz-manager,TRUE,,--server.port=8080 --quartz-manager.security.accounts.in-memory.users[0].username=foo --quartz-manager.security.accounts.in-memory.users[0].password=bar --quartz-manager.security.accounts.in-memory.users[0].roles[0]=admin --quartz-manager.security.accounts.in-memory.users[1].username=foo2 --quartz-manager.security.accounts.in-memory.users[1].password=bar --quartz-manager.security.accounts.in-memory.users[1].roles[0]=admin,http://localhost:8080/v3/api-docs,http://localhost:8080,FALSE,FALSE,"",
37+
microcks,TRUE,-DPOSTMAN_RUNNER_URL=http://postman:3000 -DSERVICES_UPDATE_INTERVAL='0 0 0/2 * * *' -DKEYCLOAK_URL=http://keycloak:8080 -DKEYCLOAK_PUBLIC_URL=http://localhost:${HOST_PORT:-8081} -DENABLE_CORS_POLICY=false -DCORS_REST_ALLOW_CREDENTIALS=true -DTEST_CALLBACK_URL=http://localhost:${HOST_PORT:-8080},--server.port=8080 --spring.profiles.active=prod --grpc.server.port=0 --spring.data.mongodb.uri=mongodb://mongodb:27017/test --spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:${HOST_PORT:-8081}/realms/microcks --spring.security.oauth2.resourceserver.jwt.jwk-set-uri=http://keycloak:${HOST_PORT:-8080}/realms/microcks/protocol/openid-connect/certs,http://localhost:8080/v3/api-docs,http://localhost:8080,FALSE,FALSE,"","[{""name"": ""mongodb"", ""image_name"": ""mongo:7.0"", ""tmp_fs"": ""/data/db"", ""environment"": ""MONGODB_REPLICA_SET_MODE: primary;ALLOW_EMPTY_PASSWORD: yes"", ""volume"": """", ""health_check_command"": """"},{""name"": ""keycloak"",""image_name"": ""quay.io/keycloak/keycloak:26.0.0"", ""command"":[""start-dev"", ""--hostname=http://localhost:${HOST_PORT:-8081}"", ""--import-realm"", ""--health-enabled=true""], ""port"": ""${HOST_PORT:-8081}:8080"", ""tmp_fs"": """", ""environment"": ""KEYCLOAK_ADMIN: 'admin';KEYCLOAK_ADMIN_PASSWORD: 'admin';KC_HEALTH_ENABLED: 'true';KC_METRICS_ENABLED: 'true'"", ""volume"": ""../scripts/dockerize/data/additional_files/microcks/microcks-realm-sample.json:/opt/keycloak/data/import/microcks-realm.json"", ""health_check_command"": [""CMD"", ""sh"", ""-c"", ""echo -e 'GET /health/live HTTP/1.1\r\nHost: localhost\r\n\r\n' > /dev/tcp/localhost/9000""]},{""name"": ""postman"", ""image_name"": ""quay.io/microcks/microcks-postman-runtime:0.6.0"", ""tmp_fs"": """", ""environment"": """", ""volume"": """", ""health_check_command"": [""CMD"", ""curl"", ""-f"", ""http://localhost:3000/health""]}]"

scripts/dockerize/docker_generator.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,13 @@ def generate_docker_compose(self):
136136
database_params = {
137137
'name': db['name'] if 'name' in db else 'db',
138138
'DATABASE_IMAGE_NAME': db['image_name'],
139-
'DATABASE_PORT': db['port'],
139+
'DATABASE_PORT': db['port'] if 'port' in db else None,
140140
'TMP_FS': db['tmp_fs'],
141141
'DATABASE_ENVIRONMENT': str(db['environment']).split(';') if str(db['environment']) != '' else None,
142142
'DATABASE_VOLUME': str(db['volume']).split(';') if str(db['volume']) != '' else None,
143143
'HEALTH_CHECK': health_check_command != "",
144-
'HEALTH_CHECK_COMMAND': health_check_command
144+
'HEALTH_CHECK_COMMAND': health_check_command,
145+
'COMMAND': db['command'] if 'command' in db else None,
145146
}
146147
database_image = database_template.render(database_params)
147148
db_images.append(database_image)

scripts/dockerize/templates/db.template

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,11 @@
2323
timeout: 30s
2424
retries: 3
2525
{% endif %}
26+
{% if DATABASE_PORT %}
27+
ports:
28+
- '{{DATABASE_PORT}}'
29+
{% endif %}
2630

31+
{% if COMMAND %}
32+
command: {{COMMAND}}
33+
{% endif %}

0 commit comments

Comments
 (0)