diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c212cdc --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +node_modules/ +data/ +dockerfile + diff --git a/.gitignore b/.gitignore index 72f5330..0fefe32 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -# Logs -logs *.log npm-debug.log* yarn-debug.log* @@ -116,4 +114,6 @@ dist .pnp.* uploads/ -temp/ \ No newline at end of file +temp/ +#Volumes +data/ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100755 index 0000000..8786202 --- /dev/null +++ b/docker-compose.yml @@ -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 + diff --git a/dockerfile b/dockerfile new file mode 100755 index 0000000..55bc9af --- /dev/null +++ b/dockerfile @@ -0,0 +1,6 @@ +FROM node +WORKDIR /usr/src/app +COPY . . +# to prevent seeding give no arguments +ENTRYPOINT ["./start.sh","seed"] + diff --git a/env/.env.example b/env/.env.example index 87f9c15..f3f5345 100644 --- a/env/.env.example +++ b/env/.env.example @@ -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 @@ -15,4 +20,4 @@ JWT_SECRET=secret_key EMAIL=youremail@gmail.com PASS=yourpassword -SENDGRID_API_KEY= \ No newline at end of file +SENDGRID_API_KEY= diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..2538e88 --- /dev/null +++ b/start.sh @@ -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 \ No newline at end of file