Skip to content
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
3 changes: 3 additions & 0 deletions .docker/app.env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
APP_LISTEN_PORT=3000
GOOGLE_OAUTH_CLIENT_ID='YOUR_CLIENT_ID'
GOOGLE_OAUTH_SECRET_ID='YOUR_SECRET_ID'
3 changes: 3 additions & 0 deletions .docker/postgres.env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POSTGRES_USER=invoice_user
POSTGRES_PASSWORD=invoice!@#
POSTGRES_DB=invoice
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Config file
config.local.js
.docker/web.env
.docker/postgres.env

# Library
node_modules/
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM node:7.7

ADD . /var/www/invoice_app

WORKDIR /var/www/invoice_app

EXPOSE 3000

RUN npm install

CMD [npm, start]
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,29 @@ docker run --rm node npm install

## Setup

### Config
### Config & install

Create a config.local.js in the root directory of the project and override or set any value provided by config.js. The minimal contents for the config.local.js file should be:
To configure the whole stack you need to setup the docker compose environments. To handle this just copy the copy
distribution files

```
module.exports = {
APP_LISTEN_PORT: 3000,
GOOGLE_OAUTH_CLIENT_ID: 'YOUR_CLIENT_ID',
GOOGLE_OAUTH_SECRET_ID: 'YOUR_SECRET_ID'
}
cp .docker/app.env.dist .docker/app.env
cp .docker/posgress.env.dist .docker/posgress.env
```


## Run
When you copy you config files and setup all the data in there like google
API credentials you are able to install the application.

```
host$ docker run -it --rm -v ${PWD}:/app -w /app -p 3000:3000 node bash
docker-compose run --rm app npm install
```

This will enter your short time lived container and will allow you to start the application

## Run

To run the stack just perform

```
container$id npm start
docker-compose up -d
```

Now you can open watch your project on [http://localhost:3000/]()
9 changes: 0 additions & 9 deletions config.js

This file was deleted.

26 changes: 26 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: "2"
services:
app:
build: ./
env_file:
- ./.docker/app.env
ports:
- "3000:3000"
volumes:
- .:/var/www/invoice-node-app
working_dir: /var/www/invoice-node-app
command: [npm, run, dev]
db:
image: postgres:9.6.2-alpine
env_file: ./.docker/postgres.env
volumes:
- ./data/invoice-node-app-db:/var/lib/postgresql
ports:
- "5432:5432"
db_test:
image: postgres:9.6.2-alpine
env_file: ./.docker/postgres.env
volumes:
- ./data/invoice-node-app-db-test:/var/lib/postgresql
ports:
- "5433:5432"
11 changes: 5 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
const CONFIG = require('./config.local')
const express = require('express')
const auth = require('./src/login/auth')

const app = express()
const Auth = auth(
app,
CONFIG.GOOGLE_OAUTH_CLIENT_ID,
CONFIG.GOOGLE_OAUTH_SECRET_ID,
`http://localhost:${CONFIG.APP_LISTEN_PORT}`
process.env.GOOGLE_OAUTH_CLIENT_ID,
process.env.GOOGLE_OAUTH_SECRET_ID,
`http://localhost:${process.env.APP_LISTEN_PORT}`
)

app.get('/', (req, res) => res.send('<a href="/auth/google">Sign In with Google</a>'))
Expand All @@ -28,6 +27,6 @@ app.get('/user/profile', function (req, res) {
${JSON.stringify(req.user)}`)
})

app.listen(CONFIG.APP_LISTEN_PORT, function () {
console.log(`X-Team invoice server is running at port ${CONFIG.APP_LISTEN_PORT}!`)
app.listen(process.env.APP_LISTEN_PORT, function () {
console.log(`X-Team invoice server is running at port ${process.env.APP_LISTEN_PORT}!`)
})