diff --git a/Dockerfile b/Dockerfile index e312007ca..178abf22a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,13 @@ FROM node:0.10-slim +ARG test + +RUN echo $test + RUN npm install -g mocha RUN npm install -g istanbul RUN npm install -g gulp +RUN pwd COPY ./package.json /src/package.json RUN cd /src && npm install diff --git a/Dockerfile1 b/Dockerfile1 new file mode 100644 index 000000000..67fd37901 --- /dev/null +++ b/Dockerfile1 @@ -0,0 +1 @@ +FROM alpine diff --git a/Dockerfile2 b/Dockerfile2 new file mode 100644 index 000000000..67fd37901 --- /dev/null +++ b/Dockerfile2 @@ -0,0 +1 @@ +FROM alpine diff --git a/Dockerfile_prod b/Dockerfile_prod index 49e3ae6a7..9ffcfe621 100644 --- a/Dockerfile_prod +++ b/Dockerfile_prod @@ -1,5 +1,8 @@ FROM node:0.10-slim +ARG DIRNAME=defaultdir +RUN mkdir /home/$DIRNAME + COPY ./package.json /src/package.json RUN cd /src && npm install COPY ./ /src diff --git a/README.md b/README.md index 08b6b7b16..9583f9a0b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![Codefresh build status]( https://g-staging.codefresh.io/api/badges/build?branch=master&repoName=demochat&repoOwner=containers101&pipelineName=demochat&accountName=verchol )]( https://g-staging.codefresh.io/repositories/containers101/demochat/builds?filter=trigger:build ) - +12ssa ![Let's Chat Greylock](http://i.imgur.com/0a3l5VF.png) ![Screenshot](http://i.imgur.com/C4uMD67.png) A self-hosted chat app for small teams or big Gal by [Security Compass][seccom]. @@ -8,6 +8,7 @@ A self-hosted chat app for small teams or big Gal by [Security Compass][seccom]. [![Dependency Status](https://david-dm.org/sdelements/lets-chat.svg)](https://david-dm.org/sdelements/lets-chat) [![devDependency Status](https://david-dm.org/sdelements/lets-chat/dev-status.svg)](https://david-dm.org/sdelements/lets-chat#info=devDependencies) +f ## Features and Stuff diff --git a/bad-codefresh.yaml b/bad-codefresh.yaml new file mode 100644 index 000000000..fc9e56dad --- /dev/null +++ b/bad-codefresh.yaml @@ -0,0 +1,6 @@ +version: '1.0' +steps: + test: + image: alpine + commands: + - pwd diff --git a/codefresh-tivix.yaml b/codefresh-tivix.yaml new file mode 100644 index 000000000..b13a30ad4 --- /dev/null +++ b/codefresh-tivix.yaml @@ -0,0 +1,73 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: pd-backend + labels: + app: pd-backend + +spec: + replicas: 1 + selector: + matchLabels: + app: pd-backend-container + template: + metadata: + labels: + app: pd-backend-container + + spec: + imagePullSecrets: + - name: codefresh-generated-r.cfcr.io-cfcr-staging + + containers: + - name: django + image: r.cfcr.io/zoetis/zoetis/petdialog-backend:develop + imagePullPolicy: Always + command: ["bash"] + args: ["-c", "uwsgi --ini /code/petdialog_web/uwsgi.ini"] + ports: + - containerPort: 8000 + env: + - name: UWSGI_PORT + value: "8000" + - name: UWSGI_PROCESSES + value: "4" + - name: UWSGI_THREADS_USE + value: "true" + - name: UWSGI_THREADS + value: "2" + - name: UWSGI_THREADS_OFFLOAD + value: "2" + - name: UWSGI_HARAKIRI_COUNT + value: "60" + + - name: DJANGO_ALLOWED_HOST + value: 'petdialog.cdi-stage.com' + - name: ENV + value: staging + + - name: POSTGRES_USER + value: petdialog3_1 + - name: POSTGRES_DB + value: petdialog + - name: POSTGRES_HOST + value: pd-stage-k8s-vpc.cdrzinh1897o.eu-west-1.rds.amazonaws.com + + - name: REDIS_URL + value: pd-redis-service + + - name: ELASTIC_APM_APP_NAME + value: petdialog-staging-k8s + - name: ELASTIC_APM_SECRET_TOKEN + valueFrom: + secretKeyRef: + name: elastic-apm-secret-token + key: password + - name: ELASTIC_APM_SERVER_URL + value: https://elk.cdi-stage.com:8200 + + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: postgres-credentials + key: password diff --git a/codefresh.yml b/codefresh.yml index 982009f1b..acbb444ce 100644 --- a/codefresh.yml +++ b/codefresh.yml @@ -10,13 +10,13 @@ steps: unit_tests: title: Unit Tests - image: ${{build_step}} + image: ${{build_step}} fail_fast: false #working-directory : ${{initial-clone}} commands: #- npm install #- npm install -g gulp - - npm test + - npm test push_to_registry: title: Push To Registry diff --git a/compose.yml b/compose.yml new file mode 100644 index 000000000..6026b3131 --- /dev/null +++ b/compose.yml @@ -0,0 +1,9 @@ +version: '2' +services: + elasticsearch: + image: 'elasticsearch:5.1-alpine' + datasets: + image: 'circleci/postgres:9.6-alpine' + command: ls -la /amir + volumes: + - '/var/lib/docker/volumes/${{CF_VOLUME}}/_data/${{CF_REPO_NAME}}/extras/emotes/:/amir' diff --git a/dockerfile_test b/dockerfile_test new file mode 100644 index 000000000..ba5184e52 --- /dev/null +++ b/dockerfile_test @@ -0,0 +1,5 @@ +ARG owner=default +ARG image=default +ARG tag=default + +FROM $owner/$image:$tag diff --git a/multistage_Dockerfile b/multistage_Dockerfile new file mode 100644 index 000000000..95ce12a45 --- /dev/null +++ b/multistage_Dockerfile @@ -0,0 +1,9 @@ +FROM alpine AS base +RUN echo hoy +ARG TEST_ARG +RUN echo hi +FROM base AS dependencies +RUN echo hi stage 2 +FROM base +COPY --from=dependencies /tmp /tmp2 +RUN echo test diff --git a/pip.yaml b/pip.yaml new file mode 100644 index 000000000..5e1e77884 --- /dev/null +++ b/pip.yaml @@ -0,0 +1,283 @@ +version: '1.0' +stages: + - build + - publish + - deploy +steps: + main_clone: + stage: build + type: git-clone + title: Cloning Git Repo + git: CF-default + repo: ${{CF_REPO_OWNER}}/${{CF_REPO_NAME}} + revision: ${{CF_REVISION}} + + + build_image_sdk: + stage: build + type: build + title: Docker build & pack sdk image + dockerfile: Dockerfile + description: Building code... + working_directory: ${{main_clone}} + image_name: broadvoice/messaging.api + tag: 'sdk-${{CF_SHORT_REVISION}}' + metadata: + set: + - git_repo: '${{CF_REPO_NAME}}' + - git_branch: '${{CF_BRANCH}}' + - git_link: '${{CF_COMMIT_URL}}' + - git_author: '${{CF_COMMIT_AUTHOR}}' + - git_commit_message: '${{CF_COMMIT_MESSAGE}}' + - tag: 'sdk-${{CF_SHORT_REVISION}}' + build_arguments: + - BRANCH=${{CF_BRANCH}} + - COMMIT=${{CF_REVISION}} + - ASPNETCORE_ENVIRONMENT=${{ASPNETCORE_ENVIRONMENT}} + when: + branch: + only: + - master + - develop + - /^feature\/.*/i + - /^bug\/.*/i + - /^release\/.*/i + - /^hotfix\/.*/i + #ignore: [ 'feature/BC-1667' ] + + compose_test: + stage: build + type: composition + title: Use Docker Compose to run XUnit Tests + working_directory: ./test + description: Running tests... + when: + condition: + all: + releaseMatch: 'match("${{CF_BRANCH}}", "^(develop$|feature|bug|release|hotfix)", true) == true' + notSkipTest: 'match("${{CF_COMMIT_MESSAGE}}", "skip\b*([x]?unit\b*|)test", true) == false' + notMultiTest: 'match("${{CF_BRANCH}}", "BC-1667", true) == false' + composition: + version: '3' + services: + # cassandra 1 + scylla-node-1: + image: "broadvoice/scyllacluster:latest" + ports: + - 7000 + - 10000 + - 9160 + - 9042 + volumes: + - ${{CF_VOLUME}}:/codefresh/volume + environment: + - PROJECTNAME=${{CF_REPO_NAME}} + - MEMORY=512M + logging: + driver: none + # cassandra 2 + scylla-node-2: + image: "broadvoice/scyllacluster:latest" + ports: + - 7000 + - 10000 + - 9160 + - 9042 + links: + - scylla-node-1 + depends_on: + - scylla-node-1 + environment: + - PRIMARY_NODE=scylla-node-1 + - MEMORY=512M + logging: + driver: none + # elastic search 1 + es: + image: broadvoice/ci-elasticsearch:latest + user: elasticsearch + ports: + - 9200 + - 9300 + environment: + - 'discovery.type=single-node' + - 'xpack.security.enabled=false' + - 'ES_JAVA_OPTS=-Xms300m -Xmx300m' + - 'CEREBRO_VER=' + logging: + driver: none + # redis 1 + redis: + image: redis:4-alpine + ports: + - 6379 + logging: + driver: none + # rmq 1 + rmq-1: + image: 'broadvoice/ci-messaging-rmq:latest' + ports: + - 5672 + - 15672 + logging: + driver: none + # asp.net code + api: + image: ${{build_image_sdk}} + environment: + - 'ASPNETCORE_URLS=http://*:80' + - 'APPLICATION_NAME=Broadvoice.Messaging.API' + working_dir: /src + entrypoint: ./codefresh-integration-test-entry.sh + ports: + - 80 + depends_on: + - scylla-node-1 + - scylla-node-2 + - es + - redis + - rmq-1 + links: + - scylla-node-1 + - scylla-node-2 + - es + - redis + - rmq-1 + volumes: + ${{CF_VOLUME}}: + external: true + composition_candidates: + api: + image: ${{build_image_sdk}} + environment: + - 'TESTCONSOLE=Off' + - 'ELASTICSEARCH__CONNECTIONSTRING=Hosts=es:9200' + - 'CASSANDRASETTINGS__CONNECTIONSTRING=Contact Points=scylla-node-1,scylla-node-2;Port=9042;UseStreamMode=true;KeepAlive=true;MaxSchemaAgreementWaitSeconds=100000;ReuseAddress=true;ConnectTimeoutMillis=180000;QueryTimeoutMillis=180000;ReadTimeoutMillis=180000' + - 'REDISCONNECTIONFACTORY__CONNECTIONSTRING=redis:6379,syncTimeout=2500,connectTimeout=8000,configCheckSeconds=15' + - 'RABBITMQCONNECTION__CONNECTIONSTRING=amqp://guest:guest@rmq-1:5672/' + - 'CONST__PROXYURL=${{CONST_BASEURL}}' + + copy_sdk_artifacts: + stage: build + title: Share Sdk Artifacts + description: Copy artifacts from build sdk step + image: ${{build_image_sdk}} + working_directory: ${{main_clone}} + when: + branch: + only: + - develop + - /^feature\/.*/i + - /^bug\/.*/i + - /^release\/.*/i + - /^hotfix\/.*/i + commands: + - mkdir -p /codefresh/volume/broadvoice.messaging/publish + - echo 'Publish content:' + - cp -r /Broadvoice/Messaging.API/publish/* /codefresh/volume/broadvoice.messaging/publish + - ls /codefresh/volume/broadvoice.messaging/publish + - echo 'Copied publish files!!!' + + build_runtime_image: + stage: build + type: build + title: Docker build & pack runtime image + dockerfile: Dockerfile.Runtime.Dockerfile + description: Building Runtime Image + working_directory: ${{main_clone}} + image_name: broadvoice/messaging.api + tag: 'runtime-${{CF_SHORT_REVISION}}' + metadata: + set: + - git_repo: '${{CF_REPO_NAME}}' + - git_branch: '${{CF_BRANCH}}' + - git_link: '${{CF_COMMIT_URL}}' + - git_author: '${{CF_COMMIT_AUTHOR}}' + - git_commit_message: '${{CF_COMMIT_MESSAGE}}' + - tag: 'runtime-${{CF_SHORT_REVISION}}' + build_arguments: + - BRANCH=${{CF_BRANCH}} + - COMMIT=${{CF_REVISION}} + - ASPNETCORE_ENVIRONMENT=${{ASPNETCORE_ENVIRONMENT}} + when: + branch: + only: + - develop + - /^feature\/.*/i + - /^bug\/.*/i + - /^release\/.*/i + - /^hotfix\/.*/i + + push_develop_img_dockerhub: + stage: publish + type: push + title: 'Publish Integration Image to DockerHub' + candidate: '${{build_runtime_image}}' + image_name: broadvoice/messaging.api + tags: + - develop + - integration + registry: dockerhub + when: + condition: + any: + developBranch: '"${{CF_BRANCH}}" == "develop"' + fakeDevBranch: 'match("${{CF_BRANCH}}", "feature/BC-1667", true) == true' + + push_rc_img_dockerhub: + stage: publish + type: push + title: 'Publish RC/QA Image to Dockerhub' + candidate: '${{build_runtime_image}}' + image_name: broadvoice/messaging.api + tags: + - rc-${{CF_SHORT_REVISION}} + - qa + registry: dockerhub + when: + condition: + any: + releaseMatch: 'match("${{CF_BRANCH}}", "^release\/.*", true) == true' + hotfixMatch: 'match("${{CF_BRANCH}}", "^hotfix\/.*", true) == true' + + deploy_proxmox_dev: + stage: deploy + title: Deploy to Dev Environment (ProxMox) + image: node:latest + working_directory: ${{main_clone}} + environment: + - DOCKER_TAG=${{DOCKER_TAG}} + - CONST_BASEURL=${{CONST_BASEURL}} + - CONST_BASECLIENTURL=${{CONST_BASECLIENTURL}} + commands: + - echo " IdentityFile ~/.ssh/id_rsa" >> /etc/ssh/ssh_config + - mkdir -p ~/.ssh; echo ${{SSH_KEY}} | base64 --decode > ~/.ssh/id_rsa; chmod 600 ~/.ssh/id_rsa + - sed -i '2iDOCKER_TAG=${{DOCKER_TAG}}' deploy_proxmox.sh + #- cat deploy_proxmox.sh + #- echo '===========================' + - REMOTECOMMAND=$(base64 -w0 deploy_proxmox.sh); ssh -o StrictHostKeyChecking=no -p 23895 user_build@1.tcp.ngrok.io "echo $REMOTECOMMAND | base64 -d | sudo bash" + when: + condition: + any: + developBranch: '"${{CF_BRANCH}}" == "develop"' + fakeDevBranch: 'match("${{CF_BRANCH}}", "feature/BC-1667", true) == true' + + deploy_proxmox_qa: + stage: deploy + title: Deploy to QA Environment (ProxMox) + image: node:latest + working_directory: ${{main_clone}} + environment: + - DOCKER_TAG=${{DOCKER_TAG}} + - CONST_BASEURL=${{CONST_BASEURL}} + - CONST_BASECLIENTURL=${{CONST_BASECLIENTURL}} + commands: + - echo " IdentityFile ~/.ssh/id_rsa" >> /etc/ssh/ssh_config + - mkdir -p ~/.ssh; echo ${{SSH_KEY}} | base64 --decode > ~/.ssh/id_rsa; chmod 600 ~/.ssh/id_rsa + - sed -i '2iDOCKER_TAG=${{DOCKER_TAG}}' deploy_proxmox.sh + - REMOTECOMMAND=$(base64 -w0 deploy_proxmox.sh); ssh -o StrictHostKeyChecking=no -p 23896 user_build@1.tcp.ngrok.io "echo $REMOTECOMMAND | base64 -d | sudo bash" + when: + condition: + any: + releaseMatch: 'match("${{CF_BRANCH}}", "^release\/.*", true) == true' + hotfixMatch: 'match("${{CF_BRANCH}}", "^hotfix\/.*", true) == true' diff --git a/script.sh b/script.sh new file mode 100644 index 000000000..d8030cb3e --- /dev/null +++ b/script.sh @@ -0,0 +1,2 @@ +#!/bin/bash +docker build -f Dockerfile . diff --git a/spinnaker.json b/spinnaker.json new file mode 100644 index 000000000..6462a320d --- /dev/null +++ b/spinnaker.json @@ -0,0 +1,15 @@ +{ + "artifacts": [ + { + "name": "my-file", + "type": "s3/object", + "reference": "s3://webhook-example-bucket/webhook-example-object.yaml" + }, + { + "type": "helm/chart", + "name": "external-dns", + "reference": "external-dns", + "version": "1.4.0" + } + ] +} diff --git a/test.yaml b/test.yaml new file mode 100644 index 000000000..f348b6684 --- /dev/null +++ b/test.yaml @@ -0,0 +1,15 @@ +version: '1.0' + +steps: + + wait: + image: codefresh/cli + commands: + # Get CF pipeline name programaticlly + - CF_PIPELINE_NAME=$(codefresh get builds ${{CF_BUILD_ID}}|awk '{print $2}'|egrep -v "PIPELINE-NAME|no available") + # Verify if there's already another running build, if so, terminate it + - while [ $(codefresh get builds --status=running --pipeline-name=$CF_PIPELINE_NAME -b ${{CF_BRANCH}} |egrep -v "ID|no available"| wc -l) -gt 1 -a $(codefresh get builds --status=running --pipeline-name=$CF_PIPELINE_NAME -b ${{CF_BRANCH}}|egrep -v "ID|no available"|awk 'NR==1{print $1}') = ${{CF_BUILD_ID}} ]; do TERMINATE_BUILD=$(codefresh get builds --status=running --pipeline-name=$CF_PIPELINE_NAME -b ${{CF_BRANCH}}|egrep -v "ID|no available"|awk 'NR==2{print $1}') && echo "terminating build $TERMINATE_BUILD" && codefresh terminate $TERMINATE_BUILD && sleep 5; done + sleep: + image: alpine + commands: + - sleep 60