Last active
February 20, 2019 13:52
-
-
Save jeckel/ce0617381ffbd208b9d9a78134b6244f to your computer and use it in GitHub Desktop.
Loopback CircleCI Sample
This file contains 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
version: 2 | |
jobs: | |
# Run tests | |
test: | |
working_directory: ~/novi | |
docker: | |
- image: circleci/node:10 | |
- image: postgres:alpine | |
environment: | |
POSTGRES_USER: root | |
POSTGRES_DB: loopback_test | |
environment: | |
DATABASE_URL: 'pgsql://root:@127.0.0.1:5432/loopback_test' | |
steps: | |
- checkout | |
- run: | |
name: prepare database | |
command: | | |
sudo apt-get install postgresql-client | |
psql -h 127.0.0.1 -U root loopback_test < devops/docker/sql/0-structure.sql | |
psql -h 127.0.0.1 -U root loopback_test < devops/docker/sql/1-data.sql | |
- restore_cache: | |
key: dependency-cache-{{ checksum "package.json" }} | |
- run: | |
name: install-npm | |
command: npm install | |
- save_cache: | |
key: dependency-cache-{{ checksum "package.json" }} | |
paths: | |
- ./node_modules | |
- run: | |
name: seed database | |
command: npm run build && npm run seed | |
- run: | |
name: test | |
command: npm run test | |
environment: | |
HOST: '127.0.0.1' | |
PORT: '3000' | |
# Deploy the image | |
deploy: | |
docker: | |
- image: docker | |
environment: | |
APP_NAME: app_name | |
steps: | |
- checkout | |
- run: | |
name: Build production docker image | |
command: docker build --rm=false -t registry.heroku.com/${APP_NAME}/web:latest -f ./devops/docker/prod/Dockerfile | |
- run: | |
name: Push image to heroku | |
command: | | |
docker login --email=${HEROKU_LOGIN} --username=${HEROKU_LOGIN} --password=${HEROKU_API_KEY} registry.heroku.com | |
docker push registry.heroku.com/${APP_NAME}/web:latest | |
# Define the workflow | |
workflows: | |
version: 2 | |
test-build: | |
jobs: | |
- test | |
- deploy: | |
filters: | |
branches: | |
only: | |
- master | |
tags: | |
only: /^v[0-9]+(\.[0-9]+)*$/ | |
requires: | |
- test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment