Last active
August 30, 2017 16:23
-
-
Save iynere/052a76d986545abf6949ad0641f42f92 to your computer and use it in GitHub Desktop.
shyp Dockerfile https://hub.docker.com/r/iynere/shyp
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
version: 2 | |
jobs: | |
build: | |
docker: | |
- image: iynere/shyp:v1-node-psql | |
environment: | |
NODE_ENV: test | |
PATH: "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/home/circleci/shyp_api/node_modules/.bin" | |
PGHOST: 127.0.0.1 | |
CIRCLE_TEST_REPORTS: test_reports | |
CIRCLE_ARTIFACTS: artifacts | |
JUNIT_REPORT_STACK: 1 | |
- image: circleci/postgres:9.4-ram | |
working_directory: ~/shyp_api | |
parallelism: 4 | |
steps: | |
# Putting whole command here so it can run before code is checked out. | |
# Relying on `$SLACK_POST_URL` to be set in Circle's env. | |
- run: | |
name: slack thing | |
working_directory: ~ | |
command: 'if [[ "$CIRCLE_BRANCH" == "master" ]]; then curl -X POST --data "payload={\"channel\": \"#platform\", \"text\": \"Running production build - $CIRCLE_BUILD_URL - $CIRCLE_COMPARE_URL\"}" "$SLACK_POST_URL"; fi' | |
- restore_cache: | |
key: shyp_api-source-v1-{{ .Branch }}-{{ .Revision }} | |
keys: | |
- shyp_api-source-v1-{{ .Branch }}- | |
- shyp_api-source-v1- | |
- checkout | |
- save_cache: | |
key: shyp_api-source-v1-{{ .Branch }}-{{ .Revision }} | |
paths: | |
- ".git" | |
- run: | |
name: clear node modules, npm cache | |
command: | | |
rm -rf node_modules | |
rm -rf .cache-require-paths.json | |
npm cache clean | |
- restore_cache: | |
key: shyp_api-yarn-v1-{{ checksum "yarn.lock" }} | |
- restore_cache: | |
key: shyp_api-node-v1-{{ checksum "package.json" }} | |
- run: | |
name: yarn install | |
command: | | |
yarn install --ignore-engines | |
cd node_modules/supertest && yarn install --force | |
- save_cache: | |
key: shyp_api-yarn-v1-{{ checksum "yarn.lock" }} | |
paths: | |
- ~/.cache/yarn | |
- save_cache: | |
key: shyp_api-node-v1-{{ checksum "package.json" }} | |
paths: | |
- node_modules | |
- run: | |
name: develop schema | |
command: | | |
psql --dbname=circle_test --username=root --file "schemas/develop.schema.sql" | |
- run: mkdir -p $CIRCLE_TEST_REPORTS/mocha | |
- run: mkdir -p node_modules/istanbul/lib/assets/vendor | |
- run: | |
name: pre-test stuff | |
command: | | |
make lint | |
./bin/compile-docs | |
- run: | |
name: change username for connecting to postgres | |
command: sed -i 's/ubuntu/root/g' api/config/connections.js | |
- run: | |
name: tests | |
command: | | |
./bin/circle-test \ | |
$(circleci tests glob "test/**/*.test.js" "test/**/*.test.coffee" | circleci tests split --split-by=timings) | |
# # not using configure-database.sh script currently, since postgres is in its own container | |
# postgres logging is not currently set up on the postgres container | |
# sudo sh -c "cp -r /var/lib/postgresql/9.4/main/pg_log/*.log $CIRCLE_ARTIFACTS" | |
- run: | |
name: test data | |
command: | | |
./node_modules/.bin/istanbul report | |
- run: | |
name: coverage reports | |
command: | | |
cp -r coverage $CIRCLE_ARTIFACTS | |
- run: | |
name: pre-deploy | |
command: | | |
make check-heroku-status | |
# IMPT: if docs fail, build can be red, even if it already deployed | |
# environment is saved to a file on compile, which determines which repo it publishes to | |
- run: | |
name: deployment for production | |
command: | | |
if [ "${CIRCLE_BRANCH}" == "master" ]; then | |
./bin/push-deployment | |
./bin/compile-docs | |
./bin/publish-docs | |
./bin/circle-trigger-worker-build | |
fi | |
environment: | |
DOCS_ENVIRONMENT: production | |
# IMPT: if docs fail, build can be red, even if it already deployed | |
- run: | |
name: deployment for integration | |
command: | | |
if [ "${CIRCLE_BRANCH}" == "develop" ]; then | |
git push [email protected]:shyp-api-int.git develop:master | |
./bin/compile-docs | |
./bin/publish-docs | |
./bin/circle-trigger-worker-build | |
fi | |
environment: | |
DOCS_ENVIRONMENT: integration | |
- store_test_results: | |
path: test_reports/mocha | |
- store_artifacts: | |
path: artifacts |
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
FROM circleci/node:6.11.1 | |
USER root | |
RUN echo "DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=14.04\nDISTRIB_CODENAME=trusty\nDISTRIB_DESCRIPTION=\"Ubuntu 14.04.4 LTS\"" > /etc/lsb-release | |
USER circleci |
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
FROM circleci/node:6.11.1 | |
USER root | |
RUN echo "DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=14.04\nDISTRIB_CODENAME=trusty\nDISTRIB_DESCRIPTION=\"Ubuntu 14.04.4 LTS\"" > /etc/lsb-release | |
RUN apt-get update | |
RUN apt-get install postgresql-9.4 | |
RUN echo "local all all trust\nhost all all 127.0.0.1/32 trust\nhost all all ::1/128 trust\n# To allow for Docker connections\nhost all all 0.0.0.0/0 trust" > /etc/postgresql/9.4/main/pg_hba.conf | |
RUN sed -i "s/port = ..../port = 5432/g" /etc/postgresql/9.4/main/postgresql.conf | |
USER circleci |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment