Skip to content

Commit

Permalink
Merge pull request #1 from ergomake/setup-ergomake
Browse files Browse the repository at this point in the history
setup ergomake
  • Loading branch information
lucasfcosta authored Jan 26, 2023
2 parents a2871d4 + c0ee9bf commit b1bf27c
Show file tree
Hide file tree
Showing 7 changed files with 229 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.git
27 changes: 27 additions & 0 deletions .ergomake/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: '3.1'

services:
app:
build:
context: ..
environment:
DB_USER: exampleUserName
DB_PASSWORD: examplePassword
DB_DATABASE: exampleDB
DB_HOST: "db"
PORT: "3000"
JWT_KEY: "exampleSecretKey"
ports:
- "3000:3000"
depends_on:
- db

db:
image: postgres
environment:
POSTGRES_USER: exampleUserName
POSTGRES_PASSWORD: examplePassword
POSTGRES_DB: exampleDB
ports:
- "5432:5432"

12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:16

WORKDIR /usr/src/app

COPY . .

RUN npm install
RUN npm run build -w frontend

EXPOSE 3001

CMD ["npm", "run", "start", "-w", "backend"]
16 changes: 5 additions & 11 deletions backend/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
username: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
host: "127.0.0.1",
host: process.env.DB_HOST ?? "127.0.0.1",
dialect: "postgres",
},
test: {
Expand All @@ -14,16 +14,10 @@ module.exports = {
dialect: "mysql",
},
production: {
username: process.env.PG_USER,
password: process.env.PG_PASSWORD,
database: process.env.PG_DATABASE,
host: process.env.PG_HOST,
username: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
host: process.env.DB_HOST ?? "127.0.0.1",
dialect: "postgres",
dialectOptions: {
ssl: {
require: true,
rejectUnauthorized: false,
},
},
},
};
1 change: 1 addition & 0 deletions backend/models/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const env = process.env.NODE_ENV || "development";
const config = require(__dirname + "/../config/config.js")[env];
const db = {};

console.log(JSON.stringify(config,null,2))
let sequelize;
if (config.use_env_variable) {
sequelize = new Sequelize(process.env[config.use_env_variable], config);
Expand Down
5 changes: 3 additions & 2 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "NODE_ENV=production node index.js",
"start": "wait-on tcp:db:5432 && NODE_ENV=production node index.js",
"dev": "NODE_ENV=development nodemon index.js",
"test": "jest"
},
Expand All @@ -17,7 +17,8 @@
"express": "^4.17.2",
"jsonwebtoken": "^8.5.1",
"pg": "^8.7.3",
"sequelize": "^6.14.1"
"sequelize": "^6.14.1",
"wait-on": "7.0.1"
},
"devDependencies": {
"jest": "^28.1.3",
Expand Down
196 changes: 179 additions & 17 deletions package-lock.json

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

0 comments on commit b1bf27c

Please sign in to comment.