Skip to content
Open
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
12 changes: 6 additions & 6 deletions Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies-toml-version = "2"
[[package]]
org = "ballerina"
name = "auth"
version = "2.2.1"
version = "2.3.1"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "jballerina.java"},
Expand Down Expand Up @@ -41,7 +41,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "file"
version = "1.2.2"
version = "1.3.0"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
Expand All @@ -54,7 +54,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "http"
version = "2.2.2"
version = "2.3.0"
dependencies = [
{org = "ballerina", name = "auth"},
{org = "ballerina", name = "cache"},
Expand Down Expand Up @@ -101,7 +101,7 @@ version = "0.0.0"
[[package]]
org = "ballerina"
name = "jwt"
version = "2.2.1"
version = "2.3.1"
dependencies = [
{org = "ballerina", name = "cache"},
{org = "ballerina", name = "crypto"},
Expand Down Expand Up @@ -214,7 +214,7 @@ modules = [
[[package]]
org = "ballerina"
name = "oauth2"
version = "2.2.1"
version = "2.3.1"
dependencies = [
{org = "ballerina", name = "cache"},
{org = "ballerina", name = "crypto"},
Expand All @@ -234,7 +234,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "os"
version = "1.2.1"
version = "1.3.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile
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"]
16 changes: 16 additions & 0 deletions README.md
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
8 changes: 4 additions & 4 deletions config.bal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
configurable string dbHost = "dbHost";
configurable string dbHost = "medicinesforlk-mysql";
Copy link
Collaborator

@AmilaJ AmilaJ Jul 23, 2022

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?

Copy link
Collaborator Author

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.

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";
44 changes: 44 additions & 0 deletions docker-compose.yml
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
1 change: 1 addition & 0 deletions mysql-scripts/create-database.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE DATABASE IF NOT EXISTS medicinesforlk;
2 changes: 2 additions & 0 deletions mysql-scripts/creation-ddl.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
USE medicinesforlk;

CREATE TABLE IF NOT EXISTS SUPPLIER (
SUPPLIERID INT NOT NULL AUTO_INCREMENT,
`NAME` VARCHAR (255) NOT NULL,
Expand Down