nfp_sites/.circleci/config.yml

49 lines
1.6 KiB
YAML
Raw Normal View History

2019-09-14 19:03:38 +00:00
version: 2
jobs:
build:
docker:
- image: docker:latest
environment:
- di: "nfpis/nfpmoe"
- dtag: "latest"
- service_name: "nfpmoe"
- target_port: "7030" # The public port
- service_port: "4030" # Container port
working_directory: ~/nfpmoe
steps:
- run:
2019-10-01 03:49:58 +00:00
name: Update and install SSH & Git & sed
command: apk update && apk upgrade && apk add --no-cache bash git openssh sed
2019-09-14 19:03:38 +00:00
- checkout
- setup_remote_docker
2019-10-01 03:45:44 +00:00
- run:
name: Replace version in config
2019-10-01 03:47:25 +00:00
command: |
2019-10-01 03:53:36 +00:00
sed -i "s/circleci_version_number/${CIRCLE_BUILD_NUM}/g" config/config.default.json
2019-09-14 19:03:38 +00:00
- run:
name: Build docker image
command: docker build -t ${di}:build_${CIRCLE_BUILD_NUM} -t ${di}:${CIRCLE_SHA1} -t ${di}:${dtag} .
- run:
name: Push to docker
command: |
docker login -u $DOCKER_USER -p $DOCKER_PASS
docker push ${di}
- deploy:
name: Deploy to production
command: |
if [ "${CIRCLE_BRANCH}" != "master" ]; then
echo Not running on master. Exiting.
exit 0
fi
echo "$MASTER_HOST" | base64 -d > ~/.ssh/master_host
echo "$MASTER_KEY" | base64 -d > ~/.ssh/master_key
chmod 600 ~/.ssh/master_key
ssh -p 51120 -i ~/.ssh/master_key -o "UserKnownHostsFile ~/.ssh/master_host" root@82.221.107.21 "docker ${service_name} ${di}:${CIRCLE_SHA1} ${target_port} ${service_port}"
workflows:
version: 2
build_deploy:
jobs:
- build:
context: org-global