Add postgresql config
This commit is contained in:
parent
91712fa7e0
commit
90139f9d80
6 changed files with 55 additions and 7 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -34,3 +34,4 @@ out/
|
||||||
|
|
||||||
### VS Code ###
|
### VS Code ###
|
||||||
.vscode/
|
.vscode/
|
||||||
|
.env
|
||||||
|
|
12
Dockerfile
Normal file
12
Dockerfile
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
FROM gradle:7-jdk11 AS build
|
||||||
|
COPY --chown=gradle:gradle . /home/gradle/src
|
||||||
|
WORKDIR /home/gradle/src
|
||||||
|
RUN gradle buildFatJar --no-daemon
|
||||||
|
|
||||||
|
FROM openjdk:11
|
||||||
|
EXPOSE 3002
|
||||||
|
RUN mkdir /app
|
||||||
|
COPY --from=build /home/gradle/src/.env /home/gradle/src/build/libs/*.jar /app/
|
||||||
|
|
||||||
|
ENV PORT=3002
|
||||||
|
ENTRYPOINT ["java","-jar","/app/schools-all.jar"]
|
|
@ -45,7 +45,7 @@ dependencies {
|
||||||
implementation("org.jetbrains.exposed:exposed-dao:$exposed_version")
|
implementation("org.jetbrains.exposed:exposed-dao:$exposed_version")
|
||||||
implementation("org.jetbrains.exposed:exposed-jdbc:$exposed_version")
|
implementation("org.jetbrains.exposed:exposed-jdbc:$exposed_version")
|
||||||
implementation("org.jetbrains.exposed:exposed-java-time:$exposed_version")
|
implementation("org.jetbrains.exposed:exposed-java-time:$exposed_version")
|
||||||
implementation("com.h2database:h2:$h2_version")
|
implementation("com.impossibl.pgjdbc-ng:pgjdbc-ng:0.8.9")
|
||||||
|
|
||||||
testImplementation("io.ktor:ktor-server-tests-jvm")
|
testImplementation("io.ktor:ktor-server-tests-jvm")
|
||||||
testImplementation("io.ktor:ktor-server-test-host-jvm")
|
testImplementation("io.ktor:ktor-server-test-host-jvm")
|
||||||
|
|
33
docker-compose.yaml
Normal file
33
docker-compose.yaml
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
version: "3.8"
|
||||||
|
|
||||||
|
services:
|
||||||
|
schools:
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- "3002:3002"
|
||||||
|
networks:
|
||||||
|
- docker_network
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
|
||||||
|
db:
|
||||||
|
image: postgres:16-alpine
|
||||||
|
restart: always
|
||||||
|
environment:
|
||||||
|
- POSTGRES_USER=postgres
|
||||||
|
- POSTGRES_PASSWORD=postgres
|
||||||
|
- POSTGRES_DB=schools
|
||||||
|
ports:
|
||||||
|
- '5004:5432'
|
||||||
|
networks:
|
||||||
|
- docker_network
|
||||||
|
volumes:
|
||||||
|
- db:/var/lib/postgresql/data
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db:
|
||||||
|
driver: local
|
||||||
|
|
||||||
|
networks:
|
||||||
|
docker_network:
|
||||||
|
name: wulkanowy_network
|
|
@ -7,7 +7,7 @@ import io.ktor.server.engine.*
|
||||||
import io.ktor.server.netty.*
|
import io.ktor.server.netty.*
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
embeddedServer(Netty, port = 8080, host = "0.0.0.0", module = Application::module)
|
embeddedServer(Netty, port = 3002, host = "0.0.0.0", module = Application::module)
|
||||||
.start(wait = true)
|
.start(wait = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,12 @@ import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
|
||||||
object DatabaseFactory {
|
object DatabaseFactory {
|
||||||
fun init() {
|
fun init() {
|
||||||
val driverClassName = "org.h2.Driver"
|
val database = Database.connect(
|
||||||
val jdbcURL = "jdbc:h2:file:./build/db"
|
url = "jdbc:pgsql://localhost:5004/schools",
|
||||||
val database = Database.connect(jdbcURL, driverClassName)
|
driver = "com.impossibl.postgres.jdbc.PGDriver",
|
||||||
|
user = "postgres",
|
||||||
|
password = "postgres",
|
||||||
|
)
|
||||||
|
|
||||||
transaction(database) {
|
transaction(database) {
|
||||||
SchemaUtils.create(LoginEvents)
|
SchemaUtils.create(LoginEvents)
|
||||||
|
|
Loading…
Reference in a new issue