Skip to content

Commit cdeee53

Browse files
Logging service files
1 parent 8db8233 commit cdeee53

8 files changed

Lines changed: 628 additions & 0 deletions

File tree

services/lumberjack/Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
ARG BASE=node:8-alpine
2+
3+
# Compile our js source.
4+
FROM ${BASE} AS builder
5+
6+
WORKDIR /builder
7+
8+
# We need packages to install the net-ping node dependency.
9+
RUN apk --no-cache add \
10+
make \
11+
g++ \
12+
python-dev
13+
14+
COPY common/nodejs/package.json src/common/
15+
COPY lumberjack/package.json .
16+
17+
RUN npm install
18+
19+
COPY common/messages/stats.proto \
20+
src/messages/
21+
22+
RUN npm run build-msg
23+
24+
COPY common/nodejs src/common
25+
COPY lumberjack .
26+
27+
RUN npm run build
28+
29+
# Make the actual image now.
30+
FROM ${BASE}
31+
32+
WORKDIR /app
33+
34+
# Copying over raw-socket since we don't have to build it again.
35+
36+
ENV NODE_ENV=production
37+
38+
COPY common/nodejs/package.json src/common/
39+
COPY lumberjack/package.json .
40+
41+
RUN npm install
42+
43+
# Add in the output from the js builder above.
44+
COPY --from=builder /builder/lib lib
45+
46+
COPY /lumberjack/bin bin
47+
48+
ENV INFLUX_PORT=8086 \
49+
INFLUX_HOST='localhost'
50+
51+
EXPOSE 6000
52+
53+
CMD FORCE_COLOR=1 npm start --silent
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
ARG BASE=node:8-alpine
2+
3+
FROM ${BASE}
4+
5+
ENV NODE_ENV=test
6+
7+
WORKDIR /test
8+
9+
# We need packages to install the net-ping node dependency.
10+
RUN apk --no-cache add \
11+
make \
12+
g++ \
13+
python-dev
14+
15+
COPY common/nodejs/package.json src/common/
16+
COPY lumberjack/package.json .
17+
18+
RUN npm install
19+
20+
COPY common/messages/stats.proto \
21+
src/messages/
22+
23+
RUN npm run build-msg
24+
25+
COPY common/nodejs src/common
26+
COPY lumberjack .
27+
28+
CMD npm run lint && npm test

services/lumberjack/Makefile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Flags for docker when building images, meant to be overridden
2+
DOCKERFLAGS :=
3+
4+
PONG_IMAGE := uavaustin/lumberjack
5+
PONG_TEST_IMAGE := uavaustin/lumberjack-test
6+
ALPINE_IMAGE := alpine
7+
8+
current_dir := $(shell pwd)
9+
10+
.PHONY: all
11+
all: image
12+
13+
.PHONY: image
14+
image:
15+
docker build -t $(PONG_IMAGE) -f Dockerfile $(DOCKERFLAGS) ..
16+
17+
.PHONY: test
18+
test: alpine
19+
docker build -t $(PONG_TEST_IMAGE) -f Dockerfile.test $(DOCKERFLAGS) ..
20+
docker run -it --rm -v $(current_dir)/coverage:/test/coverage \
21+
-v /var/run/docker.sock:/var/run/docker.sock $(PONG_TEST_IMAGE)
22+
23+
.PHONY: alpine
24+
alpine:
25+
@if ! docker inspect --type=image $(ALPINE_IMAGE) &> /dev/null; then \
26+
docker pull $(ALPINE_IMAGE); \
27+
fi
28+
29+
.PHONY: clean
30+
clean:
31+
rm -rf node_modules lib package-lock.json
32+
docker rmi -f $(PONG_IMAGE)
33+
docker rmi -f $(PONG_TEST_IMAGE)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env node
2+
3+
const Service = require('..');
4+
5+
let service = new Service({
6+
influxPort: process.env.INFLUX_PORT,
7+
influxHost: process.env.INFLUX_HOST
8+
});
9+
10+
service.start();
11+
12+
process.once('SIGINT', () => service.stop());

services/lumberjack/jest.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
testEnvironment: 'node',
3+
collectCoverage: true,
4+
collectCoverageFrom: [
5+
'src/**/*.js',
6+
'!src/common/**',
7+
'!src/messages.js'
8+
]
9+
}

0 commit comments

Comments
 (0)