Skip to content
This repository has been archived by the owner on Jun 24, 2020. It is now read-only.

Commit

Permalink
Reduce build size (#1)
Browse files Browse the repository at this point in the history
* use builder container + Zeit PKG

* use webpack to compile the build before packaging

* remove ununsed code

* update docs
  • Loading branch information
hharnisc committed Mar 3, 2018
1 parent 81a4b6a commit 66e568a
Show file tree
Hide file tree
Showing 12 changed files with 9,311 additions and 3,420 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
app.min.js
stats.json
26 changes: 13 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FROM node:9.6.1-alpine

RUN mkdir -p /usr/src/app
FROM node:9.6.1-alpine as builder
RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh
WORKDIR /usr/src/app

ENV NODE_ENV production

COPY package.json /usr/src/app
COPY . /usr/src/app
RUN npm install

COPY src/ /usr/src/app/src/

EXPOSE 80

CMD npm run serve
RUN npm run build
RUN npm install -g pkg
RUN /usr/local/bin/pkg -t node8-alpine-x64 app.min.js -o binary

FROM alpine:latest
RUN apk update && apk add --no-cache libstdc++ libgcc
WORKDIR /root/
COPY --from=builder /usr/src/app/binary binary
CMD ["./binary"]
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ spec:
{
"name": "mongodb-check-buffer",
"type": "mongoDBCheck",
"url": "mongodb://mongo:27017",
"dbName": "buffer"
"host": "mongo",
"port": 27017
}
]
}
Expand Down Expand Up @@ -101,8 +101,8 @@ EKG sidecar is passed it's configuration as JSON through the EKG_CONFIG environm
{
"name": "mongodb-check-buffer",
"type": "mongoDBCheck",
"url": "mongodb://mongo:27017",
"dbName": "buffer",
"host": "mongo",
"port": 27017,
"timeout": 5000
}
],
Expand All @@ -129,8 +129,8 @@ EKG sidecar is passed it's configuration as JSON through the EKG_CONFIG environm
{
"name": "mongodb-check-buffer",
"type": "mongoDBCheck",
"url": "mongodb://mongo:27017",
"dbName": "buffer",
"host": "mongo",
"port": 27017,
"timeout": 5000
}
]
Expand Down Expand Up @@ -203,8 +203,8 @@ Ping a mongodb database
{
"name": "mongodb-check-buffer",
"type": "mongoDBCheck",
"url": "mongodb://mongo:27017",
"dbName": "buffer",
"host": "mongo",
"port": 27017,
"timeout": 5000
}
```
Expand Down Expand Up @@ -382,8 +382,8 @@ Returns a function that pings a mongodb database

```js
const doCheck = mongoDBCheck({
url: 'mongodb://mongo:27017',
dbName: 'default',
host: 'mongo',
port: 27017,
timeout: 5000,
})

Expand Down
20 changes: 20 additions & 0 deletions __mocks__/mongodb-core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const MongoDBCore = {}
const Server = function() {
this.connection = {
command: (cmd, args, cb) =>
cb(null, {
result: {
ok: 1,
},
}),
destroy: () => {},
}
this.on = (type, cb) => {
if (type === 'connect') {
this.connectCb = cb
}
}
this.connect = () => this.connectCb(this.connection)
}
MongoDBCore.Server = jest.fn(Server)
module.exports = MongoDBCore
38 changes: 0 additions & 38 deletions __mocks__/mongodb.js

This file was deleted.

8 changes: 4 additions & 4 deletions example/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ ekg.addLivenessCheck({
ekg.addLivenessCheck({
name: 'mongodb localhost',
check: mongoDBCheck({
url: 'mongodb://localhost:27017',
dbName: 'default',
host: 'localhost',
port: '27017',
}),
})
ekg.addLivenessCheck({
Expand Down Expand Up @@ -77,8 +77,8 @@ ekg.addReadinessCheck({
ekg.addReadinessCheck({
name: 'mongodb localhost',
check: mongoDBCheck({
url: 'mongodb://localhost:27017',
dbName: 'default',
host: 'localhost',
port: '27017',
}),
})
ekg.addReadinessCheck({
Expand Down

0 comments on commit 66e568a

Please sign in to comment.