Skip to content

Instantly share code, notes, and snippets.

@boudra
Last active September 10, 2024 11:55
Show Gist options
  • Save boudra/c6f354f268aabca9b5e38a514575e28b to your computer and use it in GitHub Desktop.
Save boudra/c6f354f268aabca9b5e38a514575e28b to your computer and use it in GitHub Desktop.
Using docker-compose for Postgres
const Sequelize = require("sequelize");
const sequelize = new Sequelize("postgres://user:pass@localhost:5432/codeworks");
sequelize.authenticate().then(() => {
console.log("connected to database");
}).catch(() => {
console.error("failed to connect to database");
})
# run this with `docker-compose up -d`
db:
image: postgres
ports:
- "5432:5432"
environment:
- POSTGRES_USER=user
- POSTGRES_PASSWORD=pass
- POSTGRES_DB=codeworks
# put this filein the Github Workflows dir: `.github/workflows/push.yml`
name: Node.js CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Build the docker-compose stack
run: docker-compose up -d
- run: npm ci
- run: npm run build --if-present
- run: npm run lint
- run: npm test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment