Skip to content

Commit

Permalink
dockerize iam-api
Browse files Browse the repository at this point in the history
  • Loading branch information
Omid Mohkamkar committed Apr 30, 2024
1 parent dc2a609 commit cd176dc
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 40 deletions.
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM maven:3.8.3-openjdk-17 AS build

# Set the working directory
WORKDIR /app

# Copy the source code
COPY ./iam-api .

# Build the project
RUN mvn clean package -DskipTests

# Create the final image with the built JAR file
FROM openjdk:17-jdk-slim

# Set the working directory
WORKDIR /opt/iam-aas

# Copy the JAR file
COPY --from=build /app/target/iam-api-2.0.2.jar ./application.jar

# Expose the port
EXPOSE 8000

# Run the application
ENTRYPOINT ["java", "-jar", "./application.jar"]
25 changes: 16 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=iam-password
ports:
- "5432"
- "5432:5432"
healthcheck:
test: "pg_isready -U postgres"

Expand Down Expand Up @@ -51,15 +51,22 @@ services:
labels:
org.springframework.boot.ignore: true

pgadmin-main:
image: dpage/pgadmin4
iam-api:
image: omidmk567/iam-aas:1.0.0
container_name: iam-api
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
PGADMIN_DEFAULT_PASSWORD: admin
- SPRING_DATASOURCE_URL=jdbc:postgresql://iam-postgres:5432/iam
- SPRING_DATASOURCE_USERNAME=postgres
- SPRING_DATASOURCE_PASSWORD=iam-password
- SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.postgresql.Driver
- APP_IAM_AAS_KEYCLOAK_BASE_URL=http://keycloak:8080
- APP_IAM_AAS_KEYCLOAK_MASTER_REALM=master
- APP_IAM_AAS_KEYCLOAK_MASTER_USERNAME=admin
- APP_IAM_AAS_KEYCLOAK_MASTER_PASSWORD=admin
- APP_IAM_AAS_KEYCLOAK_MASTER_CLIENT_ID=admin-cli
- APP_IAM_AAS_KEYCLOAK_AUTH_REALM=IAM-aaS
depends_on:
- keycloak-db
- iam-api-db
- keycloak
ports:
- '5051:80'
labels:
org.springframework.boot.ignore: true
- "8000:8000"
13 changes: 13 additions & 0 deletions iam-api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM openjdk:17-jdk-slim

# Set the working directory
WORKDIR /opt/iam-aas

# Copy the JAR file
COPY ./target/iam-api-2.0.2.jar ./application.jar

# Expose the port
EXPOSE 8000

# Run the application
ENTRYPOINT ["java", "-jar", "./application.jar"]
10 changes: 1 addition & 9 deletions iam-api/src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,12 @@ spring.jpa.hibernate.ddl-auto=create-drop
# Flyway
spring.flyway.enabled=false

# Keycloak
app.iam-aas.keycloak.base-url=http://localhost:8080
app.iam-aas.keycloak.master-realm=master
app.iam-aas.keycloak.master-username=admin
app.iam-aas.keycloak.master-password=admin
app.iam-aas.keycloak.master-client-id=admin-cli
app.iam-aas.keycloak.auth-realm=IAM-aaS

# Keycloak OAuth2 Resource Server
spring.security.oauth2.resourceserver.jwt.issuer-uri=${app.iam-aas.keycloak.base-url}/realms/${app.iam-aas.keycloak.auth-realm}
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=${app.iam-aas.keycloak.base-url}/realms/${app.iam-aas.keycloak.auth-realm}/protocol/openid-connect/certs
app.iam-aas.jwt.role.converter.clients=iam-admins,iam-customers

# Docker compose
spring.docker.compose.enabled=true
spring.docker.compose.enabled=false
spring.docker.compose.file=../docker-compose.yml
spring.docker.compose.lifecycle-management=start_only
10 changes: 1 addition & 9 deletions iam-api/src/main/resources/application-prod.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,12 @@ app.iam-aas.cors.allowed-origins=http://localhost:3000
spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=update

# Keycloak
app.iam-aas.keycloak.base-url=http://localhost:8080
app.iam-aas.keycloak.master-realm=master
app.iam-aas.keycloak.master-username=admin
app.iam-aas.keycloak.master-password=admin
app.iam-aas.keycloak.master-client-id=admin-cli
app.iam-aas.keycloak.auth-realm=IAM-aaS

# Keycloak OAuth2 Resource Server
spring.security.oauth2.resourceserver.jwt.issuer-uri=${app.iam-aas.keycloak.base-url}/realms/${app.iam-aas.keycloak.auth-realm}
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=${app.iam-aas.keycloak.base-url}/realms/${app.iam-aas.keycloak.auth-realm}/protocol/openid-connect/certs
app.iam-aas.jwt.role.converter.clients=iam-admins,iam-customers

# Docker compose
spring.docker.compose.enabled=true
spring.docker.compose.enabled=false
spring.docker.compose.file=../docker-compose.yml
spring.docker.compose.lifecycle-management=start_and_stop
13 changes: 0 additions & 13 deletions iam-api/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ app.iam-aas.cost-factor=1
app.iam-aas.fail-on-mail-error=false

# Database & JPA
spring.datasource.url=jdbc:h2:mem:iam-db
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=password
spring.h2.console.enabled=true
spring.jpa.properties.hibernate.event.merge.entity_copy_observer=allow
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
Expand All @@ -30,14 +25,6 @@ spring.flyway.enabled=true
spring.data.web.pageable.default-page-size=10
spring.data.web.pageable.max-page-size=100

# Keycloak
app.iam-aas.keycloak.base-url=http://localhost:8080
app.iam-aas.keycloak.master-realm=master
app.iam-aas.keycloak.master-username=omidmk
app.iam-aas.keycloak.master-password=omidmk
app.iam-aas.keycloak.master-client-id=admin-cli
app.iam-aas.keycloak.auth-realm=iam-aas

# Keycloak OAuth2 Resource Server
spring.security.oauth2.resourceserver.jwt.issuer-uri=${app.iam-aas.keycloak.base-url}/realms/${app.iam-aas.keycloak.auth-realm}
spring.security.oauth2.resourceserver.jwt.jwk-set-uri=${app.iam-aas.keycloak.base-url}/realms/${app.iam-aas.keycloak.auth-realm}/protocol/openid-connect/certs
Expand Down

0 comments on commit cd176dc

Please sign in to comment.