Skip to content

Commit

Permalink
Docker support (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
Harin329 authored Aug 30, 2023
1 parent 7fa3a6c commit 6a7070c
Show file tree
Hide file tree
Showing 25 changed files with 191 additions and 62 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ Backend will be exposed on port 3000
2. run `yarn` to install dependencies
3. run `yarn start`

#### Docker Setup
1. run `docker-compose up --build -d`

<!-- DEPLOYMENT -->
## Deployment

Expand Down
7 changes: 7 additions & 0 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:18
WORKDIR /code
COPY package*.json ./
RUN yarn
COPY . .
EXPOSE 8080
CMD ["node", "index.js"]
1 change: 1 addition & 0 deletions database/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/data
4 changes: 4 additions & 0 deletions database/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM --platform=linux/x86_64 mysql:8.0

COPY ./init/* /docker-entrypoint-initdb.d/
COPY ./procedures/* /docker-entrypoint-initdb.d/
23 changes: 23 additions & 0 deletions database/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Initialize_Tables
CALL labby.createForms;
CALL labby.createOrganizations;
CALL labby.createUsers;
CALL labby.createSurveys;
CALL labby.createQuestions;
CALL labby.createQuestions_Answer;
CALL labby.createAnswers;
CALL labby.createAssignment;
CALL labby.createProjects;
CALL labby.createBillable;
CALL labby.createClickAnalytics;
CALL labby.createClinical;
CALL labby.createConditions;
CALL labby.createCostCenters;
CALL labby.createCostCenterAssignments;
CALL labby.createDrafts;
CALL labby.createProjectAssignments;
CALL labby.createQuestions_Cost;
CALL labby.createTasks;
CALL labby.createSubtasks;

CALL addUser('DEMO-USER-1', 'ORG-ID-A', 'Mapcore', '[email protected]', true, 'd7f349eab1e95fa9', '39cb61ac781817affb8d1af5fe4768007e160646af0e8a844db0ae27e0a7263d6182a133347505a442f2672f499e14b51e4830cfcdbe64c9a8a5077cbfd3a831');
16 changes: 0 additions & 16 deletions database/init/init.sql

This file was deleted.

2 changes: 1 addition & 1 deletion database/procedures/assignmentProc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,5 @@ CREATE PROCEDURE `delete_project_cost_centers` (
) BEGIN
DELETE FROM costcenter_assignments WHERE fk_project_id=project_id;
END $$

DELIMITER ;
2 changes: 1 addition & 1 deletion database/procedures/billableProc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -149,5 +149,5 @@ CREATE PROCEDURE `delete_billable` (
BEGIN
DELETE FROM billable WHERE billable_id = id;
END $$

DELIMITER ;
2 changes: 1 addition & 1 deletion database/procedures/costCenterProc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ CREATE PROCEDURE `delete_cost_center` (
BEGIN
DELETE FROM cost_centers WHERE cost_center_id = id;
END $$

DELIMITER ;
30 changes: 15 additions & 15 deletions database/procedures/formCreator/delete-questions.sql
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
USE `labby`;

DROP procedure IF EXISTS `delete_form`;
DROP procedure IF EXISTS `delete_question`;
DROP procedure IF EXISTS `delete_answer`;
DROP procedure IF EXISTS `delete_cost`;
DROP procedure IF EXISTS `delete_organization`;
DROP procedure IF EXISTS `delete_condition`;


DELIMITER $$

CREATE PROCEDURE `delete_form` (
IN id VARCHAR(50)
CREATE PROCEDURE `delete_form` (
IN `id` VARCHAR(50)
)
BEGIN
DELETE FROM forms WHERE form_id = id;
END $$

CREATE PROCEDURE `delete_question` (
IN id VARCHAR(50)
CREATE PROCEDURE `delete_question` (
IN `id` VARCHAR(50)
)
BEGIN
DELETE FROM questions WHERE question_id = id;
END $$

CREATE PROCEDURE `delete_answer` (
IN id VARCHAR(50)
CREATE PROCEDURE `delete_answer` (
IN `id` VARCHAR(50)
)
BEGIN
DELETE FROM questions_answer WHERE answer_id = id;
END $$

CREATE PROCEDURE `delete_cost` (
IN id VARCHAR(50)
CREATE PROCEDURE `delete_cost` (
IN `id` VARCHAR(50)
)
BEGIN
DELETE FROM questions_cost WHERE fk_answer_id = id;
END $$

CREATE PROCEDURE `delete_organization` (
IN id VARCHAR(50)
CREATE PROCEDURE `delete_organization` (
IN `id` VARCHAR(50)
)
BEGIN
DELETE FROM organizations WHERE organization_id = id;
END $$

CREATE PROCEDURE `delete_condition` (
IN id VARCHAR(50)
CREATE PROCEDURE `delete_condition` (
IN `id` VARCHAR(50)
)
BEGIN
DELETE FROM conditions WHERE condition_id = id;
Expand Down
8 changes: 4 additions & 4 deletions database/procedures/formCreator/load-questions.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
USE `labby`;

DROP procedure IF EXISTS `load_forms`;
DROP procedure IF EXISTS `load_published_forms`;
DROP procedure IF EXISTS `load_questions`;
Expand All @@ -8,8 +8,8 @@ DROP procedure IF EXISTS `load_questions_answers`;
DROP procedure IF EXISTS `load_conditions`;
DROP procedure IF EXISTS `load_costs`;
DROP procedure IF EXISTS `load_organization_costs`;


DELIMITER $$

CREATE PROCEDURE `load_forms` ()
Expand Down Expand Up @@ -130,6 +130,6 @@ SELECT question, answer, fk_answer_id, cost
ORDER BY
position_index;
END $$

DELIMITER ;

18 changes: 9 additions & 9 deletions database/procedures/formCreator/save-questions.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
USE `labby`;

DROP procedure IF EXISTS `save_form`;
DROP procedure IF EXISTS `save_answer`;
DROP procedure IF EXISTS `save_cost`;
DROP procedure IF EXISTS `save_condition`;

DELIMITER $$

CREATE PROCEDURE `save_form` (
Expand All @@ -28,15 +28,15 @@ ON DUPLICATE KEY UPDATE
forms.form_name=`_form_name`,
forms.date_created=now(),
forms.published=false;

END $$

CREATE PROCEDURE `save_answer` (
IN `_answer_id` VARCHAR(50),
IN `_answer` TEXT,
IN `_question_type` VARCHAR(50),
IN `_fk_question_id` VARCHAR(50)

) BEGIN INSERT INTO `questions_answer` (
`answer_id`,
`answer`,
Expand All @@ -58,9 +58,9 @@ ON DUPLICATE KEY UPDATE
questions_answer.question_type=`_question_type`,
questions_answer.fk_question_id=`_fk_question_id`,
questions_answer.added_on=now();

END $$

CREATE PROCEDURE `save_cost` (
IN `_cost_id` VARCHAR(50),
IN `_cost` DOUBLE,
Expand Down Expand Up @@ -110,7 +110,7 @@ VALUES
`_condition_type`,
`_condition_parameter`
);

END $$

DELIMITER ;
2 changes: 1 addition & 1 deletion database/procedures/organizationsProc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ CREATE PROCEDURE `delete_organization` (
) BEGIN
DELETE FROM organizations WHERE organization_id=_organization_id;
END $$

DELIMITER ;
2 changes: 1 addition & 1 deletion database/procedures/projectProc.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ CREATE PROCEDURE `delete_project` (
BEGIN
DELETE FROM projects WHERE project_id = id;
END $$

DELIMITER ;
8 changes: 4 additions & 4 deletions database/procedures/questionsCostProc.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
USE `labby`;

DROP procedure IF EXISTS `save_cost_quantifiable`;

DELIMITER $$

CREATE PROCEDURE `save_cost_quantifiable` (
IN `_answer_id` VARCHAR(50),
IN `_quantifiable` BOOLEAN
Expand All @@ -14,5 +14,5 @@ SET `quantifiable` = `_quantifiable`
WHERE `fk_answer_id` = `_answer_id`;

END $$

DELIMITER ;
6 changes: 3 additions & 3 deletions database/procedures/questionsProc.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
USE `labby`;

DROP procedure IF EXISTS `save_question`;

DELIMITER $$

CREATE PROCEDURE `save_question` (
Expand All @@ -14,7 +14,7 @@ CREATE PROCEDURE `save_question` (
IN `_clinical` BOOLEAN,
IN `_question_note` TEXT,
IN `_numerical_only` BOOLEAN

) BEGIN INSERT INTO `questions` (
`question_id`,
`fk_form_id`,
Expand Down Expand Up @@ -48,7 +48,7 @@ ON DUPLICATE KEY UPDATE
questions.clinical=`_clinical`,
questions.question_note=`_question_note`,
questions.numerical_only=`_numerical_only`;

END $$

DELIMITER ;
1 change: 0 additions & 1 deletion database/procedures/surveyProc.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
USE `labby`;

DROP PROCEDURE IF EXISTS `createSurveys`;
DROP PROCEDURE IF EXISTS `addSurvey`;
DROP PROCEDURE IF EXISTS `loadSurveyByUser`;
DROP PROCEDURE IF EXIStS `deleteSurvey`;
Expand Down
2 changes: 1 addition & 1 deletion database/procedures/ticketManagement/deleteProcedures.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
USE `labby`;

DROP procedure IF EXISTS `delete_task`;
DROP procedure IF EXISTS `delete_subtask`;

Expand Down
2 changes: 1 addition & 1 deletion database/procedures/ticketManagement/loadProcedures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ SELECT * FROM subtasks
WHERE subtasks.fk_task_id = `task_id`;

END $$

DELIMITER ;
2 changes: 1 addition & 1 deletion database/procedures/ticketManagement/saveProcedures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,5 @@ UPDATE `subtasks` SET `subtask_state`=`_subtask_state`, `subtask_updated` = NOW(

END $$


DELIMITER ;
53 changes: 53 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
version: "3.9"
services:
client:
build: ./frontend
ports:
- "3000:3000"
depends_on:
- web
web:
build: ./backend
ports:
- "8080:8080"
environment:
MYSQL_PWD: 'Launchpad'
depends_on:
- db
db:
build: ./database
restart: always
command:
--secure_file_priv=''
--local_infile=1
--default-authentication-plugin=mysql_native_password
environment:
MYSQL_DATABASE: 'labby'
MYSQL_USER: 'launchpad'
MYSQL_PASSWORD: 'Launchpad'
MYSQL_ROOT_PASSWORD: 'Launchpad'
TZ: 'America/Los_Angeles'
ports:
- '3306:3306'
expose:
- '3306'
volumes:
- ./database/data:/var/lib/mysql
- ./database/init.sql:/docker-entrypoint-initdb.d/~init.sql
nginx:
build: ./nginx
restart: always
ports:
- 80:80
- 443:443
# volumes:
# - ./certbot/conf:/etc/letsencrypt
# - ./certbot/www:/var/www/certbot
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
# certbot:
# image: certbot/certbot
# restart: always
# volumes:
# - ./certbot/conf:/etc/letsencrypt
# - ./certbot/www:/var/www/certbot
# entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"
7 changes: 7 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:18
WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package*.json ./
RUN yarn
COPY . ./
CMD ["yarn", "start"]
Loading

0 comments on commit 6a7070c

Please sign in to comment.