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

The run command reported in the README is incorrect #206

Open
andrea-gioia opened this issue Jan 20, 2025 · 0 comments
Open

The run command reported in the README is incorrect #206

andrea-gioia opened this issue Jan 20, 2025 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@andrea-gioia
Copy link
Contributor

andrea-gioia commented Jan 20, 2025

In the README section Run with Docker, there are several problems:

  1. the command to build the image is incorrect. The Dockerfile is not located in the project root but in the subdirectories of each modules. For example, the Dockerfile for building the registry service image can be found in product-plane-services/registry-server.
  2. the example only demonstrates how to run a single service (i.e., the registry) and does not explain how to run the entire platform. It would be helpful to clarify this and include instructions on running multiple services together, such as the registry and policy services.
  3. The command to run the container on Windows does not work because the --net host option behaves differently in WSL 2 compared to native Linux due to the virtualized nature of the WSL 2 network. This means that on Windows when using --net host, ports cannot be forwarded, and as a result, even if the container runs correctly, it is not accessible from the Windows host

The following instructions fix the problem mentioned above....

Build image

Build the Docker image of the application and run it.

Before executing the following commands change properly the value of arguments DATABASE_USERNAME, DATABASE_PASSWORD and DATABASE_URL. Reported commands already contains right argument values if you have created the database using the commands above.

MySql

docker build -t odmp-mysql-app . -f product-plane-services/registry-server/Dockerfile \
   --build-arg DATABASE_URL=jdbc:mysql://localhost:3306/ODMREGISTRY \
   --build-arg DATABASE_USERNAME=root \
   --build-arg DATABASE_PASSWORD=root \
   --build-arg FLYWAY_SCRIPTS_DIR=mysql

Postgres

docker build -t odmp-postgres-app . -f product-plane-services/registry-server/Dockerfile\
   --build-arg DATABASE_URL=jdbc:postgresql://localhost:5432/odmpdb \
   --build-arg DATABASE_USERNAME=postgres \
   --build-arg DATABASE_PASSWORD=postgres \
   --build-arg FLYWAY_SCRIPTS_DIR=postgresql

On Windows replace localhost with host.docker.internal

Run application

Run the Docker image.

Note: Before executing the following commands

  1. remove the argument --net host if the database is not running on localhost
  2. replace --net host with --add-host=host.docker.internal:host-gateway if you are running the container on windows

MySql

docker run --name odmp-mysql-app -p 8001:8001 --add-host=host.docker.internal:host-gateway odmp-mysql-app

Postgres

docker run --name odmp-postgres-app -p 8001:8001 --add-host=host.docker.internal:host-gateway odmp-postgres-app

Another solution that works on both Windows and Linux is to use a shared network bridge between the two containers. These are the commands to run the registry on PostgreSQL...

docker network create odmp-network

docker run --name odmp-postgres-db -d - --network odmp-network p 5432:5432  \
   -e POSTGRES_DB=odmpdb \
   -e POSTGRES_USER=postgres \
   -e POSTGRES_PASSWORD=postgres \
   postgres:11-alpine

docker build -t odmp-postgres-app . -f product-plane-services/registry-server/Dockerfile\
   --build-arg DATABASE_URL=jdbc:postgresql://odmp-postgres-db:5432/odmpdb \
   --build-arg DATABASE_USERNAME=postgres \
   --build-arg DATABASE_PASSWORD=postgres \
   --build-arg FLYWAY_SCRIPTS_DIR=postgresql

docker run --name odmp-postgres-app  --network odmp-network -p 8001:8001 odmp-postgres-app
@andrea-gioia andrea-gioia added the documentation Improvements or additions to documentation label Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants