Coder Social home page Coder Social logo

zookeeper-tiny-url's Introduction

Zookeeper test with tiny URL

Dev setup to test the ID generation and interaction with Zookeeper

At this moment there is no actual database just an in memory stub, so it won't work really. But this is to test the ID generation part.

  1. Pull the Official ZooKeeper Docker Image Pull the latest ZooKeeper image from Docker Hub.
docker pull zookeeper
  1. Run the ZooKeeper Docker Container Start a ZooKeeper container from the pulled image, exposing port 2181.
docker run --name tiny-url-zookeeper --network=tinyurlnetwork -p 2181:2181 -d zookeeper
  1. Build the Application Docker Image Navigate to the directory containing your application's Dockerfile, then build a Docker image for the application.
docker build -t tiny-url-app .
  1. Run the Application Docker Containers Start two containers from your application's Docker image. These will connect to the ZooKeeper server using the container name as the hostname.
docker run -d --name=app-instance-1 --network=tinyurlnetwork -p 3001:3000 tiny-url-app
docker run -d --name=app-instance-2 --network=tinyurlnetwork -p 3002:3000 tiny-url-app

Remember to replace tinyurlnetwork with your Docker network name, tiny-url-zookeeper with your ZooKeeper container name, and tiny-url-app with your application's Docker image name. The -p flag maps the container's port to a port on your host machine, and the -d flag runs the container in detached mode.

  1. Accessing the Application With this setup, you should be able to access the two instances of your application at http://localhost:3001 and http://localhost:3002.

  2. Stopping and Removing Containers To stop and remove the containers when you're done, you can use:

docker stop app-instance-1 app-instance-2 tiny-url-zookeeper
docker rm app-instance-1 app-instance-2 tiny-url-zookeeper
  1. Removing the Docker Image If you want to remove the Docker image for your application, you can do so with:
docker rmi tiny-url-app

Next steps

  • Integrate with a NoSQL document DB
  • Better config management
  • Deploy using AWS

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.