Skip to content

Commit

Permalink
Add a standalone docker-compose file, update readme
Browse files Browse the repository at this point in the history
fixes #266
  • Loading branch information
latenssi committed Feb 23, 2022
1 parent 746ebb3 commit 438291a
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 15 deletions.
22 changes: 7 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,31 +46,23 @@ docker pull ghcr.io/flow-hydraulics/flow-wallet-api:latest

### Basic example usage

> This setup requires [Docker](https://docs.docker.com/engine/install/) and the [Flow CLI](https://docs.onflow.org/flow-cli/install/).
**NOTE:** This setup is only for demostrative purposes, please do not run this on production

This setup requires [Docker](https://docs.docker.com/engine/install/), [Docker Compose](https://docs.docker.com/compose/install/) and the [Flow CLI](https://docs.onflow.org/flow-cli/install/).

Create a configuration file:

```sh
cp .env.example .env
cp .env.example .env # and edit
```

Start the Wallet API, Flow Emulator and Postgres:
Start the Wallet API, Flow Emulator, Postgres and Redis:

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

Deploy the FUSD contract to the emulator:

```sh
flow project deploy -n emulator
```

You can now access the API at http://localhost:3000/v1/accounts.

Next, see the [FUSD sample app](/examples/nextjs-fusd-provider)
for an example of how to use this configuration as part of
a complete application.
You can now access the API at http://localhost:3000/v1.

Once you're finished, run this to stop the containers:

Expand Down Expand Up @@ -318,7 +310,7 @@ with support from the Flow core contributors.

## Testing

You can run a fully dockerized test suite if you have _Docker_ and _docker-compose_ installed.
You can run a fully dockerized test suite if you have _Docker_ and _Docker Compose_ installed.

# Run the test suite
make run-test-suite
Expand Down
84 changes: 84 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
version: "3.9"

networks:
private:

volumes:
emulator-persist:

services:
db:
image: postgres:13-alpine
environment:
POSTGRES_DB: wallet
POSTGRES_USER: wallet
POSTGRES_PASSWORD: wallet
networks:
- private
healthcheck:
test:
[
"CMD-SHELL",
"pg_isready --username=${POSTGRES_USER:-wallet} --dbname=${POSTGRES_DB:-wallet}",
]
interval: 10s
timeout: 5s
retries: 10

redis:
image: redis:6.2-alpine
command: redis-server /usr/local/etc/redis/redis.conf
volumes:
- ./redis-config/redis.conf:/usr/local/etc/redis/redis.conf
- ./redis-config/users.acl:/usr/local/etc/redis/users.acl
networks:
- private
healthcheck:
test:
[
"CMD-SHELL",
"redis-cli ping",
]
interval: 10s
timeout: 5s
retries: 10

emulator:
image: gcr.io/flow-container-registry/emulator:0.27.3
command: emulator --persist
volumes:
- emulator-persist:/flowdb
env_file:
- ./.env
environment:
FLOW_SERVICEPRIVATEKEY: ${FLOW_WALLET_ADMIN_PRIVATE_KEY}
FLOW_SERVICEKEYSIGALGO: ECDSA_P256
FLOW_SERVICEKEYHASHALGO: SHA3_256
FLOW_DBPATH: /flowdb
networks:
- private

api:
build:
context: .
dockerfile: ./docker/wallet/Dockerfile
target: dist
network: host # docker build sometimes has problems fetching from alpine's CDN
networks:
- private
ports:
- "3000:3000"
env_file:
- ./.env
environment:
FLOW_WALLET_DATABASE_DSN: postgresql://wallet:wallet@db:5432/wallet
FLOW_WALLET_DATABASE_TYPE: psql
FLOW_WALLET_ACCESS_API_HOST: emulator:3569
FLOW_WALLET_CHAIN_ID: flow-emulator
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
emulator:
condition: service_started

0 comments on commit 438291a

Please sign in to comment.