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 # Dockerfile for json-server
# #
FROM alpine FROM alpine:3
MAINTAINER kev <noreply@easypi.pro> MAINTAINER EasyPi Software Foundation
WORKDIR /data
RUN set -xe \ RUN set -xe \
&& apk add --no-cache nodejs nodejs-npm \ && apk add --no-cache nodejs nodejs-npm \
&& npm install -g json-server \ && npm install -g json-server \
&& rm -rf /tmp/npm* /var/cache/apk/* && rm -rf /tmp/npm* /var/cache/apk/*
WORKDIR /data
EXPOSE 3000 EXPOSE 3000
ENTRYPOINT ["json-server"] 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 ## docker-compose.yml
```yaml ```yaml
json-server: version: "3.8"
image: vimagick/json-server services:
command: -H 0.0.0.0 -p 3000 -w db.json json-server:
ports: image: vimagick/json-server
- "3000:3000" command: -H 0.0.0.0 -p 3000 -w db.json
volumes: init: true
- ./data:/data ports:
restart: always - "3000:3000"
volumes:
- ./data:/data
restart: unless-stopped
``` ```
>> :warning: `init: true` is required. [read more][2]
## data/db.json ## data/db.json
```json ```json
@ -48,3 +53,4 @@ http GET :3000/db
``` ```
[1]: https://github.com/typicode/json-server [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: version: "3.8"
image: vimagick/json-server services:
command: -H 0.0.0.0 -p 3000 -w db.json json-server:
ports: image: vimagick/json-server
- "3000:3000" command: -H 0.0.0.0 -p 3000 -w db.json
volumes: init: true
- ./data:/data ports:
restart: always - "3000:3000"
volumes:
- ./data:/data
restart: unless-stopped