diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..70c5f859 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,163 @@ +### Bower ### +bower_components +.bower-cache +.bower-registry +.bower-tmp + + +### Git ### +*.orig + + +### macOS ### +*.DS_Store +.AppleDouble +.LSOverride + +# Thumbnails +._* +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + +### Node ### +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + + +### SublimeText ### +# cache files for sublime text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# workspace files are user-specific +*.sublime-workspace + +# project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using SublimeText +# *.sublime-project + +# sftp configuration file +sftp-config.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings + + +### Vim ### +# swap +[._]*.s[a-w][a-z] +[._]s[a-w][a-z] +# session +Session.vim +# temporary +.netrwhist +*~ +# auto-generated tag files +tags + + +### Windows ### +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + + +### Application Specific ### +.env + +# PostCSS +*.postcss.js + +/cloudapi-graphql/credentials.json +/docker-graphql/config.json +tap-xunit +/ui/dist + +_todo +packages/*/dist +packages/*/buid +packages/ui-toolkit/styleguide +packages/*/node_modules +legacy + diff --git a/.gitignore b/.gitignore index d61ad114..69c05479 100644 --- a/.gitignore +++ b/.gitignore @@ -155,4 +155,6 @@ tap-xunit /ui/dist _todo -packages/*/dist \ No newline at end of file +packages/*/dist +packages/*/buid +packages/ui-toolkit/styleguide diff --git a/circle.yml b/circle.yml index a29161ca..2fd6bef1 100644 --- a/circle.yml +++ b/circle.yml @@ -37,14 +37,12 @@ test: # test - yarn run test -# deployment: -# development: -# branch: master -# commands: -# - ./bin/docker-login -# - make -j2 build -# - make -j2 push -# - ./bin/deploy +deployment: + development: + branch: master + commands: + - ./bin/docker-login + - ./bin/deploy # production: # tag: /production-*/ # commands: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..f3db23ca --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,94 @@ +version: "2" + +services: + ############################################################################# + # CONSUL + # + # Consul is the service catalog that helps discovery between the components + # Change "-bootstrap" to "-bootstrap-expect 3", then scale to 3 or more to + # turn this into an HA Consul raft. + ############################################################################# + consul: + image: autopilotpattern/consul:latest + command: > + /usr/local/bin/containerpilot + /bin/consul agent -server + -bootstrap-expect 3 + -config-dir=/etc/consul + -ui-dir /ui + restart: always + mem_limit: 128m + ports: + - 8500 + dns: + - 127.0.0.1 + labels: + - triton.cns.services=consul-$CIRCLE_BRANCH + - com.docker.swarm.affinities=["container!=~*"] + + ############################################################################# + # PROMETHEUS + # + # Prometheus is an open source performance monitoring tool + # it is included here for demo purposes and is not required + ############################################################################# + prometheus: + image: autopilotpattern/prometheus:latest + restart: always + mem_limit: 1g + ports: + - 9090 + labels: + - triton.cns.services=prometheus-$CIRCLE_BRANCH + - com.docker.swarm.affinities=["container!=~*prometheus*"] + + ############################################################################# + # STYLEGUIDE + ############################################################################# + styleguide: + build: + context: . + dockerfile: ./packages/ui-toolkit/Dockerfile + ports: + - 6060:6060 + mem_limit: 512m + labels: + - triton.cns.services=ui-$CIRCLE_BRANCH + - com.docker.swarm.affinities=["container!=~*styleguide*"] + environment: + - CONSUL_AGENT=1 + - PORT=6060 + + ############################################################################# + # FRONTEND + ############################################################################# + cp-frontend: + build: + context: . + dockerfile: ./packages/cp-frontend/Dockerfile + mem_limit: 512m + labels: + - triton.cns.services=frontend-$CIRCLE_BRANCH + - com.docker.swarm.affinities=["container!=~*cp-frontend*"] + environment: + - CONSUL_AGENT=1 + - PORT=3069 + ports: + - 3069:3069 + + ############################################################################# + # BACKEND + ############################################################################# + gql-mock-server: + build: + context: . + dockerfile: ./packages/cp-gql-mock-server/Dockerfile + mem_limit: 512m + labels: + - triton.cns.services=frontend-$CIRCLE_BRANCH + - com.docker.swarm.affinities=["container!=~*gql-mock-server*"] + environment: + - CONSUL_AGENT=1 + - PORT=3000 + ports: + - 3000:3000 diff --git a/packages/cp-frontend/Dockerfile b/packages/cp-frontend/Dockerfile new file mode 100644 index 00000000..9b43cdb2 --- /dev/null +++ b/packages/cp-frontend/Dockerfile @@ -0,0 +1,12 @@ +# todo change to 7 +FROM quay.io/yldio/alpine-node-containerpilot:latest + +RUN npm install lerna@^2.0.0-rc.5 \ + && ./node_modules/.bin/lerna clean --yes --scope joyent-cp-frontend --include-filtered-dependencies \ + && ./node_modules/.bin/lerna bootstrap --scope joyent-cp-frontend --include-filtered-dependencies + +WORKDIR /home/node/app/packages/cp-frontend +COPY packages/cp-frontend/etc/containerpilot.json /etc/ + +EXPOSE 3069 +CMD ["/bin/containerpilot", "yarn", "run", "start"] diff --git a/packages/cp-frontend/etc/containerpilot.json b/packages/cp-frontend/etc/containerpilot.json new file mode 100644 index 00000000..e42ac9a9 --- /dev/null +++ b/packages/cp-frontend/etc/containerpilot.json @@ -0,0 +1,46 @@ +{ + "consul": "0.0.0.0:8500", + "services": [ + { + "name": "cp-frontend", + "port": 3069, + "health": "/usr/bin/curl -o /dev/null --fail -s http://0.0.0.0:3069/", + "poll": 3, + "ttl": 10 + } + ], + "backends": [], + "telemetry": { + "port": 9090, + "sensors": [ + { + "name": "frontend_memory_percent", + "help": "percentage of memory used", + "type": "gauge", + "poll": 5, + "check": ["/bin/sensors", "memory"] + }, + { + "name": "frontend_cpu_load", + "help": "cpu load", + "type": "gauge", + "poll": 5, + "check": ["/bin/sensors", "cpu"] + }, + { + "name": "frontend_disk_capacity", + "help": "disk capacity", + "type": "gauge", + "poll": 60, + "check": ["/bin/sensors", "diskcapacity"] + }, + { + "name": "frontend_disk_usage", + "help": "disk usage", + "type": "gauge", + "poll": 60, + "check": ["/bin/sensors", "diskusage"] + } + ] + } +} \ No newline at end of file diff --git a/packages/cp-gql-mock-server/Dockerfile b/packages/cp-gql-mock-server/Dockerfile new file mode 100644 index 00000000..c3ac7dc7 --- /dev/null +++ b/packages/cp-gql-mock-server/Dockerfile @@ -0,0 +1,12 @@ +# todo change to 7 +FROM quay.io/yldio/alpine-node-containerpilot:latest + +RUN npm install lerna@^2.0.0-rc.5 \ + && ./node_modules/.bin/lerna clean --yes --scope joyent-cp-gql-mock-server --include-filtered-dependencies \ + && ./node_modules/.bin/lerna bootstrap --scope joyent-cp-gql-mock-server --include-filtered-dependencies + +WORKDIR /home/node/app/packages/cp-gql-mock-server +COPY packages/cp-gql-mock-server/etc/containerpilot.json /etc/ + +EXPOSE 3000 +CMD ["/bin/containerpilot", "yarn", "run", "start"] diff --git a/packages/cp-gql-mock-server/etc/containerpilot.json b/packages/cp-gql-mock-server/etc/containerpilot.json new file mode 100644 index 00000000..a6c55623 --- /dev/null +++ b/packages/cp-gql-mock-server/etc/containerpilot.json @@ -0,0 +1,46 @@ +{ + "consul": "0.0.0.0:8500", + "services": [ + { + "name": "cp-gql-mock-server", + "port": 3000, + "health": "/usr/bin/curl -o /dev/null --fail -s http://0.0.0.0:3000/", + "poll": 3, + "ttl": 10 + } + ], + "backends": [], + "telemetry": { + "port": 9090, + "sensors": [ + { + "name": "frontend_memory_percent", + "help": "percentage of memory used", + "type": "gauge", + "poll": 5, + "check": ["/bin/sensors", "memory"] + }, + { + "name": "frontend_cpu_load", + "help": "cpu load", + "type": "gauge", + "poll": 5, + "check": ["/bin/sensors", "cpu"] + }, + { + "name": "frontend_disk_capacity", + "help": "disk capacity", + "type": "gauge", + "poll": 60, + "check": ["/bin/sensors", "diskcapacity"] + }, + { + "name": "frontend_disk_usage", + "help": "disk usage", + "type": "gauge", + "poll": 60, + "check": ["/bin/sensors", "diskusage"] + } + ] + } +} \ No newline at end of file diff --git a/packages/ui-toolkit/Dockerfile b/packages/ui-toolkit/Dockerfile new file mode 100644 index 00000000..e1496fd3 --- /dev/null +++ b/packages/ui-toolkit/Dockerfile @@ -0,0 +1,12 @@ +# todo change to 7 +FROM quay.io/yldio/alpine-node-containerpilot:latest + +RUN npm install lerna@^2.0.0-rc.5 \ + && ./node_modules/.bin/lerna clean --yes --scope joyent-ui-toolkit --include-filtered-dependencies \ + && ./node_modules/.bin/lerna bootstrap --scope joyent-ui-toolkit --include-filtered-dependencies + +WORKDIR /home/node/app/packages/ui-toolkit +COPY packages/ui-toolkit/etc/containerpilot.json /etc/ + +EXPOSE 6060 +CMD ["/bin/containerpilot", "yarn", "run", "styleguide"] diff --git a/packages/ui-toolkit/etc/containerpilot.json b/packages/ui-toolkit/etc/containerpilot.json new file mode 100644 index 00000000..e0e73a73 --- /dev/null +++ b/packages/ui-toolkit/etc/containerpilot.json @@ -0,0 +1,46 @@ +{ + "consul": "0.0.0.0:8500", + "services": [ + { + "name": "ui-toolkit", + "port": 6060, + "health": "/usr/bin/curl -o /dev/null --fail -s http://0.0.0.0:6060/", + "poll": 3, + "ttl": 10 + } + ], + "backends": [], + "telemetry": { + "port": 9090, + "sensors": [ + { + "name": "frontend_memory_percent", + "help": "percentage of memory used", + "type": "gauge", + "poll": 5, + "check": ["/bin/sensors", "memory"] + }, + { + "name": "frontend_cpu_load", + "help": "cpu load", + "type": "gauge", + "poll": 5, + "check": ["/bin/sensors", "cpu"] + }, + { + "name": "frontend_disk_capacity", + "help": "disk capacity", + "type": "gauge", + "poll": 60, + "check": ["/bin/sensors", "diskcapacity"] + }, + { + "name": "frontend_disk_usage", + "help": "disk usage", + "type": "gauge", + "poll": 60, + "check": ["/bin/sensors", "diskusage"] + } + ] + } +} \ No newline at end of file