Skip to content

Commit

Permalink
feat: Docker image and docker-compose example
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed May 14, 2020
1 parent 60382ee commit 84ddcad
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
npm-debug.log
examples
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM node:10
WORKDIR /usr/src/app
COPY . .
RUN yarn
RUN yarn bootstrap
RUN yarn build
ENTRYPOINT ["./packages/daf-cli/bin/daf.js"]
43 changes: 43 additions & 0 deletions examples/docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Usage

## Help

```
docker-compose run daf -h
```

## Create identity

```
docker-compose run daf identity-manager -c
```


## Start GraphQL server

```
docker-compose up -d
```

open http://localhost:8080

If you set `DAF_GRAPHQL_API_KEY` in `docker-compose.yml`, you will need to add HTTP `Authorization` header to your GraphQL API calls.
Example:

```
DAF_GRAPHQL_API_KEY=ABC123
```

```
{
"Authorization": "Bearer ABC123"
}
```



## Stop

```
docker-compose down
```
47 changes: 47 additions & 0 deletions examples/docker/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
var fs = require('fs')

module.exports = {
identityProviders: [
{
package: 'daf-ethr-did',
network: 'rinkeby',
rpcUrl: 'https://rinkeby.infura.io/v3/' + process.env.DAF_INFURA_ID,
gas: 10001,
ttl: 60 * 60 * 24 * 30 * 12 + 1,
},
{
package: 'daf-elem-did',
network: 'ropsten',
apiUrl: 'https://element-did.com/api/v1/sidetree',
},
],
ethrDidNetworks: [
{
name: 'mainnet',
rpcUrl: 'https://mainnet.infura.io/v3/' + process.env.DAF_INFURA_ID
},
{
name: 'rinkeby',
rpcUrl: 'https://rinkeby.infura.io/v3/' + process.env.DAF_INFURA_ID
},

],
// https://typeorm.io/#/connection-options
database: {
type: 'sqlite',
synchronize: !fs.existsSync(process.env.DAF_DATA_STORE),
database: process.env.DAF_DATA_STORE,
logging: process.env.DAF_DEBUG_DB === 'true' ? true : false,
migrationsRun: true,
},
graphql: {
apiKey: process.env.DAF_GRAPHQL_API_KEY,
resolvers: {
IdentityManager: true,
TrustGraph: false,
DIDComm: true,
W3c: true,
Sdr: true,
}
}
}
20 changes: 20 additions & 0 deletions examples/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: "3"

services:
daf:
image: uport/daf:latest
ports:
- 8080:8080/tcp
environment:
- DAF_CONFIG=/config/config.js
- DAF_DATA_STORE=/config/database.sqlite
- DAF_GRAPHQL_API_KEY=
- DAF_INFURA_ID=5ffc47f65c4042ce847ef66a3fa70d4c
- DAF_SECRET_KEY=d72629cfd01e8e64762808a37e29d63103ef5cb7e92888afb9d4c0a6426c933e
command:
[
"graphql",
"--port=8080"
]
volumes:
- .:/config
1 change: 0 additions & 1 deletion packages/daf-cli/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const writeDefaultEnv = async () => {
}

if (!fs.existsSync(envFile)) {
console.log('Environment file does not exist. Creating: ' + envFile)
let env = 'DAF_DATA_STORE=' + defaultPath + 'database-v2.sqlite'
env += '\nDAF_DEBUG_DB=false'
env += '\nDAF_SECRET_KEY=' + (await SecretBox.createSecretKey())
Expand Down

0 comments on commit 84ddcad

Please sign in to comment.