From fe538f39e6669f6455afea64e7e0126177f1b123 Mon Sep 17 00:00:00 2001 From: Anjana Somathilake Date: Mon, 23 Mar 2020 14:14:37 +0530 Subject: [PATCH 1/2] docker file and updated readme --- Dockerfile | 5 +++++ docker-compose.yml | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3ad7d42 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,5 @@ +FROM frolvlad/alpine-java:jre8-slim +EXPOSE 8000 +COPY target/covid19-1.0.0-SNAPSHOT/*.* ./ +ENTRYPOINT ["java","-jar","covid19.jar"] + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..c4ba1a9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,53 @@ +version: "2.1" + +volumes: + files: + driver: local + mysql: + driver: local + backup: + driver: local + +services: + covid19-service: + build: ./ + expose: + - "8000" + restart: always + ports: + - 8000:8000 + depends_on: + - db + environment: + - COVID19_SERVICE_DOMAIN="localhost" + healthcheck: + test: ["CMD", "/usr/bin/healthcheck"] + interval: 30s + timeout: 10s + retries: 5 + volumes: + - files:/mnt/data + + db: + image: webhippie/mariadb:latest + restart: always + expose: + - "3306" + ports: + - 3306:3306 + environment: + - MARIADB_ROOT_PASSWORD=root + - MARIADB_USERNAME=root + - MARIADB_PASSWORD=root + - MARIADB_DATABASE=covid19_db + - MARIADB_MAX_ALLOWED_PACKET=128M + - MARIADB_INNODB_LOG_FILE_SIZE=64M + healthcheck: + test: ["CMD", "/usr/bin/mysql --user=root --password=root--execute \"SHOW DATABASES;\""] + interval: 30s + timeout: 10s + retries: 5 + volumes: + - mysql:/var/lib/mysql + - backup:/var/lib/backup + From 1f371bd74373fe404649fe57ab6e66d6947abd9b Mon Sep 17 00:00:00 2001 From: Anjana Somathilake Date: Mon, 23 Mar 2020 14:16:12 +0530 Subject: [PATCH 2/2] updated readme --- readme.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/readme.md b/readme.md index 21c71bf..663e229 100644 --- a/readme.md +++ b/readme.md @@ -33,6 +33,14 @@ and add the private key from Firebase Admin SDK. - run `java -jar covid19-1.0.0-SNAPSHOT.jar`. Check if the jar version matches. - NOTE: access logs will get stored in the tomcat folder (tomcat/access/). These logs can be disabled from the application.yml + +### with Docker +- build project using `mvn clean install` +- unzip the `target/covid19-1.0.0-SNAPSHOT.zip` to `target/covid19-1.0.0-SNAPSHOT` +- modify the db url in the application.yml (replace localhose with container name) as below (FIXME: automate with spring profiles) +- `url: jdbc:mysql://db:3306/covid19_db?useUnicode=yes&characterEncoding=UTF-8` +- run ` docker-compose up -d` , make sure that ports 8000 and 3306 are not used in the local machine +- connect to dockerized mysql localhost:3306/covid19_db and execute `covid19.sql` on server (execute `covid19_test.sql` to add test data) ## APIs ----