Giter VIP home page Giter VIP logo

demo-docker-k8s's Introduction

Workshop Docker and Kubernetes

Software requirements

Step 1 :: Building User service with Docker

$cd services/user
$docker image build -t user .
$docker container run --rm -p 3000:3000 \
 -e PROCESS_TYPE=web \
 -e NODE_ENV=production \
 -e DB_HOST=xxx \
 -e DB_USER=xxx \
 -e DB_PASSWORD=xxx \
 -e DB_DATABASE=xxx \
 -e DB_PORT=3306 \
 user

Working with docker compose

  • Create database
  • Seeding data to database (create tables)
  • Start user service
// Create
$docker-compose up -d

// Delete
$docker-compose down

API Testing with Postman by using newman command

$cd testing
$newman run user-service.postman_collection.json

Step 2 :: Building Product service with Docker

$cd services/product
$docker image build -t product .
$docker container run --rm -p 3000:3000 \
 -e PROCESS_TYPE=web \
 -e NODE_ENV=production \
 -e DB_HOST=xxx \
 -e DB_USER=xxx \
 -e DB_PASSWORD=xxx \
 -e DB_DATABASE=xxx \
 -e DB_PORT=3306 \
 product

Working with docker compose

  • Create database
  • Seeding data to database (create tables)
  • Start product service
// Create
$docker-compose up -d

// Delete
$docker-compose down

API Testing with Postman by using newman command

$cd testing
$newman run product-service.postman_collection.json

Step 3 :: Building API gateway for User services with Docker

$cd gateway
$docker image build -t gateway .
$docker container run --rm -p 3001:3000 \
 -e JWT_SECRET=secret \
 -e USER_WEB_SERVICE_HOST=xxx \
 -e USER_WEB_SERVICE_PORT=3000 \
 -e PRODUCT_WEB_SERVICE_HOST=yyy \
 -e PRODUCT_WEB_SERVICE_PORT=3000 \
 gateway

Call API from Gateway

Step 4 :: Building Frontend with Docker

$cd frontend
$docker image build -t frontend .
$docker container run --rm -p 3002:3000 frontend

Open url=http://localhost:3002/login in browser

Step 5 :: Run All-in-one with Docker compose

Build and deploy

$docker-compose -f docker-compose-build.yml build
$docker-compose -f docker-compose-build.yml up

// Delete all
$docker-compose -f docker-compose-build.yml down

Deploy only

$docker-compose -f docker-compose-deploy.yml up

// Delete all
$docker-compose -f docker-compose-deploy.yml down

Open url=http://localhost:3002/login in browser

demo-docker-k8s's People

Contributors

up1 avatar

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.