beyond-sw-camp / be01-101

Beyond SW camp first player 101
17 stars 2 forks source link

nginx proxy by famous jwilder #43

Open pySatellite opened 9 months ago

pySatellite commented 9 months ago

scale out/in -> auto lb

$ docker compose -f compose/auto_lb/compose.yml  up -d --build --force-recreate

$ docker compose -f compose/auto_lb/compose.yml ls                             
NAME                STATUS              CONFIG FILES
awsgoo              running(2)          /home/tom/code/k9s/compose/auto_lb/compose.yml

$ docker compose -f compose/auto_lb/compose.yml  up -d --scale blog=5

docker compose -f compose/auto_lb/compose.yml ps
NAME                   IMAGE                    COMMAND                  SERVICE             CREATED              STATUS              PORTS
awsgoo-blog-1          awsgoo-blog              "/bin/sh -c 'service…"   blog                About a minute ago   Up About a minute   80/tcp
awsgoo-blog-2          awsgoo-blog              "/bin/sh -c 'service…"   blog                19 seconds ago       Up 17 seconds       80/tcp
awsgoo-blog-3          awsgoo-blog              "/bin/sh -c 'service…"   blog                19 seconds ago       Up 16 seconds       80/tcp
awsgoo-blog-4          awsgoo-blog              "/bin/sh -c 'service…"   blog                19 seconds ago       Up 17 seconds       80/tcp
awsgoo-blog-5          awsgoo-blog              "/bin/sh -c 'service…"   blog                19 seconds ago       Up 16 seconds       80/tcp
awsgoo-nginx-proxy-1   nginxproxy/nginx-proxy   "/app/docker-entrypo…"   nginx-proxy         About a minute ago   Up About a minute   0.0.0.0:9889->80/tcp
pySatellite commented 9 months ago

limit cpu / memory

pySatellite commented 9 months ago

compose.yml

version: '2'
name: awsgoo
services:
  nginx-proxy:
    image: nginxproxy/nginx-proxy # https://github.com/nginx-proxy/nginx-proxy
    ports:
      - "9889:80"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
    depends_on:
      - blog

  blog:
    # build: ../../docker_file/httpd
    image: pysatellite/blog
    deploy:
      mode: replicated
      replicas: 1 # https://docs.docker.com/compose/compose-file/deploy/#replicas
    expose:
      - "80"
    environment:
      - VIRTUAL_HOST=aws.google.com
      - VIRTUAL_PORT=80