Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit a2f6d53

Browse files
JyyjyEandrewJones
andauthored
feat(Dockerfile) adds docker file to containerized the example server (#434) (#439)
* feat(Dockerfile) adds docker file to containerized the example server Dockerizes the example server js for easier portability. Fixes a bug in server.js so that empty logs are no longer written out to the active JSON file buffer. * expose port --------- Co-authored-by: Evan Jones <[email protected]>
1 parent 01295de commit a2f6d53

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ARG BUILDPLATFORM=${BUILDPLATFORM:-amd64}
2+
FROM --platform=${BUILDPLATFORM} node:18-bullseye-slim AS flagon-node
3+
4+
WORKDIR /app
5+
RUN --mount=type=bind,target=./package.json,src=./package.json \
6+
--mount=type=bind,target=./package-lock.json,src=./package-lock.json \
7+
npm ci
8+
COPY ./src src/
9+
COPY ./example example/
10+
11+
EXPOSE 8000
12+
13+
CMD ["node", "example/server.js"]

example/server.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ app.get('/', function (req, res) {
6666

6767
app.post('/', function (req, res) {
6868
const body = typeof req.body === "string" ? JSON.parse(req.body) : req.body
69+
70+
const isEmptyArray = (Array.isArray(body) && body.length === 0);
71+
const isEmptyObject = (typeof body === 'object' && body !== null && Object.keys(body).length === 0);
72+
if (isEmptyArray || isEmptyObject) return
73+
6974
console.log(body)
7075

7176
let delimiter = ',\n\t';

0 commit comments

Comments
 (0)