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

Dockerise application #17

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions .Dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
data
36 changes: 18 additions & 18 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"plugins": [
"source-map-support",
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose" : true }],
["@babel/plugin-proposal-private-methods", { "loose" : true }]
],
"presets": [
"@babel/typescript",
[
"@babel/preset-env",
{
"targets": {
"node": true
}
}
]
]
{
"plugins": [
"source-map-support",
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose" : true }],
["@babel/plugin-proposal-private-methods", { "loose" : true }]
],
"presets": [
"@babel/typescript",
[
"@babel/preset-env",
{
"targets": {
"node": true
}
}
]
]
}
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ GOOGLE_OAUTH_CALLBACK_URL=http://localhost:3000/api/v1/auth/google/callback
JWT_SECRET=[Insert Key here]
ACCESS_TOKEN_TTL=1d
ACCESS_TOKEN_TTL_IN_SEC=86400
REFRESH_TOKEN_TTL_IN_SEC=5184000
REFRESH_TOKEN_TTL_IN_SEC=5184000
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
node_modules
jspm_packages
data/database.sqlite
data/.database.built

# serverless
.serverless
.webpack
.env
.env.local
.env.localdev
.env.localdev.local
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:14.17

WORKDIR /app/

COPY package-lock.json package.json serverless.yml ./

RUN npm i

COPY . .

COPY docker/docker-entrypoint.sh /scripts/docker-entrypoint.sh

RUN chmod 755 /scripts/docker-entrypoint.sh

ENTRYPOINT ["sh", "/scripts/docker-entrypoint.sh"]
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
reset-db:
npm run
import-db:
all: down clean-db build up

clean-db:
npm run db:clean
rm data/.database.built || true

build:
docker-compose build --force mbo_backend

up:
docker-compose up

down:
docker-compose down

import-db:
npm run typeorm schema:sync
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# MBO Backend
This is the backend repository for multiplied by one
This is the backend repository for multiplied by one. The project requires either `docker` + `docker-compose` or node v14 on the host machine.

To get started run
To get started run. (You will need to run this when updating files outside of src / installing new packakges)
```bash
npm i
npm run db:create
npm run start
make all
```

Then to start the running containers run.
```bash
make start
```
18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '3.8'

services:
mbo_backend:
build:
context: .
ports:
- "3000:3000"
container_name: "mbo_backend"
volumes:
- './package.json:/app/package.json'
- './serverless.yml:/app/serverless.yml'
- './package-lock.json:/app/yarn.lock'
- './src/:/app/src/'
- './data/:/app/data/'
- './.env:/app/.env'
- './.env.localdev:/app/.env.localdev'
- './.env.localdev.local:/app/.env.localdev.local'
11 changes: 11 additions & 0 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
cd /app

if [ ! -f /app/data/.database.built ]; then
echo "Creating db..."
npm run db:create
npm run fixtures
touch /app/data/.database.built
fi

npm run start
6 changes: 3 additions & 3 deletions fixtures/EyeAccount.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
entity: EyeAccount
items:
eyeAccount{1..10}:
entity: EyeAccount
items:
eyeAccount{1..10}:
user: '@user{1..5}'
14 changes: 7 additions & 7 deletions fixtures/Eyebox.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
entity: Eyebox
items:
eyeBox{1..10}:
subjectLine: 'Subject Title'
tStamp: '{{date.past}}'
messageBody: '{{lorem.sentence}}'
sender: '@eyeAccount{1..10}'
entity: Eyebox
items:
eyeBox{1..10}:
subjectLine: 'Subject Title'
tStamp: '{{date.past}}'
messageBody: '{{lorem.sentence}}'
sender: '@eyeAccount{1..10}'
receiver: '@eyeAccount{1..10}'
14 changes: 7 additions & 7 deletions fixtures/Headmate.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
entity: Headmate
items:
headmate{1..10}:
hName: ($current)
user: '@user{1..5}'
eyeAccounts:
- '@eyeAccount{1..5}'
entity: Headmate
items:
headmate{1..10}:
hName: ($current)
user: '@user{1..5}'
eyeAccounts:
- '@eyeAccount{1..5}'
- '@eyeAccount{6..10}'
6 changes: 3 additions & 3 deletions fixtures/Journal.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
entity: Journal
items:
journal{1..10}:
entity: Journal
items:
journal{1..10}:
eyeAccount: '@eyeAccount{1..10}'
12 changes: 6 additions & 6 deletions fixtures/JournalEntry.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
entity: JournalEntry
items:
journalEntry{1..10}:
tStamp: '{{date.past}}'
etitle: 'Journal entry title ($current)'
ebody: '{{lorem.text}}'
entity: JournalEntry
items:
journalEntry{1..10}:
tStamp: '{{date.past}}'
etitle: 'Journal entry title ($current)'
ebody: '{{lorem.text}}'
journal: '@journal{1..10}'
8 changes: 4 additions & 4 deletions fixtures/Meeting.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
entity: Meeting
items:
meeting{1..10}:
datetime: '{{date.past}}'
entity: Meeting
items:
meeting{1..10}:
datetime: '{{date.past}}'
meetingSpace: '@meetingSpace{1..10}'
12 changes: 6 additions & 6 deletions fixtures/MeetingEntry.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
entity: MeetingEntry
items:
meetingEntry{1..10}:
meeting: '@meeting{1..10}'
headmate: '@headmate{1..10}'
tStamp: '{{date.past}}'
entity: MeetingEntry
items:
meetingEntry{1..10}:
meeting: '@meeting{1..10}'
headmate: '@headmate{1..10}'
tStamp: '{{date.past}}'
mbody: '{{lorem.text}}'
6 changes: 3 additions & 3 deletions fixtures/MeetingSpace.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
entity: MeetingSpace
items:
meetingSpace{1..10}:
entity: MeetingSpace
items:
meetingSpace{1..10}:
user: '@user{1..5}'
14 changes: 7 additions & 7 deletions fixtures/Reminders.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
entity: Reminders
items:
reminder{1..10}:
assignee: '@user{1..5}'
headmate: '@headmate{1..10}'
time: '{{date.past}}'
message: '{{lorem.sentence}}'
entity: Reminders
items:
reminder{1..10}:
assignee: '@user{1..5}'
headmate: '@headmate{1..10}'
time: '{{date.past}}'
message: '{{lorem.sentence}}'
completion: false
8 changes: 4 additions & 4 deletions fixtures/User.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
entity: User
items:
user{1..5}:
googleAccountId: ($current*100000)
entity: User
items:
user{1..5}:
googleAccountId: ($current*100000)
emailAddress: '{{internet.email}}'
Loading