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

#13 Enhancement/add docker support #42

Open
wants to merge 6 commits into
base: integ
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
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
data/
dockerfile

6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
Expand Down Expand Up @@ -116,4 +114,6 @@ dist
.pnp.*

uploads/
temp/
temp/
#Volumes
data/
28 changes: 28 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
version: '3'
services:
db:
image: mysql
environment:
MYSQL_USER: 'root'
MYSQL_ROOT_PASSWORD: 'root'
MYSQL_DATABASE: 'bonafide'
ports:
- '3305:3306'
cap_add:
- SYS_NICE
#can uncomment to persist data
# volumes:
# - ./data/:/var/lib/mysql

portal:
build: ./
ports:
- '3000:3000'
- '3001:3001'
depends_on:
- db
stdin_open: true
# can uncomment volumes if changes to be reflected without rebuilding image
# volumes:
# - ./:/usr/src/app

6 changes: 6 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node
WORKDIR /usr/src/app
COPY . .
# to prevent seeding give no arguments
ENTRYPOINT ["./start.sh","seed"]

7 changes: 6 additions & 1 deletion env/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
DB_HOST=localhost

#docker
#DB_HOST=db
#DB_PASS=root

DB_USER=root
DB_PASS=your_pass_here
DB_NAME=bonafide
Expand All @@ -15,4 +20,4 @@ JWT_SECRET=secret_key

[email protected]
PASS=yourpassword
SENDGRID_API_KEY=<your api key>
SENDGRID_API_KEY=<your api key>
25 changes: 25 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
echo "waiting for mysql to be setup"

while :
do
(echo -n > /dev/tcp/localhost/3306) > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "Mysql setup completed setting up web app"
npm i
npm i -g pm2
if [ "$1" = "seed" ]
then
cd database
node seed.js
cd ..
fi
./deploy.sh deploy
cd public/
npm i
npm start
break
fi
sleep 1
done