-
Notifications
You must be signed in to change notification settings - Fork 13
Added Docker and docker-compose to run API and MySQL #48
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
Open
ramdesh
wants to merge
10
commits into
main
Choose a base branch
from
docker-compose
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d256c2d
Dockerized backend
ramdesh c275c41
Redefined config file
ramdesh 6376c23
Changed config
ramdesh 8ae5031
Removed chars that could cause an error
ramdesh 1fa8f07
Added newline
ramdesh cd21728
Added more missing newlines
ramdesh 8c60d07
Updated README with normal run instructions
ramdesh 5a25c1a
Updated with correct port
ramdesh 01762dc
Added db creation
ramdesh f09e5e2
Added info on testing API after run
ramdesh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| from ballerina/ballerina:latest | ||
|
|
||
| COPY . /app | ||
| WORKDIR /app | ||
| RUN mkdir /home/ballerina/.ballerina | ||
|
|
||
| EXPOSE 9090 | ||
|
|
||
| ENTRYPOINT ["bal", "run"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| ## Medicines for LK - Admin API | ||
|
|
||
| The medicines LK app is comprised of a [React Frontend](https://github.com/LSFLK/MedicinesforLK), [Ballerina Donor API](https://github.com/LSFLK/MedicinesforLK-DonorAPI) and [Ballerina Admin API](https://github.com/LSFLK/MedicinesforLK-AdminAPI). | ||
|
|
||
| ### Development | ||
|
|
||
| - [Set up Ballerina](https://ballerina.io/learn/install-ballerina/set-up-ballerina/) | ||
| - Run a MySQL server and execute the script `mysql-scripts/creation-ddl.sql` on it to bring up the DDL for the db. You need to have a `medicinesforlk` db in your MySQL server to set up the DDL in. | ||
| - Modify `config.bal` with the values for the MySQL server you set up. | ||
| - `bal run` (runs the API on port 9090) | ||
| - Test the API http://localhost:9090/admin/medicalneeds | ||
|
|
||
| ### Run using Docker Compose | ||
|
|
||
| - `docker-compose up -d` | ||
| - Test the API http://localhost:9090/admin/medicalneeds |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| configurable string dbHost = "dbHost"; | ||
| configurable string dbHost = "medicinesforlk-mysql"; | ||
| configurable int dbPort = 3306; | ||
| configurable string dbUser = "dbUser"; | ||
| configurable string dbPass = "dbPass"; | ||
| configurable string db = "db"; | ||
| configurable string dbUser = "root"; | ||
| configurable string dbPass = "root"; | ||
| configurable string db = "medicinesforlk"; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| version: "3.5" | ||
|
|
||
| services: | ||
| medicinesforlk-adminapi: | ||
| build: | ||
| context: ./ | ||
| restart: unless-stopped | ||
| container_name: medicinesforlk-adminapi | ||
| image: medicinesforlk-adminapi | ||
| ports: | ||
| - "9090:9090" | ||
| volumes: | ||
| - "./:/home" | ||
| - "./target:/app/target" | ||
| - "./Dependencies.toml:/app/Dependencies.toml" | ||
| networks: | ||
| medicinesforlk-network: | ||
| ipv4_address: 172.16.238.10 | ||
|
|
||
|
|
||
| mysql: | ||
| image: mysql | ||
| container_name: medicinesforlk-mysql | ||
| command: --default-authentication-plugin=mysql_native_password | ||
| environment: | ||
| MYSQL_ROOT_PASSWORD: root | ||
| ports: | ||
| - "3306:3306" | ||
| volumes: | ||
| - "./mysql-scripts/create-database.sql:/docker-entrypoint-initdb.d/1.sql" | ||
| - "./mysql-scripts/creation-ddl.sql:/docker-entrypoint-initdb.d/2.sql" | ||
| networks: | ||
| medicinesforlk-network: | ||
| ipv4_address: 172.16.238.11 | ||
|
|
||
|
|
||
| networks: | ||
| medicinesforlk-network: | ||
| name: medicinesforlk-network | ||
| driver: bridge | ||
| ipam: | ||
| driver: default | ||
| config: | ||
| - subnet: 172.16.238.0/24 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| CREATE DATABASE IF NOT EXISTS medicinesforlk; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file commit is not required, or is this needed to work with docker image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AmilaJ yes, I'm using it for the MySQL Docker image I'm creating.