Skip to content

UNIBUC-PROD-ENGINEERING/service

Repository files navigation

Prerequisites

For using Github Codespaces, no prerequisites are mandatory. Follow the ./PREREQUISITES.md instructions to configure a local virtual machine with Ubuntu, Docker, IntelliJ.

Access the code

Run code in Github Codespaces

  • Make sure that the Github repository is forked under your account / Organization
  • Create a new Codespace from your forked repository
  • Wait for the Codespace to be up and running
  • Make sure that Docker service has been started
    • docker ps should return no error
  • For running all services in docker:
    • Build the docker image of the hello world service
      • make build
    • Start all the service containers
      • ./start.sh
  • For running / debugging directly in Visual Studio Code
    • Start the MongoDB related services
      • ./start_mongo_only.sh
    • Start the Spring Boot service by clicking Run button inside Visual Studio Code

NOTE: for a live demo, please check out this youtube video

Run/debug code in IntelliJ

  • Build the code
    • IntelliJ will build it automatically
    • If you want to build it from command line and also run unit tests, run: ./gradlew build
  • Create an IntelliJ run configuration for a Jar application
    • Add in the configuration the JAR path to the build folder ./build/libs/hello-0.0.1-SNAPSHOT.jar
  • Start the MongoDB container using docker compose
    • docker-compose up -d mongo
  • Run/debug your IntelliJ run configuration
  • Open in your browser:

Deploy and run the code locally as docker instance

  • Build the docker image of the hello world service

    • make build
  • Start all the containers

    • ./start.sh
  • Verify that all containers started, by running

    service git:(master) ✗  $ docker ps
    CONTAINER ID   IMAGE           COMMAND                  CREATED         STATUS         PORTS                      NAMES
    c1d05dddd3fe   mongo:5.0.2     "docker-entrypoint.s…"   6 seconds ago   Up 5 seconds   0.0.0.0:27017->27017/tcp   service_mongo_1
    e90bb406c139   hello-img       "java -jar /hello/li…"   6 seconds ago   Up 5 seconds   0.0.0.0:8080->8080/tcp     service_hello_1
    411475a7b596   mongo-express   "tini -- /docker-ent…"   6 seconds ago   Up 2 seconds   0.0.0.0:8090->8081/tcp     service_mongo-admin-ui_1
    
  • Open in your browser:

  • You can access the MongoDB Admin UI at: