mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 15:35:09 +00:00
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:
parent
4277f4a68f
commit
73049e0153
4 changed files with 69 additions and 0 deletions
19
README.md
19
README.md
|
|
@ -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 container’s hostname instead of localhost.
|
||||||
|
|
||||||
|
### Run docker containers
|
||||||
|
docker-compose up -d
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
4
asset-transfer-basic/rest-api-typescript/.dockerignore
Normal file
4
asset-transfer-basic/rest-api-typescript/.dockerignore
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
node_modules
|
||||||
|
npm-debug.log
|
||||||
|
Dockerfile
|
||||||
|
.gitignore
|
||||||
20
asset-transfer-basic/rest-api-typescript/Dockerfile
Normal file
20
asset-transfer-basic/rest-api-typescript/Dockerfile
Normal 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
26
asset-transfer-basic/rest-api-typescript/docker-compose.yaml
Normal file
26
asset-transfer-basic/rest-api-typescript/docker-compose.yaml
Normal 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
|
||||||
Loading…
Reference in a new issue