chore: simplify frontend docker image

This commit is contained in:
geek 2017-08-03 15:09:12 -05:00 committed by Sérgio Ramos
parent 0cf61c628a
commit 0330699c05
7 changed files with 38 additions and 42 deletions

View File

@ -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"]

View File

@ -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"
}

View File

@ -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;

View File

@ -46,8 +46,7 @@ prometheus:
# FRONTEND
#############################################################################
frontend:
build: ./
dockerfile: docker/frontend/Dockerfile
build: docker/frontend
mem_limit: 512m
links:
- consul:consul

View File

@ -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",

View File

@ -1,7 +1,6 @@
{
"name": "joyent-manifest-editor",
"version": "1.0.0",
"private": true,
"license": "MPL-2.0",
"description": "",
"keywords": [],

View File

@ -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"