Skip to content

Instantly share code, notes, and snippets.

@coderdiaz
Last active May 4, 2020 03:45
Show Gist options
  • Save coderdiaz/99c43488ba2677937d99cc9679d25a0e to your computer and use it in GitHub Desktop.
Save coderdiaz/99c43488ba2677937d99cc9679d25a0e to your computer and use it in GitHub Desktop.
version: "3.5"
services:
nest:
container_name: nest-api
build:
context: .
target: development
command: npm run start:dev
env_file:
- .env
ports:
- 3000:3000
volumes:
- .:/usr/src/app
- /usr/src/app/node_modules
depends_on:
- postgres
postgres:
container_name: pg
image: postgres:9.6.15
environment:
PGDATA: /var/lib/postgresql/data/pgdata
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
volumes:
- ./docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
- ./pgdata:/var/lib/postgresql/data
ports:
- 5432:5432
networks:
default:
name: webapp
FROM node:12.16.1 As development
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install --only=development
COPY . .
RUN npm run build
const ENV = process.env.NODE_ENV || 'development';
const defaultConfig = {
type: 'postgres',
host: 'postgres',
username: 'postgres',
password: 'postgres',
database: 'roomates-dev',
migrationsRun: true,
entities: ['dist/**/*.entity.{ts,js}'],
migrations: ['dist/migrations/*.{ts,js}'],
cli: {
migrationsDir: 'src/migrations'
},
};
// TypeORM config for production
if (ENV === 'production') {
module.exports = Object.assign(defaultConfig, {
host: process.env.POSTGRES_HOST,
username: process.env.POSTGRES_USER,
password: process.env.POSTGRES_PASSWORD,
database: process.env.POSTGRES_DATABASE,
migrationsRun: false,
});
}
// TypeORM config for development
if (ENV === 'development') {
module.exports = defaultConfig;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment