Skip to content

Commit 32273dd

Browse files
committed
hopefully fixed bitnami issue in Dcoker Compose as well
1 parent 7c54247 commit 32273dd

File tree

5 files changed

+38
-9
lines changed

5 files changed

+38
-9
lines changed

dockerfiles/reservations-api.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ services:
3333
# default env does not work on volumes
3434
# - ${JACOCODIR}:/jacoco
3535
db:
36-
image: bitnami/mongodb:4.4
36+
image: mongo:4.4
3737
tmpfs:
38-
- '/bitnami/mongodb'
39-
environment:
40-
MONGODB_REPLICA_SET_MODE: primary
41-
ALLOW_EMPTY_PASSWORD: yes
38+
- '/data/db'
4239
volumes:
40+
- ../scripts/dockerize/data/additional_files/reservations-api/mongo-init.js:/docker-entrypoint-initdb.d/01-init-replica.js
4341
- ../scripts/dockerize/data/additional_files/reservations-api/mongo_import.sh:/docker-entrypoint-initdb.d/mongo_import.sh
44-
- ../scripts/dockerize/data/additional_files/reservations-api/init.json:/fixtures/init.json
42+
- ../scripts/dockerize/data/additional_files/reservations-api/init.json:/fixtures/init.json
43+
command: mongod --replSet rs0 --bind_ip_all

scripts/createDockerFiles.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22

33
import os
44
import pandas as pd
5+
import shutil
56

67
SCRIPT_LOCATION = os.path.dirname(os.path.realpath(__file__))
78
SUTS_LOCATION = os.path.join(SCRIPT_LOCATION, 'dockerize/data/sut.csv')
89
GENERATOR_LOCATION = os.path.join(SCRIPT_LOCATION, 'dockerize/docker_generator.py')
910

11+
PYTHON_CMD = shutil.which('python3') or shutil.which('python')
12+
if not PYTHON_CMD:
13+
raise EnvironmentError("Could not find Python interpreter")
14+
1015
suts = pd.read_csv(SUTS_LOCATION)
1116
dockerized_suts = suts[suts['Dockerized'] == True]
1217
EXPOSE_PORT = 8080
1318

1419
for _, sut in dockerized_suts.iterrows():
15-
os.system(f"python {GENERATOR_LOCATION} {sut['NAME']} {EXPOSE_PORT}")
20+
os.system(f"{PYTHON_CMD} {GENERATOR_LOCATION} {sut['NAME']} {EXPOSE_PORT}")
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
rs.initiate({
2+
_id: "rs0",
3+
members: [
4+
{ _id: 0, host: "localhost:27017" }
5+
]
6+
})
Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
11
#!/bin/bash
2-
mongoimport --host db --port 27017 --db reservations-api --collection users --file /fixtures/init.json --jsonArray
2+
3+
4+
MAX_ATTEMPTS=30
5+
attempt=1
6+
7+
echo "Waiting for Mongo PRIMARY..."
8+
9+
while ! mongo --host localhost --eval "rs.isMaster().ismaster" | grep -q true; do
10+
if [ $attempt -ge $MAX_ATTEMPTS ]; then
11+
echo "Mongo PRIMARY did not become ready after $MAX_ATTEMPTS attempts, exiting."
12+
exit 1
13+
fi
14+
attempt=$((attempt+1))
15+
sleep 1
16+
done
17+
18+
echo "Mongo PRIMARY is ready, running import..."
19+
20+
#mongoimport --host db --port 27017 --db reservations-api --collection users --file /fixtures/init.json --jsonArray
21+
mongoimport --host localhost --port 27017 --db reservations-api --collection users --file /fixtures/init.json --jsonArray

scripts/dockerize/data/sut.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ familie-ba-sak,TRUE,-DAZUREAD_TOKEN_ENDPOINT_URL=http://fake-azure-token-endpoin
33
pay-publicapi,TRUE,-Ddw.server.applicationConnectors[0].port=8080 -Ddw.server.adminConnectors[0].port=0 -Ddw.redis.endpoint=db:6379,server em_config.yaml,http://localhost:8080/assets/swagger.json,http://localhost:8080,TRUE,FALSE,"","[{""image_name"": ""redis:7.2.3"", ""tmp_fs"": """", ""environment"": """", ""volume"": """", ""health_check_command"": """"}]"
44
session-service,TRUE,"",--server.port=8080 --spring.data.mongodb.uri=mongodb://db:27017/mongo_db --spring.cache.type=NONE,http://localhost:8080/v2/api-docs,http://localhost:8080,FALSE,FALSE,"","[{""image_name"": ""mongo:6.0"", ""tmp_fs"": ""/data/db"", ""environment"": """", ""volume"": """", ""health_check_command"": """"}]"
55
bibliothek,TRUE,"",--server.port=8080 --databaseUrl=mongodb://db:27017/mongo_db --spring.data.mongodb.uri=mongodb://db:27017/mongo_db --app.storagePath=./tmp/bibliothek/,http://localhost:8080/openapi,http://localhost:8080,FALSE,FALSE,"","[{""image_name"": ""mongo:6"", ""tmp_fs"": ""/data/db"", ""environment"": """", ""volume"": """", ""health_check_command"": """"}]"
6-
reservations-api,TRUE,-Dfile.encoding=ISO-8859-1,--server.port=8080 --databaseUrl=mongodb://db:27017/mongo_db --spring.data.mongodb.uri=mongodb://db:27017/mongo_db --app.jwt.secret=abcdef012345678901234567890123456789abcdef012345678901234567890123456789,http://localhost:8080/v3/api-docs,http://localhost:8080,FALSE,FALSE,"","[{""image_name"": ""bitnami/mongodb:4.4"", ""tmp_fs"": ""/bitnami/mongodb"", ""environment"": ""MONGODB_REPLICA_SET_MODE: primary;ALLOW_EMPTY_PASSWORD: yes"", ""volume"": ""../scripts/dockerize/data/additional_files/reservations-api/mongo_import.sh:/docker-entrypoint-initdb.d/mongo_import.sh;../scripts/dockerize/data/additional_files/reservations-api/init.json:/fixtures/init.json"", ""health_check_command"": """"}]"
6+
reservations-api,TRUE,-Dfile.encoding=ISO-8859-1,--server.port=8080 --databaseUrl=mongodb://db:27017/mongo_db --spring.data.mongodb.uri=mongodb://db:27017/mongo_db --app.jwt.secret=abcdef012345678901234567890123456789abcdef012345678901234567890123456789,http://localhost:8080/v3/api-docs,http://localhost:8080,FALSE,FALSE,"","[{""image_name"": ""mongo:4.4"", ""tmp_fs"": ""/data/db"", ""environment"": """", ""command"": ""mongod --replSet rs0 --bind_ip_all"", ""volume"": ""../scripts/dockerize/data/additional_files/reservations-api/mongo-init.js:/docker-entrypoint-initdb.d/01-init-replica.js;../scripts/dockerize/data/additional_files/reservations-api/mongo_import.sh:/docker-entrypoint-initdb.d/mongo_import.sh;../scripts/dockerize/data/additional_files/reservations-api/init.json:/fixtures/init.json"", ""health_check_command"": """"}]"
77
catwatch,TRUE,-Dserver.port=8080 -Dspring.datasource.url=jdbc:h2:mem:testdb -Dspring.jpa.database-platform=org.hibernate.dialect.H2Dialect -Dspring.datasource.username=sa -Dspring.datasource.password,"",http://localhost:8080/v2/api-docs,http://localhost:8080,FALSE,FALSE,"",
88
cwa-verification,TRUE,-Dspring.datasource.url=jdbc:h2:mem:testdb -Dspring.datasource.driver-class-name=org.h2.Driver -Dspring.datasource.username=sa -Dspring.datasource.password,"--server.port=8080 --spring.profiles.active=local,external,internal --management.server.port=-1 --server.ssl.enabled=false --cwa-testresult-server.url=http://cwa-testresult-server:8088",http://localhost:8080/api-docs.json,http://localhost:8080,FALSE,FALSE,"",
99
features-service,TRUE,-Dspring.datasource.url=jdbc:h2:mem:testdb -Dspring.jpa.database-platform=org.hibernate.dialect.H2Dialect -Dspring.datasource.username=sa -Dspring.datasource.password,--server.port=8080,http://localhost:8080/swagger.json,http://localhost:8080,FALSE,FALSE,"",

0 commit comments

Comments
 (0)