From 6ad9c18683623f19ad958746cb26694589c1a238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Ramos?= Date: Tue, 30 May 2017 19:45:00 +0100 Subject: [PATCH] chore: build packages before compose --- circle.yml | 1 + docker-compose.yml | 12 +++--------- scripts/build | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 9 deletions(-) create mode 100755 scripts/build diff --git a/circle.yml b/circle.yml index 2fd6bef1..cf93e02f 100644 --- a/circle.yml +++ b/circle.yml @@ -42,6 +42,7 @@ deployment: branch: master commands: - ./bin/docker-login + - ./bin/build - ./bin/deploy # production: # tag: /production-*/ diff --git a/docker-compose.yml b/docker-compose.yml index 309a9474..aee461ed 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -43,9 +43,7 @@ prometheus: # STYLEGUIDE ############################################################################# styleguide: - build: - context: . - dockerfile: ./packages/ui-toolkit/Dockerfile + image: quay.io/yldio/joyent-ui-toolkit:$CIRCLE_BRANCH ports: - 6060:6060 mem_limit: 512m @@ -60,9 +58,7 @@ styleguide: # FRONTEND ############################################################################# cp-frontend: - build: - context: . - dockerfile: ./packages/cp-frontend/Dockerfile + image: quay.io/yldio/joyent-cp-frontend:$CIRCLE_BRANCH mem_limit: 512m labels: - triton.cns.services=frontend-$CIRCLE_BRANCH @@ -77,9 +73,7 @@ cp-frontend: # BACKEND ############################################################################# gql-mock-server: - build: - context: . - dockerfile: ./packages/cp-gql-mock-server/Dockerfile + image: quay.io/yldio/joyent-cp-gql-mock-server:$CIRCLE_BRANCH mem_limit: 512m labels: - triton.cns.services=frontend-$CIRCLE_BRANCH diff --git a/scripts/build b/scripts/build new file mode 100755 index 00000000..02a3230d --- /dev/null +++ b/scripts/build @@ -0,0 +1,29 @@ +#!/usr/bin/env node + +const execa = require('execa'); +const main = require('apr-main'); +const map = require('apr-map'); +const globby = require('globby'); +const path = require('path'); +const readPkg = require('read-pkg'); + +const ROOT = path.join(__dirname, '..'); +const CIRCLE_BRANCH = process.env['CIRCLE_BRANCH']; + +const build = async () => { + const dockerfiles = await globby(['packages/*/Dockerfile'], { + cwd: ROOT + }); + + return map(dockerfiles, async dockerfile => { + const folder = path.resolve(ROOT, path.dirname(dockerfile)); + const { name } = await readPkg(folder); + const tag = `${name}:${CIRCLE_BRANCH}`; + + return execa('docker', ['build', '-t', tag, '-f', dockerfile, '.'], { + stdio: 'inherit' + }); + }); +}; + +main(build());