From 0330699c05a4fb049066dcb3d001a8066819024e Mon Sep 17 00:00:00 2001 From: geek Date: Thu, 3 Aug 2017 15:09:12 -0500 Subject: [PATCH] chore: simplify frontend docker image --- docker/frontend/Dockerfile | 44 ++++++++++++--------------- docker/frontend/bin/reload-nginx.sh | 4 +-- docker/frontend/etc/nginx.conf.tmpl | 2 +- local-compose.yml | 3 +- packages/cp-frontend/package.json | 5 ++- packages/manifest-editor/package.json | 1 - packages/ui-toolkit/package.json | 21 ++++++++----- 7 files changed, 38 insertions(+), 42 deletions(-) diff --git a/docker/frontend/Dockerfile b/docker/frontend/Dockerfile index 0d086bd6..cccc01f4 100644 --- a/docker/frontend/Dockerfile +++ b/docker/frontend/Dockerfile @@ -1,18 +1,21 @@ FROM node:8-alpine -# Built in context of root folder in repo - # Install dependencies RUN set -x \ && apk update \ - && apk add --update curl bash build-base git nginx python openssl \ + && apk add --update curl bash nginx openssl \ && apk upgrade \ && rm -rf /var/cache/apk/* - # Use consul-template to re-write our Nginx virtualhost config - RUN curl -Lo /tmp/consul_template_0.15.0_linux_amd64.zip https://releases.hashicorp.com/consul-template/0.15.0/consul-template_0.15.0_linux_amd64.zip && \ - unzip /tmp/consul_template_0.15.0_linux_amd64.zip && \ - mv consul-template /bin + # Install Consul template + # Releases at https://releases.hashicorp.com/consul-template/ + RUN set -ex \ + && export CONSUL_TEMPLATE_VERSION=0.19.0 \ + && export CONSUL_TEMPLATE_CHECKSUM=31dda6ebc7bd7712598c6ac0337ce8fd8c533229887bd58e825757af879c5f9f \ + && curl --retry 7 --fail -Lso /tmp/consul-template.zip "https://releases.hashicorp.com/consul-template/${CONSUL_TEMPLATE_VERSION}/consul-template_${CONSUL_TEMPLATE_VERSION}_linux_amd64.zip" \ + && echo "${CONSUL_TEMPLATE_CHECKSUM} /tmp/consul-template.zip" | sha256sum -c \ + && unzip /tmp/consul-template.zip -d /usr/local/bin \ + && rm /tmp/consul-template.zip # Install Consul agent ENV CONSUL_VERSION 0.7.0 @@ -31,26 +34,17 @@ RUN curl -Lo /tmp/containerpilot.tar.gz "https://github.com/joyent/containerpilo && tar zxf /tmp/containerpilot.tar.gz -C /bin \ && rm /tmp/containerpilot.tar.gz -# Copy required files -RUN mkdir -p /opt/app/ -COPY ./ /opt/app/ -COPY ./docker/frontend/bin /bin -COPY ./docker/frontend/etc/nginx.conf.tmpl /etc/nginx/nginx.conf.tmpl -COPY ./docker/frontend/etc/containerpilot.json5 /etc/containerpilot.json5 -ENV CONTAINERPILOT /etc/containerpilot.json5 - -WORKDIR /opt/app/ - -ENV BUILD=production ENV NODE_ENV=production -RUN npm install -g yarn -RUN yarn add lerna +# Copy required files +COPY ./bin /bin +COPY ./etc/nginx.conf.tmpl /etc/nginx/nginx.conf.tmpl +COPY ./etc/containerpilot.json5 /etc/containerpilot.json5 +ENV CONTAINERPILOT /etc/containerpilot.json5 -RUN ./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 -RUN yarn build +RUN mkdir -p /opt/app/ +WORKDIR /opt/app/ +RUN npm pack joyent-cp-frontend +RUN tar -xzf joyent-cp-frontend*.tgz CMD ["/bin/containerpilot"] diff --git a/docker/frontend/bin/reload-nginx.sh b/docker/frontend/bin/reload-nginx.sh index 4b092818..403e2225 100755 --- a/docker/frontend/bin/reload-nginx.sh +++ b/docker/frontend/bin/reload-nginx.sh @@ -24,7 +24,7 @@ preStart() { consul-template \ -once \ - -consul localhost:8500 \ + -consul-addr "localhost:8500" \ -template "/etc/nginx/nginx.conf.tmpl:/etc/nginx/nginx.conf" } @@ -33,7 +33,7 @@ preStart() { onChange() { consul-template \ -once \ - -consul localhost:8500 \ + -consul-addr "localhost:8500" \ -template "/etc/nginx/nginx.conf.tmpl:/etc/nginx/nginx.conf:nginx -s reload" } diff --git a/docker/frontend/etc/nginx.conf.tmpl b/docker/frontend/etc/nginx.conf.tmpl index 732e03d8..e0a2e475 100644 --- a/docker/frontend/etc/nginx.conf.tmpl +++ b/docker/frontend/etc/nginx.conf.tmpl @@ -44,7 +44,7 @@ http { server { listen 443 ssl; listen [::]:443 ssl; - root /opt/app/packages/cp-frontend/build; + root /opt/app/package/build; ssl_certificate /etc/nginx/certs/server/server.crt; ssl_certificate_key /etc/nginx/certs/server/server.key; diff --git a/local-compose.yml b/local-compose.yml index faab683b..ba89f3c7 100644 --- a/local-compose.yml +++ b/local-compose.yml @@ -46,8 +46,7 @@ prometheus: # FRONTEND ############################################################################# frontend: - build: ./ - dockerfile: docker/frontend/Dockerfile + build: docker/frontend mem_limit: 512m links: - consul:consul diff --git a/packages/cp-frontend/package.json b/packages/cp-frontend/package.json index 17bd2923..5177bf75 100644 --- a/packages/cp-frontend/package.json +++ b/packages/cp-frontend/package.json @@ -1,10 +1,9 @@ { "name": "joyent-cp-frontend", - "version": "1.1.0", - "private": true, + "version": "1.1.1", "license": "MPL-2.0", "repository": "github:yldio/joyent-portal", - "main": "src/index.js", + "main": "build/", "scripts": { "dev": "REACT_APP_GQL_PORT=3000 PORT=3069 REACT_APP_GQL_PROTOCOL=http react-scripts start", "start": "PORT=3069 react-scripts start", diff --git a/packages/manifest-editor/package.json b/packages/manifest-editor/package.json index 0e2c638c..ba2fd414 100644 --- a/packages/manifest-editor/package.json +++ b/packages/manifest-editor/package.json @@ -1,7 +1,6 @@ { "name": "joyent-manifest-editor", "version": "1.0.0", - "private": true, "license": "MPL-2.0", "description": "", "keywords": [], diff --git a/packages/ui-toolkit/package.json b/packages/ui-toolkit/package.json index 85919744..fb8a25dd 100644 --- a/packages/ui-toolkit/package.json +++ b/packages/ui-toolkit/package.json @@ -1,7 +1,6 @@ { "name": "joyent-ui-toolkit", - "version": "1.1.0", - "private": true, + "version": "1.1.2", "license": "MPL-2.0", "repository": "github:yldio/joyent-portal", "main": "dist/umd/index.js", @@ -28,7 +27,15 @@ "postinstall": "redrun -s copy-fonts compile" }, "dependencies": { + "babel-cli": "^6.24.1", + "babel-generator": "^6.25.0", + "babel-helpers": "^6.24.1", + "babel-plugin-inline-react-svg": "^0.4.0", + "babel-plugin-styled-components": "^1.1.7", + "babel-preset-joyent-portal": "^1.0.3", + "babel-template": "^6.25.0", "camel-case": "^3.0.0", + "cross-env": "^5.0.1", "d3": "^4.10.0", "disable-scroll": "^0.3.0", "lodash.difference": "^4.5.0", @@ -41,6 +48,7 @@ "prop-types": "^15.5.10", "react-broadcast": "^0.1.2", "react-styled-flexboxgrid": "^2.0.3", + "redrun": "^5.9.15", "reduce-css-calc": "^2.0.5", "remcalc": "^1.0.8", "rnd-id": "^1.0.8", @@ -49,11 +57,7 @@ "unitcalc": "^1.0.8" }, "devDependencies": { - "babel-cli": "^6.24.1", - "babel-plugin-inline-react-svg": "^0.4.0", - "babel-plugin-styled-components": "^1.1.7", - "babel-preset-joyent-portal": "^1.0.3", - "cross-env": "^5.0.1", + "csso": "^3.1.1", "eslint": "^3.19.0", "eslint-config-joyent-portal": "2.0.0", "jest": "^20.0.4", @@ -61,6 +65,7 @@ "jest-matcher-utils": "^20.0.3", "jest-snapshot": "^20.0.3", "jest-styled-components": "^4.2.2", + "jsesc": "^2.5.1", "react": "^15.6.1", "react-docgen": "^2.17.0", "react-docgen-displayname-handler": "^1.0.0", @@ -70,7 +75,6 @@ "react-scripts": "^1.0.10", "react-styleguidist": "^5.5.9", "react-test-renderer": "^15.6.1", - "redrun": "^5.9.15", "redux": "^3.7.2", "redux-form": "^7.0.2", "snapguidist": "^2.0.0", @@ -78,6 +82,7 @@ "stylelint-config-primer": "^2.0.0", "stylelint-config-standard": "^17.0.0", "stylelint-processor-styled-components": "styled-components/stylelint-processor-styled-components#2a33b5f", + "svgo": "^0.7.2", "tinycolor2": "^1.4.1", "title-case": "^2.1.1", "webpack": "^3.4.1"