diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..66dddad --- /dev/null +++ b/docker/README.md @@ -0,0 +1,91 @@ +# Build Docker image + +* [Reference](https://nodejs.org/en/docs/guides/nodejs-docker-webapp/) + +* Command + + ```bash + // run with interactive shell + $ docker run -it /bin/bash + + // list running process + $ docker ps + + // list images + $ docker images + + // + $ docker exec -it /bin/bash + + // print app output + $ docker logs + + // build docker image. image name cannot use camel case + $ docker build -t . + + // store image in tart file + $ docker save -o ./store/.tar + + // upload tar image to server + $ rsync -rzvP ./store/.tar ubuntu@:~/apps// + + $ ssh ubuntu@ + $ cd ~/apps/ + $ docker-compose stop + $ docker load -i .tar + $ docker-compose up -d --build + ``` + + + +* testing http + + ```bash + $ curl -i localhost:5000 + + HTTP/1.1 200 OK + X-Powered-By: Express + Content-Type: text/html; charset=utf-8 + Content-Length: 12 + ETag: W/"c-M6tWOb/Y57lesdjQuHeB1P/qTV0" + Date: Mon, 13 Nov 2017 20:53:59 GMT + Connection: keep-alive + + Hello world + ``` + + + +* sample deploy script + + ```bash + # docker way + docker build -t razer-pay-direct-fast-middleware:latest . + docker save razer-pay-direct-fast-middleware:latest -o ./docker-local/razer-pay-direct-fast-middleware.tar + + # upload docker image and compose file to the server + rsync -rzvP ./docker-local/razer-pay-direct-fast-middleware.tar docker-compose.yml ubuntu@172.88.1.101:~/apps/razer-pay-direct-fast-middleware/ + + ssh ubuntu@172.88.1.101 << EOF + cd ~/apps/razer-pay-direct-fast-middleware + pwd + + echo "Stopping Container..." + docker-compose stop + + echo "Loading new Docker image..." + docker load -i razer-pay-direct-fast-middleware.tar + + echo "Restarting Container..." + docker-compose up -d --build + + echo "Container restarted." + + EOF + + echo "Deployed successfully." + ``` + + + +* s \ No newline at end of file diff --git a/redis/README.md b/redis/README.md index c85fdff..1db2afc 100644 --- a/redis/README.md +++ b/redis/README.md @@ -11,7 +11,7 @@ * login redis with password = admin ```sh - $ redis-cli -p admin + $ redis-cli -a admin ```