Skip to content

Commit

Permalink
Merge pull request #8 from musabbozkurt/adjust-docker-compose-and-doc…
Browse files Browse the repository at this point in the history
…kerfile

Adjust docker-compose.yml and Dockerfile
  • Loading branch information
musabbozkurt authored Aug 7, 2024
2 parents 72e729e + 68efee6 commit 55c03b8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ POSTGRES_PASSWORD=postgres
POSTGRES_USER=postgres
POSTGRES_DB=postgres
POSTGRES_LOCAL_PORT=5432
POSTGRES_DOCKER_PORT=5433
POSTGRES_DOCKER_PORT=5432

INVENTORY_MANAGEMENT_SERVICE_START_PROFILE=start_application
SPRING_LOCAL_PORT=8080
SPRING_DOCKER_PORT=8080

Expand Down
23 changes: 10 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,21 @@ RUN mvn -f ${PROJECT_DIR}/pom.xml clean install -DskipTests
# Use an official OpenJDK image as the base image
FROM openjdk:21-jdk-slim

ARG PROJECT_NAME=inventory-management-service
ARG PROJECT_JAR_FILE_NAME=${PROJECT_NAME}-0.0.1-SNAPSHOT
ARG PROJECT_DIR=/home/projects/${PROJECT_NAME}
ENV PROJECT_NAME=inventory-management-service
ENV PROJECT_JAR_FILE_NAME=${PROJECT_NAME}-0.0.1-SNAPSHOT
ENV PROJECT_DIR=/home/projects/${PROJECT_NAME}

# Uncomment the following command to define the location of the New Relic agent JAR
# ARG NEW_RELIC_AGENT_JAR_PATH
# Define the location of the New Relic agent JAR
ARG NEW_RELIC_AGENT_JAR_PATH
ENV NEW_RELIC_AGENT_JAR_PATH_ENV=$NEW_RELIC_AGENT_JAR_PATH

# Uncomment the following command to copy the New Relic agent JAR into the Docker image
# COPY ${NEW_RELIC_AGENT_JAR_PATH} ${NEW_RELIC_AGENT_JAR_PATH}
# Copy the New Relic agent JAR into the Docker image
COPY ${NEW_RELIC_AGENT_JAR_PATH_ENV} ${PROJECT_DIR}/${NEW_RELIC_AGENT_JAR_PATH_ENV}

# Copy the application JAR into the Docker image
COPY --from=maven-builder ${PROJECT_DIR}/target/${PROJECT_JAR_FILE_NAME}.jar ${PROJECT_DIR}/${PROJECT_JAR_FILE_NAME}.jar

WORKDIR ${PROJECT_DIR}

# Set the entrypoint to run the application
ENTRYPOINT java, -jar, ${PROJECT_JAR_FILE_NAME}.jar

# Use the following ENTRYPOINT command instead of the above ENTRYPOINT command
# to set the entrypoint to run the application with the New Relic Java agent
# ENTRYPOINT java, -javaagent:${NEW_RELIC_AGENT_JAR_PATH} -jar, ${PROJECT_JAR_FILE_NAME}.jar
# Set the entrypoint to run the application with the New Relic Java agent
ENTRYPOINT java -javaagent:${NEW_RELIC_AGENT_JAR_PATH_ENV} -jar ${PROJECT_JAR_FILE_NAME}.jar
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

1. Run `mvn clean install` or `mvn clean package`
2. Run `mvn spring-boot:run` or `./mvnw spring-boot:run`
- Run [./scripts/run.sh](scripts%2Frun.sh) to start the application with `New Relic Java agent` (OPTIONAL)
3. `docker-compose up -d --build` can be run to create and run Docker image (OPTIONAL)
- Run [./scripts/run.sh](scripts%2Frun.sh) to start the application with `New Relic Java agent` (Optional)
- `docker-compose --profile start_application up -d --build` can be run to create and run a Docker image of the
application with `New Relic Java agent` (Optional)

-----

Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ services:
- KAFKA_BROKERS=kafka:9093 # Kafka container name and port
ports:
- ${SPRING_LOCAL_PORT}:${SPRING_DOCKER_PORT}
profiles:
- ${INVENTORY_MANAGEMENT_SERVICE_START_PROFILE}

postgres:
image: debezium/example-postgres:latest
Expand Down

0 comments on commit 55c03b8

Please sign in to comment.