Skip to main content

Technical Documentation: Docker Build and Running Frontend Server

This document provides instructions on how to build and run a frontend server in Docker. Ensure Docker is installed on your system before proceeding.

Prerequisites

  • Docker installed on your system. You can follow the instructions on the official Docker website to install Docker: Docker Installation Guide.

Setting Up Staging Environment

  1. Create and configure the staging environment file:

    Create a file named docker-staging.env in the config/staging/ directory and set the environment variables as shown below:

    #
    # HOSTNAME = docker.for.mac.localhost
    ###docker.for.mac.localhost

    NATS_USER=test
    NATS_PW=test
    NATS_URL=nats://docker.for.mac.localhost:4222/
    GRAPHQL_URL=http://docker.for.mac.localhost:8080/graphql
    LOCAL_GRAPHQL_URL=http://docker.for.mac.localhost:8080/graphql
    MONGO_URL=mongodb://docker.for.mac.localhost:27017/sample-stack
    REDIS_CLUSTER_URL='[{"port":6379,"host":"docker.for.mac.localhost"}]'
    REDIS_URL=redis://docker.for.mac.localhost:6379
    BACKEND_URL=http://docker.for.mac.localhost:8080
    CLIENT_URL=http://localhost:3000
    ZIPKIN_URL=test
    ZIPKIN_PORT=test
    LOG_LEVEL=trace
    REDIS_CLUSTER_ENABLED=false
    REDIS_SENTINEL_ENABLED=false
    BACKEND_URL=http://localhost:8080
    CONNECTION_ID=v1
    LOCAL_BACKEND_URL=http://localhost:3000
    ... add remaining env variables, make sure don't override above ones.
  2. Ensure all necessary services are available at the specified URLs in the docker-staging.env file.

Branch Management

  • Switch to the devpublish* branch:

    If you are working on the develop7 branch, the corresponding publish branch will be devpublish7. Switch to the appropriate devpublish* branch.

    git checkout devpublish7
  • Note: The devpublish* branch should be read-only. Any changes that need to be tested should be made in the corresponding develop* branch. If new packages need to be released, please request the admin to publish the packages.

Building and Running the Frontend Server in Docker

  1. Build the Docker image and run the frontend server:

    Open a terminal and navigate to the root directory of your project.

  2. Execute the following command:

    lerna exec --scope="*frontend-server" yarn docker:build && lerna exec --scope="*frontend-server" yarn docker:run

This command will:

  • Build the Docker image for the frontend server.
  • Run the Docker container for the frontend server.

Additional Notes

  • Ensure that all dependent services (e.g., NATS, MongoDB, Redis) are running and accessible at the specified URLs in the environment file.
  • The CLIENT_URL and BACKEND_URL values should be correctly set to match your local setup or desired staging environment.

By following these steps, you should be able to successfully build and run the frontend server in Docker using the provided environment configuration.