Skip to content

Commit

Permalink
Make fast-boot production ready. Add to docker image. (#1962)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavk96 committed Jan 24, 2019
1 parent 5f8c556 commit aede94f
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 972 deletions.
9 changes: 5 additions & 4 deletions .dockerignore
@@ -1,12 +1,13 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
dist
tmp

# dependencies
/node_modules
/bower_components
node_modules
bower_components
Dockerfile

# misc
/.sass-cache
Expand Down
26 changes: 19 additions & 7 deletions Dockerfile
@@ -1,4 +1,4 @@
FROM node:10.15-alpine as builder
FROM node:10-alpine as builder
LABEL maintainer="Niranjan Rajendran <me@niranjan.io>"

WORKDIR /app
Expand All @@ -10,16 +10,28 @@ COPY package.json yarn.lock ./
RUN yarn install

COPY . .
RUN node scripts/l10n.js generate
RUN touch .env && JOBS=1 npx ember build -prod

RUN node scripts/l10n.js generate && \
touch .env && \
JOBS=1 yarn build -prod

##
##

FROM steebchen/nginx-spa:stable
FROM node:10-alpine

WORKDIR /fastboot

COPY scripts/fastboot-server.js .
COPY --from=builder /app/dist/ app/

COPY --from=builder /app/dist /app
RUN apk add --no-cache ca-certificates && \
cp app/package.json . && \
yarn install && \
yarn add fastboot-app-server && \
rm -rf yarn.lock && \
yarn cache clean

EXPOSE 80
EXPOSE 4000

CMD ["nginx"]
CMD ["node", "fastboot-server.js"]
19 changes: 19 additions & 0 deletions scripts/fastboot-server.js
@@ -0,0 +1,19 @@
const FastBootAppServer = require('fastboot-app-server');

const enableGzip = process.env.FASTBOOT_GZIP || 'true';
const fastbootDistPath = process.env.FASTBOOT_DIST_PATH || '/fastboot/app';
const enableChunkedResponse = process.env.FASTBOOT_CHUNKED_RESPONSE || 'true';
const fastbootHost = process.env.FASTBOOT_HOST || '0.0.0.0';
const fastbootPort = process.env.FASTBOOT_PORT || process.env.PORT || '4000';
const fastbootWorkers = process.env.FASTBOOT_WORKERS || '1';

let fastbootServer = new FastBootAppServer({
distPath : fastbootDistPath,
gzip : enableGzip === 'true',
host : fastbootHost,
port : parseInt(fastbootPort),
chunkedResponse : enableChunkedResponse === 'true',
workerCount : parseInt(fastbootWorkers)
});

fastbootServer.start();
11 changes: 0 additions & 11 deletions scripts/fastboot-server/fastboot-server.js

This file was deleted.

0 comments on commit aede94f

Please sign in to comment.