Skip to content

Commit 11a41a4

Browse files
committed
reduce image size; add init system; fix script to be POSIX compliant; fix package dependency
1 parent bba42e6 commit 11a41a4

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

.dockerignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
.git
2+
.gitignore
13
node_modules
24
logs/*.log
3-
lib/state.json
5+
lib/state.json
6+
*.md

Dockerfile

+30-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
1-
FROM node:onbuild
1+
FROM alpine:3.5
22

3-
#CMD ["node", "lib/index.js"]
4-
CMD ["node", "node_modules/.bin/forever", "--minUptime", "1", "--spinSleepTime", "1000", "-c", "node", "lib/index.js"]
3+
# install node
4+
RUN apk add --no-cache nodejs=6.9.2-r1 tini
5+
6+
# set working directory
7+
WORKDIR /app
8+
9+
# copy project file
10+
COPY package.json .
11+
12+
# Build time argument to set NODE_ENV ('production'' by default)
13+
ARG NODE_ENV
14+
ENV NODE_ENV ${NODE_ENV:-production}
15+
16+
# install node packages
17+
RUN apk add --no-cache --virtual .build-dep git && \
18+
npm set progress=false && \
19+
npm config set depth 0 && \
20+
npm install && \
21+
npm cache clean && \
22+
apk del .build-dep && \
23+
rm -rf /tmp/*
24+
25+
# Set tini as entrypoint
26+
COPY . .
27+
28+
# Set tini as entrypoint
29+
ENTRYPOINT ["/sbin/tini", "--"]
30+
31+
CMD ["node", "node_modules/.bin/forever", "--minUptime", "1", "--spinSleepTime", "1000", "-c", "node", "lib/index.js"]

lib/isReady.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#!/bin/bash
1+
#!/bin/sh
22
#
33

44
CONTAINER_ID=$1
55

66
echo "checking if container:$CONTAINER_ID exists"
7-
if [[ -n "$CONTAINER_ID" ]]; then
7+
if [ -n "$CONTAINER_ID" ]; then
88
grep -q $CONTAINER_ID ./lib/state.json
99
else
1010
grep -q "ready" ./lib/state.json

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
"cf-errors": "^0.1.11",
1010
"cf-logs": "git+https://github.com/codefresh-io/cf-logs.git#ceba4f309e52a077747a0c6bf9c3ad02e762dc4b",
1111
"dockerode": "^2.3.0",
12+
"docker-events": "0.0.2",
1213
"firebase": "^2.4.1",
1314
"forever": "^0.15.3",
1415
"lodash": "^4.15.0",
1516
"q": "^1.4.1"
1617
},
1718
"devDependencies": {
1819
"chai": "^3.0.0",
19-
"docker-events": "0.0.2",
2020
"gulp": "^3.9.1",
2121
"gulp-coveralls": "^0.1.4",
2222
"gulp-env": "^0.2.0",

0 commit comments

Comments
 (0)