Last active
September 10, 2024 11:55
-
-
Save boudra/c6f354f268aabca9b5e38a514575e28b to your computer and use it in GitHub Desktop.
Using docker-compose for Postgres
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# run this with `docker-compose up -d` | |
db: | |
image: postgres | |
ports: | |
- "5432:5432" | |
environment: | |
- POSTGRES_USER=user | |
- POSTGRES_PASSWORD=pass | |
- POSTGRES_DB=codeworks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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