Skip to content

Running the code

Akshay Katyal edited this page Jun 9, 2022 · 1 revision

We use docker-compose to run the code in the dev environment. All docker related code is in the docker folder. There are 2 ways to run the code:

  • Directly as a process
  • As a debug process which can be debugged using delve compatible launch configuration

TL DR;

cd docker
cp .env.local .env

# if you want to run directly
docker-compose up --build

# if you want to run with debugger
docker-compose -f docker-compose-debug.yml up --build
# Then, launch the Connect to Server configuration for the debugger

Then whenever you save any go file, the server automatically restarts.

Files

The following files are present in the docker folder:

.env.local

This is the environment file used for local development. When you want to start the service, all you need to do is:

cp .env.local .env

and you will get the environment setup for running the code locally.

.env.staging

This is the environment file used for staging env. Please make sure to update this file whenever you add a new env variable in the .env.local file.

Dockerfile

This is the dockerfile to run the code. It is used internally in the docker-compose file to build & run the code. In 99% of the cases, you don’t need to do anything with this file.

Dockerfile-debug

This is the dockerfile to run the code in debug mode with delve. It is used internally in the docker-compose-debug file to build & run the code. In 99% of the cases, you don’t need to do anything with this file.

This is the entry point for the Dockerfile. It essentially just starts the [modd](https://github.com/cortesi/modd) daemon so that auto-reload on saving works.

This is the entry point for the Dockerfile-debug. It essentially just starts the [modd](https://github.com/cortesi/modd) daemon so that auto-reload on saving works.

modd.conf

Configuration for modd daemon to build & run on save.

modd-debug.conf

Debug counterpart for modd.conf

docker-compose.yml

This is the main file that ties up all the dependencies together & runs the entire code. It contains database, nats and other dependencies & port mapping for all these services which are required for the code to run.

docker-compose-debug.yml

This is the main file that ties up all the dependencies together & runs the entire code in debug mode. It is exactly the same as docker-compose.yml but runs Dockerfile-debug instead of Dockerfile to run the code in debug mode.

.vscode/launch.json

This is the file which contains debugger launch configuration for vscode.

The main configuration which should be used to connect to the code running in debug mode is Connect to Server.