Compare commits

...

4 Commits

Author SHA1 Message Date
Norman Schmidt d29c1183d8 (WIP) 2022-09-25 15:48:28 +02:00
nsm 7c1784584e fix: fix keycloak connection 2022-08-26 17:32:06 +02:00
nsm a2abde3e8b fix: fixed Angular and Spring Boot Crash on startup 2022-08-26 17:30:03 +02:00
nsm 51ebab123a fix: small fixes for docker compose 2022-08-26 17:30:03 +02:00
9 changed files with 78 additions and 33 deletions

16
c4po.sh
View File

@ -2,16 +2,10 @@
baseDir=$(pwd)
composeDir=$baseDir"/security-c4po-cfg"
compose=$baseDir"/security-c4po-cfg/docker-compose.yml"
keycloakVolume="security-c4po-cfg/volumes/keycloak/data/*"
mongoVolume="security-c4po-cfg/volumes/mongodb/data/*"
composeKeycloak=$baseDir"/security-c4po-cfg/kc/docker-compose.keycloak.yml"
composeDatabase=$baseDir"/security-c4po-cfg/mongodb/docker-compose.mongodb.yml"
composeFrontend=$baseDir"/security-c4po-cfg/frontend/docker-compose.frontend.yml"
composeBackend=$baseDir"/security-c4po-cfg/backend/docker-compose.backend.yml"
compose=$baseDir"/security-c4po-cfg/docker-compose.yml"
echo -e "
_______ _______ _______ _ _ ______ _____ _______ __ __
|______ |______ | | | |_____/ | | \_/
@ -34,14 +28,12 @@ echo -e "\n"
echo "-----------------Start Build------------------"
echo -e "\n"
echo " - Backend: "
docker-compose -f ${composeBackend} build
docker-compose -f ${compose} build c4po-api
echo -e "\n"
echo " - Frontend: "
docker-compose -f ${composeFrontend} build
#docker-compose -f ${compose} build c4po-angular
echo -e "\n"
# docker-compose -f ${compose} up
echo "------------Start Docker Container------------"
echo -e "\n"
docker-compose -f ${composeKeycloak} -f ${composeDatabase} -f ${composeBackend} -f ${composeFrontend} up
# docker-compose -f ${compose} up
docker-compose -f ${compose} up # --scale c4po-angular=0

View File

@ -16,4 +16,6 @@ RUN npm install -g @angular/cli@12.2.17
COPY . /app
# start app
CMD ng serve --host 0.0.0.0
CMD ng serve -c compose --host 0.0.0.0
# -------------------------------------------------------------

View File

@ -73,6 +73,34 @@
"maximumWarning": "6kb"
}
]
},
"compose": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.compose.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "3mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
]
}
},
"defaultConfiguration": ""
@ -85,6 +113,9 @@
"configurations": {
"production": {
"browserTarget": "security-c4po-angular:build:production"
},
"compose": {
"browserTarget": "security-c4po-angular:build:compose"
}
}
},

View File

@ -0,0 +1,11 @@
export const environment = {
production: false,
// keycloak
keycloakURL: 'http://localhost:8888/auth',
keycloakrealm: 'c4po_realm_local',
keycloakclientId: 'c4po_local',
// backend service
apiEndpoint: 'http://localhost:8443',
};

View File

@ -6,15 +6,12 @@ RUN mkdir /data
RUN chown security-c4po-api:security-c4po-api /data
USER security-c4po-api
# GET CURRENT STAGE
ARG STAGE
ENV ENV_STAGE=$STAGE
# COPY PACKAGE INTO IMAGE
COPY ./build/libs/security-c4po-api-0.0.1-SNAPSHOT.jar /
USER security-c4po-api
EXPOSE 8443
# RUN JAVA
# WAIT FOR KEYCLOAK & RUN JAVA
COPY ./wait-for-keycloak.sh /
# CMD [ "java", "-jar", "security-c4po-api-0.0.1-SNAPSHOT.jar" ]
ENTRYPOINT [ "java", "-jar", "-Dspring.profiles.active=${ENV_STAGE}", "security-c4po-api-0.0.1-SNAPSHOT.jar" ]
ENTRYPOINT [ "./wait-for-keycloak.sh", "http://c4po-keycloak:8080/auth/realms/c4po_realm_local", "java", "-Dspring.profiles.active=${SPRING_PROFILES_ACTIVE}", "-jar", "security-c4po-api-0.0.1-SNAPSHOT.jar" ]

View File

@ -1,7 +1,7 @@
## IdentityProvider (Keycloak) ##
spring.security.oauth2.resourceserver.jwt.issuer-uri=http://localhost:8888/auth/realms/c4po_realm_local
keycloakhost=localhost
keycloak.client.url=http://localhost:8888
spring.security.oauth2.resourceserver.jwt.issuer-uri=http://c4po-keycloak:8080/auth/realms/c4po_realm_local
keycloakhost=c4po-keycloak
keycloak.client.url=http://c4po-keycloak:8080
keycloak.client.realm.path=auth/realms/c4po_realm_local/
## Database (MONGODB) Config ##

View File

@ -0,0 +1,17 @@
#!/bin/sh
# wait-for-keycloak.sh
set -e
host="$1"
shift
printf 'Waiting for keycloak...'
until $(curl --output /dev/null --silent --head --fail $host); do
printf '.'
sleep 4
done
printf '\nKeycloak is up and running - Starting C4PO API'
exec "$@"

View File

@ -1,9 +1,11 @@
# cfg for local keycloak
DB_VENDOR=postgres
DB_ADDR=c4po-keycloak-postgress
DB_ADDR=c4po-keycloak-postgres
DB_PORT=5432
DB_USER=c4po_kc_local
DB_PASSWORD=Test1234!
KEYCLOAK_USER=admin
KEYCLOAK_PASSWORD=admin
KEYCLOAK_IMPORT=/tmp/c4po_realm_export.json
KEYCLOAK_FRONTEND_URL=http://localhost:8888/auth
#PROXY_ADDRESS_FORWARDING=true

View File

@ -35,11 +35,9 @@ services:
container_name: c4po-keycloak
depends_on:
- c4po-keycloak-postgres
links:
- c4po-keycloak-postgres
image: jboss/keycloak:11.0.3
volumes:
- /cfg/c4po_realm_export.json/:/tmp/c4po_realm_export.json
- ./cfg/c4po_realm_export.json:/tmp/c4po_realm_export.json
ports:
- 8888:8080
env_file:
@ -53,12 +51,10 @@ services:
container_name: c4po-angular
depends_on:
- c4po-keycloak
links:
- c4po-keycloak
deploy:
resources:
limits:
memory: "1G"
memory: "2G"
ports:
- 4200:4200
networks:
@ -73,13 +69,10 @@ services:
depends_on:
- c4po-db
- c4po-keycloak
links:
- c4po-db
- c4po-keycloak
deploy:
resources:
limits:
memory: "1G"
memory: "2G"
ports:
- 8443:8443
networks: