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 + diff --git a/readme.md b/readme.md index 60a135b..7d0301e 100644 --- a/readme.md +++ b/readme.md @@ -29,6 +29,14 @@ Please keep the following in mind when submitting your valuable contributions - 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 ----