Skip to content

Commit

Permalink
Some refinements/fixes for deploying-to-google-cloud
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Apr 8, 2021
1 parent f91ac6f commit d6699cd
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions docs/src/main/asciidoc/deploying-to-google-cloud.adoc
Expand Up @@ -220,16 +220,16 @@ When the deployment is done, the output will display the URL to access your appl

== Using Cloud SQL

Google Cloud SQL provides managed instances for MySQL, PostgreSQL and SQLServer.
Google Cloud SQL provides managed instances for MySQL, PostgreSQL and Microsoft SQL Server.
Quarkus has support for all three databases.

To make them work with Cloud SQL, you first need to use the corresponding JDBC extension, for example, for PostgreSQL,
add the `jdbc-postgresql` extension.
To make your applications work with Cloud SQL, you first need to use the corresponding JDBC extension, for example, for PostgreSQL,
add the `quarkus-jdbc-postgresql` extension.

Then you need to add to your pom.xml the Cloud SQL JDBC library that provides the connectivity to Cloud SQL,
for PostgreSQL you'll need to include the following dependency :
Then you need to add to your `pom.xml` the Cloud SQL JDBC library that provides the additional connectivity to Cloud SQL.
For PostgreSQL you will need to include the following dependency:

[code, xml]
[source, xml]
----
<dependency>
<groupId>com.google.cloud.sql</groupId>
Expand All @@ -238,29 +238,29 @@ for PostgreSQL you'll need to include the following dependency :
</dependency>
----

Finally, you need to configure your datasource specifically to use the socket factory :
Finally, you need to configure your datasource specifically to use the socket factory:

[source, properties]
----
quarkus.datasource.db-kind=other #<1>
quarkus.datasource.jdbc.url=jdbc:postgresql:///mydabatabe #<2>
quarkus.datasource.db-kind=other <1>
quarkus.datasource.jdbc.url=jdbc:postgresql:///mydatabase <2>
quarkus.datasource.jdbc.driver=org.postgresql.Driver
quarkus.datasource.username=quarkus
quarkus.datasource.password=quarkus
quarkus.datasource.jdbc.additional-jdbc-properties.cloudSqlInstance=project-id:gcp-region:instance #<3>
quarkus.datasource.jdbc.additional-jdbc-properties.socketFactory=com.google.cloud.sql.postgres.SocketFactory #<4>
quarkus.datasource.jdbc.additional-jdbc-properties.cloudSqlInstance=project-id:gcp-region:instance <3>
quarkus.datasource.jdbc.additional-jdbc-properties.socketFactory=com.google.cloud.sql.postgres.SocketFactory <4>
----

1. Database kind must be 'other' as we need to skip Quarkus auto-configuration.
2. The JDBC URL should not include the hostname / IP of the database.
3. We add the `cloudSqlInstance` additional JDBC property to configure the instance id.
4. We add the `socketFactory` additional JDBC property to configure the socket factory used to connect to Cloud SQL,
<1> Database kind must be 'other' as we need to skip Quarkus auto-configuration.
<2> The JDBC URL should not include the hostname / IP of the database.
<3> We add the `cloudSqlInstance` additional JDBC property to configure the instance id.
<4> We add the `socketFactory` additional JDBC property to configure the socket factory used to connect to Cloud SQL,
this one is coming from the `postgres-socket-factory` dependency.

NOTE: If you use Hibernate, you also need to configure `quarkus.hibernate-orm.dialect=org.hibernate.dialect.PostgreSQL10Dialect` as Hibernate
would not be able to automatically detect the dialect of your database.
NOTE: If you use Hibernate ORM, you also need to configure `quarkus.hibernate-orm.dialect=org.hibernate.dialect.PostgreSQL10Dialect`
as Hibernate ORM would not be able to automatically detect the dialect of your database.

WARNING: Using a PostgreSQL socket factory is not possible on dev mode due to link:https://github.com/quarkusio/quarkus/issues/15782[#15782].
WARNING: Using a PostgreSQL socket factory is not possible in dev mode at the moment
due to issue link:https://github.com/quarkusio/quarkus/issues/15782[#15782].

== Going further

Expand Down

0 comments on commit d6699cd

Please sign in to comment.