Skip to content

Instantly share code, notes, and snippets.

@vitalbone
Last active October 14, 2019 23:08
Show Gist options
  • Save vitalbone/811e9358a2d93203c9b5b2ca46c831e7 to your computer and use it in GitHub Desktop.
Save vitalbone/811e9358a2d93203c9b5b2ca46c831e7 to your computer and use it in GitHub Desktop.
Node + Postgres = CircleCI config
version: 2
jobs:
build:
docker:
- image: circleci/node:latest
environment:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/db_name
POSTGRES_USER: postgres
POSTGRES_DB: db_name
- image: circleci/postgres:10
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: yarn install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
# Download psql client
- run: sudo apt-get install postgresql-client -y
# Avoid db race conditions with Dockerize
- run: dockerize -wait tcp://localhost:5432 -timeout 1m
# Create 'mmp_test' database
- run: psql -U postgres -h localhost -p 5432 -c "create database db_name;"
- run: yarn lint
- run: yarn build
- run: yarn test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment