Skip to main content

Coinweb Devnet Docker Container

DEVNET

This functionality is meant to be only available for development.

DEVELOPMENT

This functionality is currently in development and can change.

React smart contracts and other engineering components that rely on a development environment can be built independent from Coinweb's official Devnet network by running the Devnet locally in a docker container. This section covers the installation and utilisation of the Devnet container in detail.

VSCode

Modern IDEs offer the possibility to develop directly inside a dev container. If you develop with VSCode you can follow this documentation that explains the utilisation of Coinweb's Devnet Container using VSCode and the related plugins.

Installation

The devnet container is publicly available via the Scaleway registry. It can generally be downloaded via Docker pull and/or composed. This following section is a step by step guidance that helps you set it up manually.

Prerequisites

Docker is mandatory in order to set up the Devnet environment locally. You can learn more about Docker here.

Presets

In order to manually set up the Docker container you will have to create two files that are necessary for managing user permissions within your local Devnet.

gid + uid
# Retrieve the user ID of the current user and save it to a file named 'uid'
echo $(id -u) > .devcontainer/uid

# Retrieve the group ID of the current user and save it to a file named 'gid'
echo $(id -g) > .devcontainer/gid

These files should contain the host's ids of your user and group and will be used in the prepare-user.sh script. You can expand the dropdown below and copy paste the code of the script. Files are used, because UID and GID host's environment variables are not always available to read.

Dockerfile

The Dockerfile builds a container from the Devnet image accordingly and executed the prepare-user.sh script with the provided host's UID and GID inside the container.

note

The script and the files mentioned above are supposed to be present in the same directory as the Dockerfile.

Dockerfile

FROM rg.fr-par.scw.cloud/coinweb-devnet/main:latest AS devnet
COPY gid uid prepare-user.sh /tmp/
RUN /tmp/prepare-user.sh "$(cat /tmp/gid)" "$(cat /tmp/uid)"
RUN npm install --location=global corepack typescript

Docker Compose

note

The script, Dockerfile and the ID files mentioned above are supposed to be present in the same directory as the docker-compose.yml.

The "easiest" way to set up the Devnet Container locally is to use docker compose.

docker-compose.yml
version: '3.1'
name: coinweb-devnet
services:
postgres:
# Using alpine as it smaller in size.
image: postgres:16.1-alpine
environment:
POSTGRES_DB: devnet
POSTGRES_PASSWORD: devnet
POSTGRES_USER: devnet
devnet:
image: .
environment:
API_ENDPOINT_DEVNET: http://localhost:5000/wallet
NODE_ENV: development
links:
- postgres
volumes:
- ..:/workspace:cached
ports:
- 5000:5100 # API
- 5001:5101 # DevTools
- 5002:5102 # Explorer
- 5003:5103 # LinkMint

Starting Devnet Container

Change the current directory to the directory where all the mentioned files above are present. Preferably the folder should be named .devcontainer and be located inside your project.

docker-compose up
Loading asciinema cast...

Clean Up

The easiest way to clean up the container is to stop and remove all related images.

docker-compose down --rmi=all
Loading asciinema cast...

Issues

Ports are not available

The forwarded ports are hardcoded in the docker-compose.yml file. You can modify them accordingly.

DEVELOPMENT

Some encapsulated services may still try to use the default ports for communication with the backend. We are working on it.