fix json-server (FIX #187)

This commit is contained in:
kev 2021-10-11 19:29:24 +08:00
parent c95a77645a
commit 345bbc1996
3 changed files with 29 additions and 20 deletions

View File

@ -2,16 +2,16 @@
# Dockerfile for json-server
#
FROM alpine
MAINTAINER kev <noreply@easypi.pro>
WORKDIR /data
FROM alpine:3
MAINTAINER EasyPi Software Foundation
RUN set -xe \
&& apk add --no-cache nodejs nodejs-npm \
&& npm install -g json-server \
&& rm -rf /tmp/npm* /var/cache/apk/*
WORKDIR /data
EXPOSE 3000
ENTRYPOINT ["json-server"]

View File

@ -8,16 +8,21 @@ Get a full fake REST API with zero coding in less than 30 seconds (seriously) wi
## docker-compose.yml
```yaml
json-server:
image: vimagick/json-server
command: -H 0.0.0.0 -p 3000 -w db.json
ports:
- "3000:3000"
volumes:
- ./data:/data
restart: always
version: "3.8"
services:
json-server:
image: vimagick/json-server
command: -H 0.0.0.0 -p 3000 -w db.json
init: true
ports:
- "3000:3000"
volumes:
- ./data:/data
restart: unless-stopped
```
>> :warning: `init: true` is required. [read more][2]
## data/db.json
```json
@ -48,3 +53,4 @@ http GET :3000/db
```
[1]: https://github.com/typicode/json-server
[2]: https://developpaper.com/avoid-running-nodejs-as-pid-1-under-the-docker-image/

View File

@ -1,8 +1,11 @@
json-server:
image: vimagick/json-server
command: -H 0.0.0.0 -p 3000 -w db.json
ports:
- "3000:3000"
volumes:
- ./data:/data
restart: always
version: "3.8"
services:
json-server:
image: vimagick/json-server
command: -H 0.0.0.0 -p 3000 -w db.json
init: true
ports:
- "3000:3000"
volumes:
- ./data:/data
restart: unless-stopped