Skip to content

Commit 7808a5b

Browse files
committed
Dockerize
1 parent 68daaf4 commit 7808a5b

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM node:latest
2+
MAINTAINER Francisco Guimarães <[email protected]>
3+
4+
WORKDIR /app
5+
6+
ADD . /app
7+
8+
RUN npm run build && \
9+
ln -s /app/bin/index.js /usr/bin/json-server
10+
11+
WORKDIR /data
12+
VOLUME /data
13+
14+
EXPOSE 80
15+
ADD run.sh /run.sh
16+
ENTRYPOINT ["bash", "/run.sh"]
17+
CMD []

run.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
trap 'echo "Killing PID $SERVER_PID"; kill $SERVER_PID' EXIT
4+
5+
6+
args="$@"
7+
8+
args="$@ -p 80"
9+
10+
file=/data/db.json
11+
if [ -f $file ]; then
12+
echo "Found db.json, trying to open"
13+
args="$args db.json"
14+
fi
15+
16+
file=/data/file.js
17+
if [ -f $file ]; then
18+
echo "Found file.js seed file, trying to open"
19+
args="$args file.js"
20+
fi
21+
22+
json-server $args &
23+
SERVER_PID=$!
24+
echo "json-server started with PID $SERVER_PID"
25+
wait

0 commit comments

Comments
 (0)