Skip to content

Commit

Permalink
feat: configure production deploy docker
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-roque committed Feb 1, 2020
1 parent ce6b4d1 commit c17131c
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ HOST=0.0.0.0
PORT=8080
NODE_ENV=development

APP_NAME=StarWarsBattle
APP_NAME=ReactDonisDockerStarter
APP_URL=http://${HOST}:${PORT}

CACHE_VIEWS=false
Expand Down
1 change: 1 addition & 0 deletions docker-compose.example → docker-compose.dev.example
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
- ./database/docker-data/postgres:/var/lib/postgresql/data
# - ./database/schema.sql:/docker-entrypoint-initdb.d/0.schema.sql
#- ./database/initial-data.sql:/docker-entrypoint-initdb.d/1.data.sql

api-service:
build:
context: ./api
Expand Down
46 changes: 46 additions & 0 deletions docker-compose.prod.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: "3"

services:
web:
image: nginx:latest
container_name: web-nginx
ports:
- "80:80"
volumes:
- ./web-app/build:/var/www/html
- ./ngnix/config/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- api-service

database-service:
image: postgres:10
container_name: app-database
environment:
- POSTGRES_DB=adonis_db
- POSTGRES_DB_TEST=adonis_db_teste
- POSTGRES_USER=adonis_usr
- POSTGRES_PASSWORD=123456
ports:
- "5432:5432"
expose:
- "5432"
volumes:
- ./database/docker-data/postgres:/var/lib/postgresql/data
# - ./database/schema.sql:/docker-entrypoint-initdb.d/0.schema.sql
#- ./database/initial-data.sql:/docker-entrypoint-initdb.d/1.data.sql

api-service:
build:
context: ./api
dockerfile: Dockerfile
container_name: app-api
volumes:
- ./api:/api
command: sh -c "npm start"
ports:
- "8080:8080"
environment:
- DB_HOST=app-database
- DB_PORT=5432
depends_on:
- database-service
4 changes: 2 additions & 2 deletions entrypoint.sh → entrypoint-dev.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
echo "************* [DEVOLVA JÁ] *************"
echo "************* [REACT-DONIS-STARTER] *************"

echo "****** [CHANGELOG CONVENTION] ****** [CONFIGURING PROJECT] ******"
echo "\n"
Expand All @@ -25,6 +25,6 @@ cd ..
echo "****** [DOCKER] ****** [CONFIGURING PROJECT] ******"
echo "\n"

cp docker-compose.example docker-compose.yml
cp docker-compose.dev.example docker-compose.yml

docker-compose up
31 changes: 31 additions & 0 deletions entrypoint-prod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
echo "************* [REACT-DONIS-STARTER] *************"

echo "****** [CHANGELOG CONVENTION] ****** [CONFIGURING PROJECT] ******"
echo "\n"
npm install


echo "****** [API DEPEDENCES] ****** [CONFIGURING PROJECT] ******"
echo "\n"

cd ./api
cp .env.example .env
adonis key:generate
npm install
cd ..


echo "****** [WEB-APP DEPEDENCES] ****** [CONFIGURING PROJECT] ******"
echo "\n"
cd ./web-app
npm install
npm run build
cd ..


echo "****** [DOCKER] ****** [CONFIGURING PROJECT] ******"
echo "\n"

cp docker-compose.prod.example docker-compose.yml

docker-compose up
12 changes: 12 additions & 0 deletions ngnix/config/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
server {
listen 80;
index index.html;
server_name localhost;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html;

location / {
try_files $uri /index.html =404;
}
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c17131c

Please sign in to comment.