From 8db8bd622f3666c9442102826ae4485b6f7fb118 Mon Sep 17 00:00:00 2001 From: jaivalis Date: Sat, 4 Sep 2021 22:43:44 +0200 Subject: [PATCH] Aligned configs with heroku (#9) Co-authored-by: jaivalis --- .dockerignore | 2 +- Procfile | 2 +- README.md | 19 ++++++++++ docker/Dockerfile.native | 9 +++-- .../src/main/resources/application.properties | 38 ++++++++++++++----- system.properties | 1 + 6 files changed, 56 insertions(+), 15 deletions(-) diff --git a/.dockerignore b/.dockerignore index 94810d00..02502c07 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,5 @@ * -!target/*-runner +#!target/*-runner !target/*-runner.jar !target/lib/* !target/quarkus-app/* \ No newline at end of file diff --git a/Procfile b/Procfile index dd7e050f..a7544ee2 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: java -Dquarkus.http.port=$PORT -jar release-raccoon/target/release.raccoon-0.0.1-SNAPSHOT-runner.jar \ No newline at end of file +web: java -Dquarkus.http.port=$PORT -jar build/release-raccoon-app-0.0.1-SNAPSHOT-native-image-source-jar/release-raccoon-app-0.0.1-SNAPSHOT-runner.jar \ No newline at end of file diff --git a/README.md b/README.md index 7c360611..3838b3fc 100644 --- a/README.md +++ b/README.md @@ -70,3 +70,22 @@ Access the [Keycloak Admin Console](http://127.0.0.1:${KEYCLOAK_PORT}/auth/admin Import the [realm](resources/realm-export.json) to create a realm named `RaccoonRealm`. In case the redirect back from keycloak doesn't work in dev mode, you might need to regenerate a `quarkus.oidc.credentials.secret` and plug it into the `application.properties` file. + +## Deploying the image to heroku (manually) + +Build the project to get the jar +```shell +./mvnw package -Pnative -Dquarkus.native.container-build=true -Dquarkus.container-image.build=true +``` + +Build the docker image, push it to the heroku repository and deploy to heroku: +```shell +cp build/release-raccoon-app-0.0.1-SNAPSHOT-runner && pushd docker && docker build -f Dockerfile.native -t registry.heroku.com/release-raccoon/web . +docker push registry.heroku.com/release-raccoon/web +heroku container:release web --app release-raccoon && popd +``` + +Check the logs for a successful start. +```shell +heroku logs --app release-raccoon +``` diff --git a/docker/Dockerfile.native b/docker/Dockerfile.native index 4f64a43d..3bccb51d 100644 --- a/docker/Dockerfile.native +++ b/docker/Dockerfile.native @@ -3,11 +3,11 @@ # # Before building the container image run: # -# ./mvnw package -Pnative +# ./mvnw package -Pnative -pl release-raccoon-app # # Then, build the image with: # -# docker build -f src/main/docker/Dockerfile.native -t quarkus/release.com.raccoon . +# docker build -f src/main/docker/Dockerfile.native -t jaivalis/release-raccoon:0.0.1 . --file build/*runner # # Then run the container using: # @@ -19,7 +19,10 @@ WORKDIR /work/ RUN chown 1001 /work \ && chmod "g+rwX" /work \ && chown 1001:root /work -COPY --chown=1001:root target/*-runner /work/application +CMD pwd +COPY --chown=1001:root release-raccoon-app-0.0.1-SNAPSHOT-runner /work/application + +RUN chmod +x /work/application EXPOSE 8080 USER 1001 diff --git a/release-raccoon-app/src/main/resources/application.properties b/release-raccoon-app/src/main/resources/application.properties index b1883e09..0ce46964 100644 --- a/release-raccoon-app/src/main/resources/application.properties +++ b/release-raccoon-app/src/main/resources/application.properties @@ -1,10 +1,10 @@ +quarkus.http.port=${PORT:8080} + quarkus.swagger-ui.enable=true # https://quarkus.io/guides/writing-native-applications-tips#delaying-class-initialization quarkus.native.additional-build-args=--initialize-at-run-time=org.apache.hc.client5.http.impl.auth.NTLMEngineImpl\\,com.wrapper.spotify.SpotifyApi # db -db.name=${DB_NAME} -quarkus.datasource.jdbc.url=jdbc:mariadb://${db.server}:${db.port}/${db.name} quarkus.datasource.db-kind=mariadb quarkus.datasource.username=${DB_USERNAME} quarkus.datasource.password=${DB_PASSWORD} @@ -36,21 +36,41 @@ quarkus.mailer.username=${MAIL_USERNAME} quarkus.mailer.password=${MAIL_PASSWORD} quarkus.mailer.mock=false -# DEV +#################################################################################################### +############################################### PROD ############################################### +# db +%prod.quarkus.datasource.jdbc.url=jdbc:mariadb://${DB_HOST}:${DB_PORT}/${DB_NAME} +%prod.quarkus.datasource.username=${DB_USERNAME} +%prod.quarkus.datasource.password=${DB_PASSWORD} +%prod.quarkus.hibernate-orm.database.generation=none +%prod.quarkus.hibernate-orm.sql-load-script=no-file + +# OIDC +%prod.quarkus.oidc.auth-server-url=${AUTH0_DOMAIN} +%prod.quarkus.oidc.client-id=${AUTH0_CLIENT_ID} +%prod.quarkus.oidc.credentials.secret=${AUTH0_CLIENT_SECRET} +%prod.quarkus.oidc.application-type=web_app +%prod.quarkus.oidc.authentication.scopes=email +############################################### /PROD ############################################## +#################################################################################################### +############################################### DEV ############################################### # db +%dev.db.name=${DB_NAME} +%dev.quarkus.datasource.jdbc.url=jdbc:mariadb://${db.server}:${db.port}/${db.name} %dev.db.server=${DB_HOST} %dev.db.port=${DB_PORT} %dev.quarkus.hibernate-orm.database.generation=drop-and-create #%dev.quarkus.hibernate-orm.log.sql=true -# OIDC Configuration +# OIDC %dev.quarkus.oidc.auth-server-url=http://localhost:${KEYCLOAK_PORT}/auth/realms/RaccoonRealm %dev.quarkus.oidc.client-id=release-raccoon %dev.quarkus.oidc.credentials.secret=43817db1-b171-4c51-bebc-a1ea161cf6a9 %dev.quarkus.oidc.application-type=web_app %dev.quarkus.oidc.authentication.scopes=email - -# TEST +############################################### /DEV ############################################### +#################################################################################################### +############################################### TEST ############################################### %test.quarkus.hibernate-orm.log.sql=true #%test.quarkus.datasource.jdbc.url=jdbc:h2:mem:raccoon-test #%test.quarkus.datasource.db-kind=h2 @@ -75,7 +95,5 @@ quarkus.mailer.mock=false # email %test.quarkus.mailer.username=placeholder %test.quarkus.mailer.password=placeholder - -##%test.quarkus.hibernate-orm.sql-load-script=import-test.sql - -#%test.quarkus.log.category."org.agoncal".level=DEBUG \ No newline at end of file +############################################### /TEST ############################################## +#################################################################################################### \ No newline at end of file diff --git a/system.properties b/system.properties index 180a2734..2d69d164 100644 --- a/system.properties +++ b/system.properties @@ -1 +1,2 @@ +# used by heroku java.runtime.version=11 \ No newline at end of file