summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Dockerfile12
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/platform/JpaExperiment.kt1
-rw-r--r--opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/platform/JpaPlatformRunner.kt8
3 files changed, 16 insertions, 5 deletions
diff --git a/Dockerfile b/Dockerfile
index 6346a940..f8de6b54 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -2,15 +2,19 @@ FROM gradle:alpine
MAINTAINER Fabian Mastenbroek <f.s.mastenbroek@student.tudelft.nl>
# Copy OpenDC simulator
-COPY ./ /simulator
+COPY ./ /home/gradle/simulator
# Fix permissions
USER root
-RUN chown -R gradle:gradle /simulator
+RUN chown -R gradle:gradle /home/gradle/simulator && \
+ chmod -R 771 /home/gradle/simulator
USER gradle
# Set the working directory to the JPA integration
-WORKDIR /simulator/opendc-integration-jpa
+WORKDIR /home/gradle/simulator/opendc-integration-jpa
+
+# Build the application
+RUN gradle --no-daemon installDist
# Run the application
-CMD ["/bin/sh", "-c", "gradle run -Ppersistence.url=$(echo \"jdbc:mysql://mariadb:3306/\"$MYSQL_DATABASE) -Ppersistence.user=$MYSQL_USER -Ppersistence.password=$MYSQL_PASSWORD"]
+CMD build/install/opendc-integration-jpa/bin/opendc-integration-jpa
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/platform/JpaExperiment.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/platform/JpaExperiment.kt
index 104011df..f5a86e64 100644
--- a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/platform/JpaExperiment.kt
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/platform/JpaExperiment.kt
@@ -145,5 +145,6 @@ class JpaExperiment(val manager: EntityManager,
}
logger.info { "Simulation done" }
+ manager.close()
}
}
diff --git a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/platform/JpaPlatformRunner.kt b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/platform/JpaPlatformRunner.kt
index d7282c27..6a1d839d 100644
--- a/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/platform/JpaPlatformRunner.kt
+++ b/opendc-integration-jpa/src/main/kotlin/nl/atlarge/opendc/platform/JpaPlatformRunner.kt
@@ -38,9 +38,15 @@ val logger = KotlinLogging.logger {}
* @param args The command line arguments of the program.
*/
fun main(args: Array<String>) {
+ val properties = HashMap<Any, Any>()
+ val env = System.getenv()
+ properties["javax.persistence.jdbc.url"] = env["PERSISTENCE_URL"] ?: ""
+ properties["javax.persistence.jdbc.user"] = env["PERSISTENCE_USER"] ?: ""
+ properties["javax.persistence.jdbc.password"] = env["PERSISTENCE_PASSWORD"] ?: ""
+ val factory = Persistence.createEntityManagerFactory("opendc-simulator", properties)
+
val threads = 1
val executorService = Executors.newFixedThreadPool(threads)
- val factory = Persistence.createEntityManagerFactory("opendc-simulator")
val experiments = JpaExperimentManager(factory)
logger.info { "Waiting for enqueued experiments..." }