Skip to content

Commit

Permalink
Merge pull request #96 from anjana-somathilake/master
Browse files Browse the repository at this point in the history
Dockerfile and docker composer added
  • Loading branch information
anjana-somathilake authored Mar 23, 2020
2 parents f489b81 + 1f371bd commit a363cc2
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM frolvlad/alpine-java:jre8-slim
EXPOSE 8000
COPY target/covid19-1.0.0-SNAPSHOT/*.* ./
ENTRYPOINT ["java","-jar","covid19.jar"]

53 changes: 53 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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

8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
----
Expand Down

0 comments on commit a363cc2

Please sign in to comment.