docker file for app

readme update for docker

added dockerignore

added dumb-init

env var added to compose

readme update

Signed-off-by: sapthasurendran <saptha.surendran@ibm.com>
This commit is contained in:
sapthasurendran 2021-08-03 12:38:27 +05:30 committed by James Taylor
parent 4277f4a68f
commit 73049e0153
4 changed files with 69 additions and 0 deletions

View file

@ -105,3 +105,22 @@ curl --include --header "Content-Type: application/json" --header "X-Api-Key: ${
```shell ```shell
curl --include --header "X-Api-Key: ${SAMPLE_APIKEY}" --request DELETE http://localhost:3000/api/assets/asset7 curl --include --header "X-Api-Key: ${SAMPLE_APIKEY}" --request DELETE http://localhost:3000/api/assets/asset7
``` ```
## Steps to run the application using docker:
Move to directory fabric-rest-sample/asset-transfer-basic/rest-api-typescript
### Build docker image
docker build -t fabricapp .
### Generate .env file
TEST_NETWORK_HOME=$HOME/fabric-samples/test-network ./scripts/generateEnv.sh
Note: Connection profile need to use the peer containers hostname instead of localhost.
### Run docker containers
docker-compose up -d

View file

@ -0,0 +1,4 @@
node_modules
npm-debug.log
Dockerfile
.gitignore

View file

@ -0,0 +1,20 @@
FROM node:14-alpine3.12
RUN apk add dumb-init
WORKDIR /fabric_app/
COPY --chown=node:node . /fabric_app/
RUN npm ci
RUN npm run build
EXPOSE 3000
USER node
CMD dumb-init npm run start:dev

View file

@ -0,0 +1,26 @@
version: '3'
# Replace network name with the fabric test-network name
services:
redis:
image: 'redis'
ports:
- 6379:6379
networks:
- net_test
nodeapp:
image: 'fabricapp'
ports:
- 3000:3000
env_file:
- ./.env
environment:
- REDIS_HOST=redis
- AS_LOCAL_HOST=false
networks:
- net_test
networks:
net_test:
external: true