Skip to content

Commit

Permalink
Aligned configs with heroku (#9)
Browse files Browse the repository at this point in the history
Co-authored-by: jaivalis <[email protected]>
  • Loading branch information
jaivalis and jaivalis authored Sep 4, 2021
1 parent db6892a commit 8db8bd6
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*
!target/*-runner
#!target/*-runner
!target/*-runner.jar
!target/lib/*
!target/quarkus-app/*
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: java -Dquarkus.http.port=$PORT -jar release-raccoon/target/release.raccoon-0.0.1-SNAPSHOT-runner.jar
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
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
9 changes: 6 additions & 3 deletions docker/Dockerfile.native
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand All @@ -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
Expand Down
38 changes: 28 additions & 10 deletions release-raccoon-app/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -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}
Expand Down Expand Up @@ -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
Expand All @@ -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
############################################### /TEST ##############################################
####################################################################################################
1 change: 1 addition & 0 deletions system.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# used by heroku
java.runtime.version=11

0 comments on commit 8db8bd6

Please sign in to comment.