Add postgresql config
This commit is contained in:
parent
91712fa7e0
commit
90139f9d80
6 changed files with 55 additions and 7 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -33,4 +33,5 @@ out/
|
|||
/.nb-gradle/
|
||||
|
||||
### 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-jdbc:$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-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.*
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,10 +9,12 @@ import org.jetbrains.exposed.sql.transactions.transaction
|
|||
|
||||
object DatabaseFactory {
|
||||
fun init() {
|
||||
val driverClassName = "org.h2.Driver"
|
||||
val jdbcURL = "jdbc:h2:file:./build/db"
|
||||
val database = Database.connect(jdbcURL, driverClassName)
|
||||
|
||||
val database = Database.connect(
|
||||
url = "jdbc:pgsql://localhost:5004/schools",
|
||||
driver = "com.impossibl.postgres.jdbc.PGDriver",
|
||||
user = "postgres",
|
||||
password = "postgres",
|
||||
)
|
||||
|
||||
transaction(database) {
|
||||
SchemaUtils.create(LoginEvents)
|
||||
|
|
Loading…
Reference in a new issue