Add docker service for the api + env variables + ...
This commit is contained in:
parent
a2ac8d19af
commit
8cf8457a54
5
.env.dist
Normal file
5
.env.dist
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
MYSQL_ROOT_PASSWORD=
|
||||||
|
MYSQL_DATABASE=
|
||||||
|
MYSQL_USER=
|
||||||
|
MYSQL_PASSWORD=
|
||||||
|
JWT_SECRET=
|
||||||
14
api/Dockerfile
Normal file
14
api/Dockerfile
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
FROM openjdk:13-alpine
|
||||||
|
|
||||||
|
ENV APPLICATION_USER ktor
|
||||||
|
RUN adduser -D -g '' $APPLICATION_USER
|
||||||
|
|
||||||
|
RUN mkdir /app
|
||||||
|
RUN chown -R $APPLICATION_USER /app
|
||||||
|
|
||||||
|
USER $APPLICATION_USER
|
||||||
|
|
||||||
|
COPY ./target/api-0.0.1-jar-with-dependencies.jar /app/notes-api.jar
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
CMD ["java", "-server", "-XX:+UnlockExperimentalVMOptions", "-XX:InitialRAMFraction=2", "-XX:MinRAMFraction=2", "-XX:MaxRAMFraction=2", "-XX:+UseG1GC", "-XX:MaxGCPauseMillis=100", "-XX:+UseStringDeduplication", "-jar", "notes-api.jar"]
|
||||||
@ -24,7 +24,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
|
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
|
||||||
<kotlin.compiler.jvmTarget>12</kotlin.compiler.jvmTarget>
|
<kotlin.compiler.jvmTarget>12</kotlin.compiler.jvmTarget>
|
||||||
<main.class>io.ktor.server.netty.EngineMain</main.class>
|
<main.class>be.vandewalleh.NotesApplicationKt</main.class>
|
||||||
<java.version>13</java.version>
|
<java.version>13</java.version>
|
||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
@ -150,11 +150,6 @@
|
|||||||
<artifactId>HikariCP</artifactId>
|
<artifactId>HikariCP</artifactId>
|
||||||
<version>3.4.2</version>
|
<version>3.4.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.sksamuel.hoplite</groupId>
|
|
||||||
<artifactId>hoplite-core</artifactId>
|
|
||||||
<version>${hoplite_version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sksamuel.hoplite</groupId>
|
<groupId>com.sksamuel.hoplite</groupId>
|
||||||
<artifactId>hoplite-yaml</artifactId>
|
<artifactId>hoplite-yaml</artifactId>
|
||||||
|
|||||||
@ -1,18 +1,18 @@
|
|||||||
env: staging
|
env: staging
|
||||||
|
|
||||||
database:
|
database:
|
||||||
host: 127.0.0.1
|
host: ${MYSQL_HOST}
|
||||||
port: 3306
|
port: 3306
|
||||||
name: Notes
|
name: ${MYSQL_DATABASE}
|
||||||
username: test
|
username: ${MYSQL_USER}
|
||||||
password: test
|
password: ${MYSQL_PASSWORD}
|
||||||
|
|
||||||
server:
|
server:
|
||||||
host: 0.0.0.0
|
host: 0.0.0.0
|
||||||
port: 8081
|
port: 8081
|
||||||
|
|
||||||
jwt:
|
jwt:
|
||||||
secret: ${random.string(25)}
|
secret: ${JWT_SECRET}
|
||||||
auth:
|
auth:
|
||||||
validity: 1
|
validity: 1
|
||||||
unit: HOURS
|
unit: HOURS
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import org.kodein.di.generic.singleton
|
|||||||
import org.slf4j.Logger
|
import org.slf4j.Logger
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import javax.sql.DataSource
|
import javax.sql.DataSource
|
||||||
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
val kodein = Kodein {
|
val kodein = Kodein {
|
||||||
import(serviceModule)
|
import(serviceModule)
|
||||||
|
|||||||
@ -1,18 +1,35 @@
|
|||||||
version: '3'
|
version: '2.2'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
|
||||||
db:
|
db:
|
||||||
image: mariadb
|
image: mariadb
|
||||||
container_name: notes-mariadb
|
container_name: notes-mariadb
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
environment:
|
environment:
|
||||||
- PUID=1000
|
- PUID=1000
|
||||||
- PGID=1000
|
- PGID=1000
|
||||||
- MYSQL_ROOT_PASSWORD=test
|
|
||||||
- TZ=Europe/Brussels
|
- TZ=Europe/Brussels
|
||||||
- MYSQL_DATABASE=Notes
|
|
||||||
- MYSQL_USER=test
|
|
||||||
- MYSQL_PASSWORD=test
|
|
||||||
ports:
|
ports:
|
||||||
|
# This is only for testing
|
||||||
- 3306:3306
|
- 3306:3306
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
|
||||||
|
timeout: 20s
|
||||||
|
retries: 10
|
||||||
|
|
||||||
|
|
||||||
|
api:
|
||||||
|
build: ./api
|
||||||
|
container_name: notes-api
|
||||||
|
ports:
|
||||||
|
- 8081:8081
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
environment:
|
||||||
|
- TZ=Europe/Brussels
|
||||||
|
- MYSQL_HOST=db
|
||||||
|
depends_on:
|
||||||
|
db:
|
||||||
|
condition: service_healthy
|
||||||
Loading…
x
Reference in New Issue
Block a user