Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile and docker composer added #96

Merged
merged 2 commits into from
Mar 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @anjana-somathilake

Can't we do the build too inside the docker file?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can, then the docker should have maven installed as a dependency, building on the dev and deploying on the server is what makes sense for developers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have a CI service?

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 @@ -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)
anjana-somathilake marked this conversation as resolved.
Show resolved Hide resolved
- `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