Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ECO-2700] Clean up environment variables, fix documentation, remove unused frontend container in Docker #522

Merged
merged 9 commits into from
Jan 29, 2025
49 changes: 22 additions & 27 deletions src/docker/README.md
Original file line number Diff line number Diff line change
@@ -9,20 +9,26 @@ build the processor, otherwise you will get errors.
git submodule update --init --recursive
```

Ensure that your environment variables are set, typically with an `.env`
file that mirrors the `example.local.env` or `example.testnet.env`, depending on
which environment you're running in.

Then you can follow the simple examples below showing how to run the processor
with and without an Aptos local fullnode.

## Run the indexer processor by itself
## Run the indexer processor by itself for `mainnet` or `testnet`

```shell
docker compose -f compose.yaml up
docker compose -f compose.yaml up --env-file example.testnet.env up -d
```

## Run a local Aptos fullnode as well
To run `mainnet` instead of `testnet` just pass `example.mainnet.env` as the
`--env-file` arg.

Note that you must change the `GRPC_AUTH_TOKEN` in `example.mainnet.env` and
`example.testnet.env` to a valid authentication token if you are going to run
those networks.

You can get a token at the [Aptos Labs developer portal].

Once the services are up, you have a functional emojicoin events indexer
processor and WebSockets broker, both at their respective ports specified in
each one's example.\*.env file.

## Run a local Aptos fullnode on the `local` network

Before you run the local testnet, ensure that your Docker Desktop settings are
correct. In your Docker Desktop settings, you must have enabled:
@@ -36,25 +42,13 @@ If you're using WSL 2, you must also enable both of these settings:
Now your container can run the localnet on the host network:

```shell
docker compose -f compose.local.yaml up
```

The `compose.local.yaml` file `include`s the `compose.yaml` file and
overwrites some settings like the order of dependencies for the services.

Note the order of the `include:` items in `compose.local.yaml` and where
the config overrides are placed.

## Running the frontend container

If you want to include the `frontend` container to run the frontend in a
`docker` container, without running a local testnet:

```shell
docker compose -f compose.yaml up --profile frontend
docker compose -f compose.local.yaml up -d
```

Note that the frontend is *not* included in the default services.
Once all the services are up, you not only have a functional emojicoin events
indexer processor and WebSockets broker, but you also have an Aptos localnet
fullnode running, with an indexer processor for all the default indexer
processors as well!

## Force restart the localnet

@@ -94,4 +88,5 @@ there's no reason we need to run `--force-restart` at runtime, the best way to
handle a restart is by removing the localnet test data directory prior to each
run as well as pruning all the related volumes, which is what [prune.sh] does.

[aptos labs developer portal]: https://developers.aptoslabs.com/
[prune.sh]: ./utils/prune.sh
57 changes: 0 additions & 57 deletions src/docker/compose.yaml
Original file line number Diff line number Diff line change
@@ -97,63 +97,6 @@ services:
ports:
- '${PROCESSOR_WS_PORT}:${PROCESSOR_WS_PORT}'

frontend:
extra_hosts:
- 'host.docker.internal:host-gateway'
build:
context: '../..'
dockerfile: 'src/docker/frontend/Dockerfile'
args:
HASH_SEED: '${HASH_SEED}'
EMOJICOIN_INDEXER_URL: 'http://host.docker.internal:3000'
NEXT_PUBLIC_APTOS_NETWORK: '${APTOS_NETWORK}'
NEXT_PUBLIC_INTEGRATOR_ADDRESS: '${EMOJICOIN_INTEGRATOR_ADDRESS}'
NEXT_PUBLIC_INTEGRATOR_FEE_RATE_BPS: '${FEE_RATE_BPS}'
NEXT_PUBLIC_IS_ALLOWLIST_ENABLED: 'false'
NEXT_PUBLIC_MODULE_ADDRESS: '${EMOJICOIN_MODULE_ADDRESS}'
NEXT_PUBLIC_ARENA_MODULE_ADDRESS: '${EMOJICOIN_ARENA_MODULE_ADDRESS}'
NEXT_PUBLIC_BROKER_URL: 'ws://host.docker.internal:${BROKER_PORT}'
NEXT_PUBLIC_REWARDS_MODULE_ADDRESS: >-
${EMOJICOIN_REWARDS_MODULE_ADDRESS}
REVALIDATION_TIME: '${REVALIDATION_TIME}'
image: 'econialabs/emojicoin-dot-fun:frontend'
container_name: 'frontend'
profiles:
- 'frontend'
environment:
HASH_SEED: '${HASH_SEED}'
EMOJICOIN_INDEXER_URL: 'http://host.docker.internal:3000'
NEXT_PUBLIC_APTOS_NETWORK: '${APTOS_NETWORK}'
NEXT_PUBLIC_INTEGRATOR_ADDRESS: '${EMOJICOIN_INTEGRATOR_ADDRESS}'
NEXT_PUBLIC_INTEGRATOR_FEE_RATE_BPS: '${FEE_RATE_BPS}'
NEXT_PUBLIC_IS_ALLOWLIST_ENABLED: 'false'
NEXT_PUBLIC_MODULE_ADDRESS: '${EMOJICOIN_MODULE_ADDRESS}'
NEXT_PUBLIC_ARENA_MODULE_ADDRESS: '${EMOJICOIN_ARENA_MODULE_ADDRESS}'
NEXT_PUBLIC_BROKER_URL: 'ws://host.docker.internal:${BROKER_PORT}'
NEXT_PUBLIC_REWARDS_MODULE_ADDRESS: '${EMOJICOIN_REWARDS_MODULE_ADDRESS}'
REVALIDATION_TIME: '${REVALIDATION_TIME}'
NEXT_PUBLIC_LOCAL_APTOS_API_KEY: '${FRONTEND_LOCAL_APTOS_API_KEY}'
NEXT_PUBLIC_CUSTOM_APTOS_API_KEY: '${FRONTEND_CUSTOM_APTOS_API_KEY}'
NEXT_PUBLIC_DEVNET_APTOS_API_KEY: '${FRONTEND_DEVNET_APTOS_API_KEY}'
NEXT_PUBLIC_TESTNET_APTOS_API_KEY: '${FRONTEND_TESTNET_APTOS_API_KEY}'
NEXT_PUBLIC_MAINNET_APTOS_API_KEY: '${FRONTEND_MAINNET_APTOS_API_KEY}'
healthcheck:
test: 'curl -f http://localhost:3001/ || exit 1'
interval: '30s'
timeout: '1s'
retries: '1'
start_period: '20s'
start_interval: '1s'
ports:
- '3001:3001'
depends_on:
postgrest:
condition: 'service_started'
broker:
condition: 'service_healthy'

restart: 'unless-stopped'

volumes:
db:
driver: 'local'
95 changes: 25 additions & 70 deletions src/docker/example.local.env
Original file line number Diff line number Diff line change
@@ -1,60 +1,35 @@
# The Aptos network to use.
# - mainnet
# - testnet
# - devnet
# - local
APTOS_NETWORK="local"
# cspell:word localnet

# This is the package address of the main module address.
# ---------------------------------------------------------------------------- #
# Aptos network & contract addresses, starting version
#
# - It must start with `0x`
# - Remove all leading 0s after the `0x`.
# - Examples:
# - GOOD: 0xabc
# - BAD: 0x0abc
# - BAD: abc
# - BAD: 0abc
# These should all match their respective `NEXT_PUBLIC_*` counterparts in
# src/typescript/.env
#
# All addresses should conform to AIP-40 long form, with leading 0s and a
# leading `0x`.
# See: https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md
# ---------------------------------------------------------------------------- #
EMOJICOIN_MODULE_ADDRESS="0xf000d910b99722d201c6cf88eb7d1112b43475b9765b118f289b5d65d919000d"

# This is the package address of the rewards wrapper smart contract.
EMOJICOIN_REWARDS_MODULE_ADDRESS="0xf000d910b99722d201c6cf88eb7d1112b43475b9765b118f289b5d65d919000d"

# This is the address that receives fees generated by any `emojicoin_dot_fun`
# smart contract. It is passed to the rewards contract at compile time, but
# used in all other contexts at runtime.
EMOJICOIN_INTEGRATOR_ADDRESS="0xf000d910b99722d201c6cf88eb7d1112b43475b9765b118f289b5d65d919000d"

# This is the package address of the arena module.
EMOJICOIN_ARENA_MODULE_ADDRESS="0xf000d910b99722d201c6cf88eb7d1112b43475b9765b118f289b5d65d919000d"

# The GRPC endpoint from which the indexer receives event data. Aptos Labs
# runs several public endpoints, listed below.
# The transaction version to start indexing at. Most often this should just be
# the transaction version where the `emojicoin_dot_fun` module is published.
MINIMUM_STARTING_VERSION="0"

# ---------------------------------------------------------------------------- #
# GRPC endpoint & authentication token
#
# mainnet: https://grpc.mainnet.aptoslabs.com:443
# testnet: https://grpc.testnet.aptoslabs.com:443
# devnet: https://grpc.devnet.aptoslabs.com:443
# local: http://host.docker.internal:50051
# The GRPC endpoint from which the indexer receives event data.
#
# NOTE: If you get errors connecting to `host.docker.internal` and you're
# using Docker Desktop on WSL2 (Windows Subsystem for Linux), you need to make
# sure you enable the `WSL 2 based engine` setting and the `Add the
# *.docker.internal names to the host's /etc/hosts file` setting.
# You *also* need to enable the experimental `Enable host networking` feature.
# > To enable this feature, navigate to the Features in development tab in
# > Settings, and then select Enable host networking.
# See: https://docs.docker.com/engine/network/tutorials/host/
# And: https://docs.docker.com/desktop/windows/permission-requirements/
# You do not need to provide a valid GRPC_AUTH_TOKEN for a local network.
# ---------------------------------------------------------------------------- #
GRPC_DATA_SERVICE_URL="http://host.docker.internal:50051"
GRPC_AUTH_TOKEN="_" # Not used locally, but must at least be one character.

# For a public chain you have to get this token from https://developers.aptoslabs.com/.
# For local end-to-end testing you can use: "dummy_token"
GRPC_AUTH_TOKEN="dummy_token"

# The minimum transaction version at which to start indexing.
# Events that occur prior to this transaction version will not be indexed.
# This is most often set to the transaction version where the package is published.
MINIMUM_STARTING_VERSION="0"

# ---------------------------------------------------------------------------- #
# Miscellaneous indexer processor configurations
# ---------------------------------------------------------------------------- #
# A hard limit to the number of rows PostgREST will fetch from a view, table, or stored procedure.
# Limits payload size for accidental or malicious requests.
POSTGREST_MAX_ROWS="500"
@@ -65,25 +40,5 @@ PROCESSOR_WS_PORT="3008"
# The port the broker listens on for client connections.
BROKER_PORT="3009"

# The private key used to deploy the package locally for tests.
# Note that this private key is obviously public and should never be used in
# production or for any real value transactions.
# If you change this, local tests will fail unless you also change the
# corresponding `*_ADDRESS` values that are derived from this key.
PUBLISHER_PRIVATE_KEY="0xeaa964d1353b075ac63b0c5a0c1e92aa93355be1402f6077581e37e2a846105e"

# The caching time for server-side requests for the NextJS web application.
REVALIDATION_TIME="1"

# The integrator fee rate basis points.
FEE_RATE_BPS="100"

# Secret hash seed.
HASH_SEED="some random string that is not public"

# Set the API keys for the various frontend networks. It is okay if these are exposed publicly.
FRONTEND_LOCAL_APTOS_API_KEY=""
FRONTEND_CUSTOM_APTOS_API_KEY=""
FRONTEND_DEVNET_APTOS_API_KEY="AG-MSPVZN9BNPNB6KWSPZN7GHSETJU2TFLHJ" # cspell:disable-line
FRONTEND_TESTNET_APTOS_API_KEY="AG-FRGKQEVCNY5PDJKZBAVTVCPGEQ6YFUBBX" # cspell:disable-line
FRONTEND_MAINNET_APTOS_API_KEY="AG-BAGXRD2QME5WFTBZVAR4BPA7M5EGTBRHQ" # cspell:disable-line
# The private key of the publisher for the emojicoin contracts.
PUBLISHER_PRIVATE_KEY="eaa964d1353b075ac63b0c5a0c1e92aa93355be1402f6077581e37e2a846105e"
41 changes: 41 additions & 0 deletions src/docker/example.mainnet.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# cspell:word localnet

# ---------------------------------------------------------------------------- #
# Aptos network & contract addresses, starting version
#
# These should all match their respective `NEXT_PUBLIC_*` counterparts in
# src/typescript/.env
#
# All addresses should conform to AIP-40 long form, with leading 0s and a
# leading `0x`.
# See: https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md
# ---------------------------------------------------------------------------- #
EMOJICOIN_MODULE_ADDRESS="0xface729284ae5729100b3a9ad7f7cc025ea09739cd6e7252aff0beb53619cafe"
EMOJICOIN_ARENA_MODULE_ADDRESS="NOT_ON_MAINNET_YET"

# The transaction version to start indexing at. Most often this should just be
# the transaction version where the `emojicoin_dot_fun` module is published.
MINIMUM_STARTING_VERSION="1943970510"

# ---------------------------------------------------------------------------- #
# GRPC endpoint & authentication token
#
# The GRPC endpoint from which the indexer receives event data.
#
# You must provide a valid GRPC_AUTH_TOKEN. See https://developers.aptoslabs.com
# ---------------------------------------------------------------------------- #
GRPC_DATA_SERVICE_URL="https://grpc.mainnet.aptoslabs.com:443"
GRPC_AUTH_TOKEN="MUST_PROVIDE_TOKEN_HERE"

# ---------------------------------------------------------------------------- #
# Miscellaneous indexer processor configurations
# ---------------------------------------------------------------------------- #
# A hard limit to the number of rows PostgREST will fetch from a view, table, or stored procedure.
# Limits payload size for accidental or malicious requests.
POSTGREST_MAX_ROWS="500"

# The port the processor and broker use to communicate.
PROCESSOR_WS_PORT="3008"

# The port the broker listens on for client connections.
BROKER_PORT="3009"
80 changes: 22 additions & 58 deletions src/docker/example.testnet.env
Original file line number Diff line number Diff line change
@@ -1,55 +1,35 @@
# The Aptos network to use.
# - mainnet
# - testnet
# - devnet
# - local
APTOS_NETWORK="testnet"
# cspell:word localnet

# This is the package address of the main module address.
# ---------------------------------------------------------------------------- #
# Aptos network & contract addresses, starting version
#
# - It must start with `0x`
# - Remove all leading 0s after the `0x`.
# - Examples:
# - GOOD: 0xabc
# - BAD: 0x0abc
# - BAD: abc
# - BAD: 0abc
# These should all match their respective `NEXT_PUBLIC_*` counterparts in
# src/typescript/.env
#
# All addresses should conform to AIP-40 long form, with leading 0s and a
# leading `0x`.
# See: https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md
# ---------------------------------------------------------------------------- #
EMOJICOIN_MODULE_ADDRESS="0x11113ddc70ea051ffd8a7cde7b96818326aabf56fdfd47807f7700e2b46e1111"

# This is the package address of the rewards wrapper smart contract.
EMOJICOIN_REWARDS_MODULE_ADDRESS="0x22227920701e36651a6649be2067cd7eebf3fabb94717ff3b256e3ada58b2222"

# This is the package address of the arena module.
# NOTE: This is not the same as the REWARDS address.
EMOJICOIN_ARENA_MODULE_ADDRESS="0x2222e4c4788e34e21bacad364855f5e648c19f4643f20f22f507334d041c2222"

# This is the address that receives fees generated by any `emojicoin_dot_fun`
# smart contract. It is passed to the rewards contract at compile time, but
# used in all other contexts at runtime.
EMOJICOIN_INTEGRATOR_ADDRESS="0x33332c9ea4c220e0572b7f83f397164f8171e1c9f681136bb8ab78efa6c43333"
# The transaction version to start indexing at. Most often this should just be
# the transaction version where the `emojicoin_dot_fun` module is published.
MINIMUM_STARTING_VERSION="5675600000"

# The GRPC endpoint from which the indexer receives event data. Aptos Labs
# runs several public endpoints, listed below.
# ---------------------------------------------------------------------------- #
# GRPC endpoint & authentication token
#
# mainnet: https://grpc.mainnet.aptoslabs.com:443
# testnet: https://grpc.testnet.aptoslabs.com:443
# devnet: https://grpc.devnet.aptoslabs.com:443
# local: http://host.docker.internal:50051
# The GRPC endpoint from which the indexer receives event data.
#
# NOTE: If you get errors connecting to `host.docker.internal` on Docker Desktop
# for WSL 2, see the explanation in `example.local.env` on which configuration
# settings you need to enable.
# You must provide a valid GRPC_AUTH_TOKEN. See https://developers.aptoslabs.com
# ---------------------------------------------------------------------------- #
GRPC_DATA_SERVICE_URL="https://grpc.testnet.aptoslabs.com:443"
GRPC_AUTH_TOKEN="MUST_PROVIDE_TOKEN_HERE"

# For a public chain you have to get this token from https://developers.aptoslabs.com/.
# For local end-to-end testing you can use: "dummy_token"
GRPC_AUTH_TOKEN="dummy_token"

# The minimum transaction version at which to start indexing.
# Events that occur prior to this transaction version will not be indexed.
# This is most often set to the transaction version where the package is published.
MINIMUM_STARTING_VERSION="5675600000"

# ---------------------------------------------------------------------------- #
# Miscellaneous indexer processor configurations
# ---------------------------------------------------------------------------- #
# A hard limit to the number of rows PostgREST will fetch from a view, table, or stored procedure.
# Limits payload size for accidental or malicious requests.
POSTGREST_MAX_ROWS="500"
@@ -59,19 +39,3 @@ PROCESSOR_WS_PORT="3008"

# The port the broker listens on for client connections.
BROKER_PORT="3009"

# The caching time for server-side requests for the NextJS web application.
REVALIDATION_TIME="1"

# The integrator fee rate basis points.
FEE_RATE_BPS="100"

# Secret hash seed.
HASH_SEED="some random string that is not public"

# Set the API keys for the various frontend networks. It is okay if these are exposed publicly.
FRONTEND_LOCAL_APTOS_API_KEY=""
FRONTEND_CUSTOM_APTOS_API_KEY=""
FRONTEND_DEVNET_APTOS_API_KEY="AG-MSPVZN9BNPNB6KWSPZN7GHSETJU2TFLHJ" # cspell:disable-line
FRONTEND_TESTNET_APTOS_API_KEY="AG-FRGKQEVCNY5PDJKZBAVTVCPGEQ6YFUBBX" # cspell:disable-line
FRONTEND_MAINNET_APTOS_API_KEY="AG-BAGXRD2QME5WFTBZVAR4BPA7M5EGTBRHQ" # cspell:disable-line
Loading