From 76ee6b66edf9a0652e3f7e5ab8edc008e45406ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Ramos?= Date: Tue, 20 Jun 2017 15:45:50 +0100 Subject: [PATCH] build(cp-frontend): build assets on runtime --- docker-compose.yml | 2 ++ packages/cp-frontend/Dockerfile | 7 +------ packages/cp-frontend/etc/containerpilot.json5 | 8 ++++++++ packages/cp-gql-mock-server/Dockerfile | 6 +----- packages/portal-api/Dockerfile | 5 +---- packages/ui-toolkit/Dockerfile | 4 +--- 6 files changed, 14 insertions(+), 18 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index ebba3fdb..aedd3b28 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -66,6 +66,8 @@ cp-frontend: environment: - CONSUL_AGENT=1 - PORT=3069 + - REACT_APP_GQL_HOSTNAME=gql-mock-server-$CIRCLE_BRANCH.svc.f4b20699-b323-4452-9091-977895896da6.eu-ams-1.triton.zone + - REACT_APP_GQL_PORT=3000 ports: - 3069 diff --git a/packages/cp-frontend/Dockerfile b/packages/cp-frontend/Dockerfile index e0e025ed..e415f0d9 100644 --- a/packages/cp-frontend/Dockerfile +++ b/packages/cp-frontend/Dockerfile @@ -6,13 +6,8 @@ RUN yarn add lerna@^2.0.0-rc.5 serve \ && ./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 /opt/app/packages/cp-frontend COPY packages/cp-frontend/etc/containerpilot.json5 ${CONTAINERPILOT} - -RUN yarn run build - -ARG CIRCLE_BRANCH -ENV REACT_APP_GQL_HOSTNAME gql-mock-server-$CIRCLE_BRANCH.svc.f4b20699-b323-4452-9091-977895896da6.eu-ams-1.triton.zone +WORKDIR /opt/app/packages/cp-frontend EXPOSE 3069 CMD ["/bin/containerpilot"] diff --git a/packages/cp-frontend/etc/containerpilot.json5 b/packages/cp-frontend/etc/containerpilot.json5 index c06aa319..ff1310e7 100644 --- a/packages/cp-frontend/etc/containerpilot.json5 +++ b/packages/cp-frontend/etc/containerpilot.json5 @@ -1,10 +1,18 @@ { consul: 'localhost:8500', jobs: [ + { + name: 'build', + exec: 'yarn run build' + }, { name: 'cp-frontend', port: {{.PORT}}, exec: '../../node_modules/.bin/serve --single build --port {{.PORT}}', + when: { + source: 'build', + once: 'exitSuccess' + }, health: { exec: '/usr/bin/curl -o /dev/null --fail -s http://localhost:{{.PORT}}', interval: 2, diff --git a/packages/cp-gql-mock-server/Dockerfile b/packages/cp-gql-mock-server/Dockerfile index 412511bb..f210a6b7 100644 --- a/packages/cp-gql-mock-server/Dockerfile +++ b/packages/cp-gql-mock-server/Dockerfile @@ -6,12 +6,8 @@ RUN yarn add lerna@^2.0.0-rc.5 serve \ && ./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 /opt/app/packages/cp-gql-mock-server - COPY packages/cp-gql-mock-server/etc/containerpilot.json5 ${CONTAINERPILOT} -COPY packages/cp-gql-mock-server/bin /bin - -ARG CIRCLE_BRANCH +WORKDIR /opt/app/packages/cp-gql-mock-server EXPOSE 3000 CMD ["/bin/containerpilot"] diff --git a/packages/portal-api/Dockerfile b/packages/portal-api/Dockerfile index 704789ac..a3bf6838 100644 --- a/packages/portal-api/Dockerfile +++ b/packages/portal-api/Dockerfile @@ -11,10 +11,7 @@ RUN yarn add lerna@^2.0.0-rc.5 \ && ./node_modules/.bin/lerna clean --yes --scope portal-api --include-filtered-dependencies \ && ./node_modules/.bin/lerna bootstrap --scope portal-api --include-filtered-dependencies +COPY packages/portal-api/etc/containerpilot.json5 ${CONTAINERPILOT} WORKDIR /opt/app/packages/portal-api -COPY packages/portal-api/etc/containerpilot.json5 ${CONTAINERPILOT} - -ARG CIRCLE_BRANCH - CMD ["/bin/containerpilot"] diff --git a/packages/ui-toolkit/Dockerfile b/packages/ui-toolkit/Dockerfile index 54492ced..4f8ca206 100644 --- a/packages/ui-toolkit/Dockerfile +++ b/packages/ui-toolkit/Dockerfile @@ -6,12 +6,10 @@ RUN yarn add lerna@^2.0.0-rc.5 serve \ && ./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 /opt/app/packages/ui-toolkit COPY packages/ui-toolkit/etc/containerpilot.json5 ${CONTAINERPILOT} +WORKDIR /opt/app/packages/ui-toolkit RUN yarn run styleguide:build -ARG CIRCLE_BRANCH - EXPOSE 6060 CMD ["/bin/containerpilot"]