Git Product home page Git Product logo

devops's Introduction

export [email protected]
export LOCAL_HOST=localhost
export MongoDB_PASSWORD=butterzCUPz
export MongoDB_USERNAME=janeDOE
export WORDPRESS_DB_HOST=db
export WORDPRESS_DB_NAME=exampledb
export WORDPRESS_DB_PASSWORD=examplepass
export WORDPRESS_DB_USER=exampleuser
docker-compose up -d --build
docker-compose down
docker stack rm traefik
# docker info
sudo rm -rf devOps/
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519DO
git clone [email protected]:TurtleWolfe/devOps.git
cd devOps
docker stack deploy -c docker-compose.yml traefik

DigitalOcean Referral Badge

  1. previous bash script
  2. Getting started with OpenSSH
  3. Fail2Ban
  4. Uncomplicated FireWall
  5. escape SED
  6. jail.local.conf
  7. add Docker to previous Bash Script
  8. git clone repo
  1. Dockerfile multi stage dev, prod, test, build
  2. FrontEnd React TypeScript
  3. NGINX
  4. BackEnd express, Next, Nuxt or Nest TypeScript Backend
  5. git clone repo
  6. docker-compose UP
  1. Digital Ocean
    60 day demo
    40 days left on 60 day demo
  2. Google Cloud PlatForm
    free Forever server
    Node lighter weight on Server than PHP
  3. Amazon Web Service
    lease $5 monthly
  1. DevLama
    Social NetWork API & React playlist
  2. Traversy Media
    API Master Class
  3. David Herron
    By the end of this Node.js book, you’ll have gained practical Node.js web development knowledge and be able to build and deploy your own apps on a public web hosting solution.
  4. Academind
    placeholder
  1. YouTube, Udemy & Packt
  1. MoshOne

  2. Nav Auth

  3. Academind Git Hub

  4. code splitting

  5. .DSP XD imports

Install Docker on Ubuntu 18.04

# update apt-get libraries
sudo apt-get update

# install required packages
sudo apt-get install \
   apt-transport-https \
   ca-certificates \
   curl \
   software-properties-common

# get the GPG key for docker
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
   sudo apt-key add -

# validating the docker GPG key is installed
sudo apt-key fingerprint 0EBFCD88

# adding the docker repository
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

# update apt-get libraries again
sudo apt-get update

# install docker
sudo apt-get install docker-ce

# validate install with version command
docker --version

# validating functionality by running a container
sudo docker run hello-world

# add the current user to the docker group
sudo usermod -aG docker $USER

# validate that sudo is no longer needed
docker run hello-world

# install docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
   39  docker system info
   40  docker system info | grep Swarm
   41  docker swarm init
   42  docker system info | grep Swarm
   43  docker swarm --help
   44  docker swarm ca --help
   45  docker swarm ca
   46  docker swarm join-token
   47  docker swarm join-token --help
   48  docker swarm join-token -q
   49  docker swarm join-token manager
   50  docker swarm join-token worker
   51  docker swarm unlock-key
   52  docker swarm init
   56  docker service create --help
   64  docker container ls -a
   65  docker container rm -f $(docker container ls -aq)
   66  docker container ls -a
   67  docker container run --detach --name web-server003 --publish 80:80 nginx
   68  docker container ls -a
   70  docker container logs --follow --timestamps web-server003
   72  docker container top web-server003
   74  docker container inspect web-server003
   76  sudo apt  install jq
   77  docker container inspect --format '{{json .State}}' web-server003 | jq
   ## 78
   79  docker container stats
   81  docker container stats
   82  docker network ls
   83  docker network prune
   84  docker network ls
   85  docker network prune
   86  docker network ls
   87  docker network inspect specifics-over --format '{{json .IPAM.Config}}' | jq
   88  docker network inspect bridge --format '{{json .IPAM.Config}}' | jq
   89  docker version
   90  docker search --limit 5 alpine
   91  docker search --help
   98  docker
   99  docker info
  100  docker search --limit 5 alpine
  101  docker network inspect bridge --format '{{json .IPAM.Config}}' | jq
  102  docker network ls
  103  docker container stats
  104  docker container inspect --format '{{json .State}}' web-server003 | jq
  105  docker container top web-server003
  106  docker container run --detach --name web-server003 --publish 80:80 nginx
  107  docker info
  108  docker container ls -a
  109  docker container nginx start
  110  docker container start nginx
  111  docker container ls -a
  112  docker container start 2abfac
  113  history
  114  clear
  115  docker system info
  116  docker system info | grep Swarm
  117  docker swarm ca
  118  docker container inspect --format '{{json .State}}' web-server003 | jq
  119  clear
  120  docker container stats
  121  docker network inspect specifics-over --format '{{json .IPAM.Config}}' | jq
  122  docker network inspect bridge --format '{{json .IPAM.Config}}' | jq
  123  docker container stats
  124  docker network inspect specifics-over --format '{{json .IPAM.Config}}' | jq
  125  docker container stats
  126  docker system info | grep Swarm
  127  docker container start 2abfac
  128  docker container ls -a
  129  docker info
  130  docker container top web-server003
  131  docker search --limit 5 alpine
  132  docker info
  133  docker
  134  docker container ls -a
  135  docker images ls -a
  136  docker images
  137  docker version
  138  docker info
  139  docker container run --detach --name web-server003 --publish 80:80 nginx
  140  docker container ls
  141  docker images ls -a
  142  docker container ls -a
  143  docker network inspect web-server003 --format '{{json .IPAM.Config}}' | jq
  144  docker container inspect --format '{{json .State}}' web-server003 | jq
  145  docker container top web-server003
  146  docker container ls
  147  docker container ps
  148  docker container ps -a
  149  docker ps
  150  docker container exec -it web-server0003 bash
  151  docker container exec -it web-server003 bash
  152  ls
  153  docker container exec -it web-server003 bash
  154  history
  155  code .
  156  sudo snap install code
  157  sudo snap install code --classic
  158  sudo apt update
  159  docker container exec -it web-server0003 bash
  160  docker container exec -it web-server003 bash
  161  docker container run --detach --name web-server003 --publish 80:80 nginx
  162  ocker container run --detach --name web-server003 --publish 80:80 -v $(pwd):/usr/share/nginx/html nginx
  163  docker container run --detach --name web-server003 --publish 80:80 -v $(pwd):/usr/share/nginx/html nginx
  164  ls
  165  cd /
  166  ls
  167  cd /usr/share/
  168  ls
  169  cd
  170  ls
  171  cd /usr/share/
  172  ls
  173  cds ..
  174  ls
  175  cd
  176  ls
  177  docker container run --detach --name web-server003 --publish 80:80 -v $(pwd):/usr/share/nginx/html nginx
  178  git status
  179  docker container run --detach --name web-server003 --publish 80:80 -v $(pwd):/usr/share/nginx/html nginx
  180  docker image build -t btrav/nginx-website .
  181  docker images
  182  docker container ls
  183  docker container run --detach --name web-server003 --publish 80:80 -v $(pwd):/usr/share/nginx/html nginx
  192  sudo rm -r ChatSocketIO -f
  193  ls
  194  git clone [email protected]:TurtleWolf/ChatSocketIO.git
  195  git clone https://github.com/TurtleWolf/ChatSocketIO.git
  203  docker container run --detach --name web-server003 --publish 80:80 -v $(pwd):/usr/share/nginx/html nginx
  204  docker container start 2abfac
  205  exit
  206  docker container run --detach --name web-server003 --publish 80:80 -v $(pwd):/usr/share/nginx/html nginx
  207  docker container run --restart=always -d -i -t 2abfac /bin/bash
  208  docker container
  209  docker container ls
  210  docker container run --detach --name web-server003 --publish 80:80 -v $(pwd):/usr/share/nginx/html nginx
  211  docker container rm -f $(docker container ls -aq)
  212  docker container ls
  213  docker images ls
  214  docker image ls
  215  docker container run --restart=always -d -i -t nginx /bin/bash
  216  docker image ls
  217  docker container ls
  218  docker container rm -f $(docker container ls -aq)
  219  docker container run --detach --name web-server003 --restart=always --publish 80:80 -v $(pwd):/usr/share/nginx/html nginx
  220  docker container ls
  221  docker container rm -f $(docker container ls -aq)
  222  sudo docker container run --detach --name web-server003 --restart=always --publish 80:80 -v $(pwd):/usr/share/nginx/html nginx
  223  docker container rm -f $(docker container ls -aq)
  224  ls
  225  docker container run --restart=always -d -i -t ubuntu /bin/bash
  226  docker container ls
  227  docker container rm -f $(docker container ls -aq)
  228  docker container run --restart=always -d -i -t nginx /bin/bash
  229  docker container rm -f $(docker container ls -aq)
  230  docker container run --restart=always -d -i -t --publish 80:80 nginx /bin/bash
  231  docker container ls
  232  docker container rm -f $(docker container ls -aq)
  233  docker container ls
  234  docker container run --detach --name web-server003 --publish 80:80 nginx
  235  docker container run --detach --name web-server003 --publish 80:80 --restart=always nginx
  236  docker container rm -f $(docker container ls -aq)
  237  docker container run --detach --name web-server003 --publish 80:80 --restart=always nginx
  238  docker container ls
  239  docker container info
  240  docker container stats
  241  docker container ls
  242  docker container ls -a
  243  docker container ls info
  244  docker container inspect --format '{{json .State}}' web-server003 | jq
  245  docker network inspect web-server003 --format '{{json .IPAM.Config}}' | jq
  246  sudo apt update
  247  sudo apt upgrade
  248  sudo reboot
  249  docker container ls info
  250  docker network inspect web-server003 --format '{{json .IPAM.Config}}' | jq
  251  docker container inspect --format '{{json .State}}' web-server003 | jq
  252  docker container run --help
  253  docker container --restart string
  254  docker container --restart help
  255  docker container run --help
  256  docker container ls
  257  docker container inspect web-server003
  258  docker container inspect \     --format='{{.NetworkSettings.IPAddress}}'  $ID172.17.0.2
  259  docker container ls
  260  docker container inspect \     --format='{{.NetworkSettings.IPAddress}}'  $IDweb-server003
  261  docker container inspect --help
  262  docker container inspect web-server003
  263  docker container inspect web-server003 | grep RestartPolicy
  264  docker container inspect web-server003 | grep "RestartPolicy": {
  265  docker container inspect web-server003 | grep RestartPolicy
  266  docker container inspect --help
  267  docker container inspect web-server003 -f RestartPolicy
  268  docker container inspect web-server003
  269  docker container inspect web-server003 "RestartPolicy": {
  270  docker container inspect web-server003 RestartPolicy
  271  docker container inspect web-server003
  272  docker image ls
  273  docker container ls
  274  docker container inspect web-server003 | jq "."
  275  docker container inspect --format '{{json. .Config.Labels))' web-server003 | jq "."
  276  docker container inspect --format '{{json. .Config.Labels))' web-server003 | jq "."
  277  docker container inspect --format `{{json. .Config.Labels))` web-server003 | jq "."
  278  docker container inspect --format '{{json. .Config.Labels))' web-server003 | jq "."
  279  docker container inspect --format '{{json. .Config.Labels))' web-server003 | jq
  280  docker info
  281  docker images
  282  docker-machine

docker container exec -it web-server0003 bash
docker container run --detach --name web-server003 --publish 80:80 --restart=always nginx
#  cd usr/share/nginx/html

docker container start 2abfac
docker container run --restart=always -d -i -t 2abfac /bin/bash
# docker remove all
docker container run --detach --name web-server003 --publish 80:80 -v $(pwd):/usr/share/nginx/html nginx


# docker REACT
docker container run --detach --name web-server003 --publish 80:80 -v $(pwd):/usr/share/nginx/html react

# docker DRUPAL
docker container run --detach --name web-server003 --publish 80:80 -v $(pwd):/usr/share/nginx/html drupal

# docker WORD PRESS
docker container run --detach --name web-server003 --publish 80:80 -v $(pwd):/usr/share/nginx/html wordpress

# docker DRAGGABLE DICE
docker container run --detach --name web-server003 --publish 80:80 -v $(pwd):/usr/share/nginx/html draggable dice

# docker Free Code Camp Template
docker container run --detach --name web-server003 --publish 80:80 -v $(pwd):/usr/share/nginx/html freecodecampTEMPLATE

# ChatSocketIO.git
git clone https://github.com/TurtleWolf/ChatSocketIO.git

# docker-node-mongo
git clone https://github.com/TurtleWolf/docker-node-mongo

# dockerLAMP
git clone [email protected]:TurtleWolf/dockerLAMP.git

alt text

alt text

# Show commands & management commands
docker
# Docker version info
docker version
# Show info like number of containers, etc
docker info

WORKING WITH CONTAINERS

# Create & run a container in foreground
docker container run -it -p 80:80 nginx
# Create an run a container in background
docker container run -d -p 80:80 nginx
# Shorthand
docker container run -d -p 80:80 nginx
# Naming Containers
docker container run -d -p 80:80 --name nginx-server nginx

TIP: WHAT RUN DID

  • Looked for image called nginx in image cache
  • If not found in cache, it looks to the default image repo on Dockerhub
  • Pulled it down (latest version), stored in the image cache
  • Started it in a new container
  • We specified to take port 80- on the host and forward to port 80 on the container
  • We could do "$ docker container run --publish 8000:80 --detach nginx" to use port 8000
  • We can specify versions like "nginx:1.09"
# List running containers
docker container ls

OR

# List running containers
docker ps
# List all containers (Even if not running)
docker container ls -a
# Stop container
docker container stop [ID]
# Stop all running containers
docker stop $(docker ps -aq)
# Remove container (Can not remove running containers, must stop first)
docker container rm [ID]
# To remove a running container use force(-f)
docker container rm -f [ID]
# Remove multiple containers
docker container rm [ID] [ID] [ID]
# Remove all containers
docker rm $(docker ps -aq)
# Get logs (Use name or ID)
docker container logs [NAME]
# List processes running in container
docker container top [NAME]

TIP: ABOUT CONTAINERS

Docker containers are often compared to virtual machines but they are actually just processes running on your host os. In Windows/Mac, Docker runs in a mini-VM so to see the processes youll need to connect directly to that. On Linux however you can run "ps aux" and see the processes directly

IMAGE COMMANDS

# List the images we have pulled
docker image ls
# We can also just pull down images
docker pull [IMAGE]
# Remove image
docker image rm [IMAGE]
# Remove all images
docker rmi $(docker images -a -q)

TIP: ABOUT IMAGES

  • Images are app bianaries and dependencies with meta data about the image data and how to run the image
  • Images are no a complete OS. No kernel, kernel modules (drivers)
  • Host provides the kernel, big difference between VM
# Some sample container creation
# NGINX:
docker container run -d -p 80:80 --name nginx nginx (-p 80:80 is optional as it runs on 80 by default)
# APACHE:
docker container run -d -p 8080:80 --name apache httpd
# MONGODB:
docker container run -d -p 27017:27017 --name mongo mongo
# MYSQL:
docker container run -d -p 3306:3306 --name mysql --env MYSQL_ROOT_PASSWORD=123456 mysql
# CONTAINER INFO
# View info on container
docker container inspect [NAME]
# Specific property (--format)
docker container inspect --format '{{ .NetworkSettings.IPAddress }}' [NAME]
# Performance stats (cpu, mem, network, disk, etc)
docker container stats [NAME]

ACCESSING CONTAINERS

# Create new nginx container and bash into
docker container run -it --name [NAME] nginx bash
  • i = interactive Keep STDIN open if not attached
  • t = tty - Open prompt

For Git Bash, use "winpty"

winpty docker container run -it --name [NAME] nginx bash
# Run/Create Ubuntu container
docker container run -it --name ubuntu ubuntu

(no bash because ubuntu uses bash by default)

# You can also make it so when you exit the container does not stay by using the -rm flag
docker container run --rm -it --name [NAME] ubuntu
# Access an already created container, start with -ai
docker container start -ai ubuntu
# Use exec to edit config, etc
docker container exec -it mysql bash
# Alpine is a very small Linux distro good for docker
docker container run -it alpine sh

(use sh because it does not include bash) (alpine uses apk for its package manager - can install bash if you want)

NETWORKING

"bridge" or "docker0" is the default network

# Get port
docker container port [NAME]
# List networks
docker network ls
# Inspect network
docker network inspect [NETWORK_NAME]
("bridge" is default)
# Create network
docker network create [NETWORK_NAME]
# Create container on network
docker container run -d --name [NAME] --network [NETWORK_NAME] nginx
# Connect existing container to network
docker network connect [NETWORK_NAME] [CONTAINER_NAME]
# Disconnect container from network
docker network disconnect [NETWORK_NAME] [CONTAINER_NAME]
# Detach network from container
docker network disconnect

IMAGE TAGGING & PUSHING TO DOCKERHUB

# tags are labels that point ot an image ID
docker image ls

Youll see that each image has a tag

# Retag existing image
docker image tag nginx btraversy/nginx
# Upload to dockerhub
docker image push bradtraversy/nginx
# If denied, do
docker login
# Add tag to new image
docker image tag bradtraversy/nginx bradtraversy/nginx:testing

DOCKERFILE PARTS

  • FROM - The os used. Common is alpine, debian, ubuntu

  • COPY # Copies files from host to container

  • ADD # Copies files from host to container

  • ENV - Environment variables

  • ARG - Environment variables

  • CMD - Final command run when you launch a new container from image

  • ENTRYPOINT - Final command run when you launch a new container from image

  • RUN - Run commands/shell scripts, etc

  • EXPOSE - Ports to expose

  • WORKDIR - Sets working directory (also could use 'RUN cd /some/path')

Build image from dockerfile (reponame can be whatever)

# From the same directory as Dockerfile
docker image build -t [REPONAME] .

TIP: CACHE & ORDER

  • If you re-run the build, it will be quick because everythging is cached.
  • If you change one line and re-run, that line and everything after will not be cached
  • Keep things that change the most toward the bottom of the Dockerfile

EXTENDING DOCKERFILE

# Custom Dockerfile for html paqge with nginx
FROM nginx:latest # Extends nginx so everything included in that image is included here
WORKDIR /usr/share/nginx/html
COPY index.html index.html
# Build image from Dockerfile
docker image build -t nginx-website
# Running it
docker container run -p 80:80 --rm nginx-website
# Tag and push to Dockerhub
docker image tag nginx-website:latest btraversy/nginx-website:latest
docker image push bradtraversy/nginx-website

VOLUMES

Volume - Makes special location outside of container UFS. Used for databases

Bind Mount -Link container path to host path

# Check volumes
docker volume ls
# Cleanup unused volumes
docker volume prune
# Pull down mysql image to test
docker pull mysql
# Inspect and see volume
docker image inspect mysql
# Run container
docker container run -d --name mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=True mysql
# Inspect and see volume in container
docker container inspect mysql

TIP: Mounts

  • You will also see the volume under mounts
  • Container gets its own uniqe location on the host to store that data
  • Source: xxx is where it lives on the host
# Check volumes
docker volume ls

There is no way to tell volumes apart for instance with 2 mysql containers, so we used named volumes

# Named volumes (Add -v command)(the name here is mysql-db which could be anything)
docker container run -d --name mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=True -v mysql-db:/var/lib/mysql mysql
# Inspect new named volume
docker volume inspect mysql-db

BIND MOUNTS

  • Can not use in Dockerfile, specified at run time (uses -v as well)
  • ... run -v /Users/brad/stuff:/path/container (mac/linux)
  • ... run -v //c/Users/brad/stuff:/path/container (windows)

TIP: Instead of typing out local path, for working directory use $(pwd):/path/container - On windows may not work unless you are in your users folder

# Run and be able to edit index.html file (local dir should have the Dockerfile and the index.html)
docker container run  -p 80:80 -v $(pwd):/usr/share/nginx/html nginx
docker container run --detach --name web-server003 --publish 80:80 -v $(pwd):/usr/share/nginx/html nginx
# Go into the container and check
docker container exec -it nginx bash
cd /usr/share/nginx/html
ls -al
# You could create a file in the container and it will exist on the host as well
touch test.txt

DOCKER COMPOSE

  • Configure relationships between containers
  • Save our docker container run settings in easy to read file
  • 2 Parts: YAML File (docker.compose.yml) + CLI tool (docker-compose)

1. docker.compose.yml - Describes solutions for

  • containers
  • networks
  • volumes

2. docker-compose CLI - used for local dev/test automation with YAML files

Sample compose file (From Bret Fishers course)

version: '2'

# same as
# docker run -p 80:4000 -v $(pwd):/site bretfisher/jekyll-serve

services:
  jekyll:
    image: bretfisher/jekyll-serve
    volumes:
      - .:/site
    ports:
      - '80:4000'
# To run
docker-compose up
# You can run in background with
docker-compose up -d
# To cleanup
docker-compose down

Sample compose file (From Drupal)

# Drupal with PostgreSQL
#
# Access via "http://localhost:8080"
#   (or "http://$(docker-machine ip):8080" if using docker-machine)
#
# During initial Drupal setup,
# Database type: PostgreSQL
# Database name: postgres
# Database username: postgres
# Database password: example
# ADVANCED OPTIONS; Database host: postgres

version: '3.1'

services:

  drupal:
    image: drupal:8-apache-alpine
    ports:
      - 8080:80
    volumes:
      - /var/www/html/modules
      - /var/www/html/profiles
      - /var/www/html/themes
      # this takes advantage of the feature in Docker that a new anonymous
      # volume (which is what we're creating here) will be initialized with the
      # existing content of the image at the same location
      - /var/www/html/sites
    restart: always

  postgres:
    image: postgres:10
    environment:
      POSTGRES_PASSWORD: example
    restart: always

README.md package-lock.js Dockerfile DockerIgnore DockerCompose.yml DockerCompose-Production.yml

alt text

alt text

alt text

 1727  sudo apt purge nodejs
 1729  sudo apt remove nodejs
 1741  sudo npm uninstall -g create-react-app
 1739  sudo apt install nodejs
       sudo npm install -g [email protected]
  1. docker-compose Alpine dependencies (8)
  2. pip install docker-compose
  3. 2 spaces, no tabs in YAML
  4. : (key:value pairs)
    • (lists)
  5. WORKDIR, not cd or mkdir (unless... ?)
  6. docker-compose up -d --build to force rebuild
  7. docker-compose down -v to delete volumes

Service Options

  1. build
  2. stop
  3. ps
  4. push
  5. logs
  6. exec

Section 3: Node Dockerfile Best Practice Basics

  1. COPY over ADD
  2. npm cache clean --force
  3. CMD node not npm
  4. WORKDIR covers cd & mkdir unless you need chown then RUN mkdir
  1. LTS : even
  1. try Slim first
  2. then Alpine if needed
  3. not slim or latest
  4. Stretch more current than Jessie
  1. ENV node version
  2. Stretch more current than Jessie
  3. USER node before CMD to enable non-root user
  4. each RUN creates a new layer
  1. USER node
  2. RUN mkdir app && chown -R node:node
  3. docker-compse exec -u root
  1. USER node
  2. RUN mkdir app && chown -R node:node .
  3. COPY --chown=node:node . .
  4. docker-compse exec -u root
  1. each line is a new layer
  2. EXPOSE higher in ordering because it changes less often
  3. COPY package.json package-lock.json* ./
  4. RUN npm install && npm cache clean --force
  5. COPY . .
  6. RUN apt-get once and early

Section 4: Controlling The Node Process In Containers

  1. no need for nodemon, forever or pm2
  1. SIGINT (cntrl C), SIGTERM (docker container stop or update), & SIGKILL
  2. most likely won't need tini
  1. init
  2. tini
  3. ./sample-graceful-shutdown/sample.js
  1. COPY, if doing more than one file the ./ is required
  2. && must run both
  3. docker build -t assignment1 .
  4. docker build --no-cache -t assignment1 .
  5. docker run -p 80:3000 assignment1
  1. docker run init -d assignment1:notini

Section 5: Advanced Dockerfiles with Multi-stage and BuildKit

  1. docker build -t myapp:prod --target prod .
  1. FROM node as prod
  2. ENV NODE_ENV=production
  3. FROM prod as dev
  4. ENV NODE_ENV=development
  5. FROM dev as test
  6. ENV NODE_ENV=development

Section 6: Node Apps in Cloud Native Docker

  1. ENV configuration
  2. log stdout/stderr
  3. .dockerignore
  4. pin all versions
  5. Graceful exit SIGTERM/INIT
  6. 12 factor
  1. CMD or ENTRYPOINT script with envsubst (enviroment substitue)
  1. Winston, Morgan, Bunyan or BugSnag stdout or stderr
  1. exclude
  2. .git/
  3. node_modules/
  4. npm-debug
  5. docker-compose*.yml
  6. good to include
  7. Dockerfile
  8. README.md
  1. ln SymLinks
  2. bind-mount in & out dirs

Section 7: Compose for Awesome Local Development

  1. version: 2 for local developement
  2. depends_on not in version 3
  1. left side of bind mount should always just be a dot
  2. don't bind mount databases
  3. don't copy in local code
  4. DDforWin drive permissions
  5. Perms: Linus != Windows
  6. :delegated
  7. docker-bg-sync
  1. cp .gitignore .dockerignore
  1. WORKDIR /node
  2. WORKDIR /node/app
  3. volumes: - . : /node/app
  4. volumes: - /node/app/node_modules
  1. docker-compose run
  2. docker-compose exec
  3. docker-compose run api npm i
  4. docker-compose exec api strapi --help
  5. docker-compose exec api bash
  1. command: /app/node_modules/.bin/nodemon ./bin/www
  2. ENV PATH /app/node_modules/.bin/:$PATH
  1. depends_on
  1. mongo: test: echo ..
  1. GHOST_VERSION=2 docker-compose up
  2. Templating
  3. Control your Compose Command Scope
  1. nginx-proxy enviroment: -VIRTUAL_HOST=
  2. traefik-proxy labels: traefic.frontend.rule=Host:nginx.localhost
  1. RUN tsc
  2. target: dev
  3. "outDir" : "dist"
  4. nodemond.json watch , ignore & "exec" "node --inpsect=0.0.0.0:9229 -r ts-node/register ./src/app.ts"
  5. vscode debugger
  1. mongo: test: echo ..
  1. mongo: test: echo ..

Section 8: Making Container Images Production Ready

  1. each line is a new layer

Section 9: Running Production Node.js Containers

  1. each line is a new layer

Section 10: Running Node.js on ARM with Docker

  1. each line is a new layer

Section 11: Extras

  1. each line is a new layer

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.