Giter Club home page Giter Club logo

bretfisher / docker-mastery-for-nodejs Goto Github PK

View Code? Open in Web Editor NEW
414.0 22.0 249.0 38.82 MB

Docker Mastery for Node.js Projects, From a Docker Captain

Home Page: https://www.bretfisher.com/docker-mastery-for-nodejs

License: MIT License

Dockerfile 1.07% JavaScript 88.50% Shell 0.60% CSS 0.37% HTML 0.40% TypeScript 0.01% Less 1.32% Handlebars 0.13% Pug 0.03% EJS 7.56%
docker docker-compose nodejs node javascript containers developer-tools development-environment docker-swarm dockerfile

docker-mastery-for-nodejs's Introduction

Oh hi ๐Ÿ‘‹

apiVersion: v48
kind: Human
metadata:
  name: Bret Fisher
spec:
  purpose: Help others learn container DevOps
  sponsorship: bretfisher.com/members
  locations:
    - 
      type: YouTube Live Stream on Thursdays
      where: bret.live
    - 
      type: Newsletter
      where: bret.news
    - 
      type: Homepage
      where: bretfisher.com
    - 
      type: Discord Server
      where: devops.fan
    -
      type: Podcast
      where: bretfisher.com/podcast
  favorites:
    number: 42
    animal: ๐Ÿถ
    emoji: ๐Ÿคฆ
    food: ๐Ÿฅฉ
    drink: ๐Ÿฅƒ

๐Ÿ™‹โ€โ™€๏ธ You can Ask-Me-Anything in my ama repository, or tweet @BretFisher.

๐Ÿ’ฌ Join my 12k+ member DevOps community on Discord: devops.fan.

๐Ÿ“ฐ Read my Cloud Native Newsletter: bret.news

โ˜•๏ธ ๐Ÿค‘ Please support my DevOps YouTube Live show, podcast, and open source content by buying me a coffee every month at bretfisher.com/members!

๐Ÿง‘โ€๐Ÿซ My course repositories

My examples and templates (New stuff on top)

My tools (often used for learning Containers, Kubernetes, and Docker)

  • shpod - Common Kubernetes tools in a single pod.
  • httping - Ping with HTTP. Fantastic for testing zero-downtime rolling updates.
  • jekyll - Jekyll in a container.
  • vackup - Docker Volume backup and restore.
  • browncoat - A utility container for simulating failures like slow startup, failing healthchecks, etc.

docker-mastery-for-nodejs's People

Contributors

bretfisher avatar dependabot[bot] avatar dmshvetsov avatar kamalgill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

docker-mastery-for-nodejs's Issues

WORKDIR now creates with correct permissions

Docker's fixed the issue with WORKDIR ignoring USER when creating directories.

Prior to this fix, if you did this, you'd get access denied:

USER node 
WORKDIR /app
RUN touch /app/makfile

Today, you can it and the file would get created.

Original Q&A

Multi-stage example doesn't use test stage correctly

On line

## Stage 4 (testing)
# use this in automated CI
# it has prod and dev npm dependencies
# In 18.09 or older builder, this will always run
# In BuildKit, this will be skipped by default
FROM interm as test
CMD ["npm", "test"]
the test stage doesn't have npm dev dependencies, so any test commands would likely fail.

There are two ways to fix that:

  1. Use COPY --from=dev /opt/node_modules/ /opt/node_modules/ in test stage to combine the node modules.

  2. Have dev stage install all npm dependencies (remove --only=development) and then change the test stage to FROM dev as @ivorscott suggested (I like this the most).

Docker Compose File YAML Version 2 vs 3

Hi Bret,

Thanks for this course it's super useful! I was also watching your talk: https://youtu.be/Zgx0o8QjJk4?t=1906 and see you've used in this course and in your talk recommended version 2 for Docker Compose files. However in the official Docker documentation they recommend v3:

https://docs.docker.com/compose/compose-file/compose-versioning/

Looking the the changes I can't see anything that talks about giving up local dev only concerns that you allude to in your talk. Are you able to expand on this a little more; whether this is still applicable today, especially if you're using Amazon ECS for example?

Kind regards

user-node / COPY failed: stat /var/lib/docker/tmp/docker-builder307331584/chown: no such file or directory

Hey Bret,
At the end of the video you did not try to build the dockerfile. It's not working here.

FROM node:10-slim

EXPOSE 3000

WORKDIR /node

COPY package*.json ./

RUN mkdir app && chown -R node:node .

USER node

RUN npm install && npm cache clean --force

WORKDIR /node/app

COPY --chown node:node . .
CMD ["node", "app.js"]

ERROR

โžœ docker build -t user-node .
Sending build context to Docker daemon  29.18kB
Step 1/10 : FROM node:10-slim
 ---> 914bfdbef6aa
Step 2/10 : EXPOSE 3000
 ---> Using cache
 ---> 1f99a8debe3f
Step 3/10 : WORKDIR /node
 ---> Using cache
 ---> f42054115526
Step 4/10 : COPY package*.json ./
 ---> Using cache
 ---> f47e03cafb04
Step 5/10 : RUN mkdir app && chown -R node:node .
 ---> Using cache
 ---> ce303b5752ff
Step 6/10 : USER node
 ---> Using cache
 ---> f2569831d8cb
Step 7/10 : RUN npm install && npm cache clean --force
 ---> Using cache
 ---> efdc76fb5ee5
Step 8/10 : WORKDIR /node/app
 ---> Using cache
 ---> 0945a9b679a3
Step 9/10 : COPY chown node:node . .
COPY failed: stat /var/lib/docker/tmp/docker-builder307331584/chown: no such file or directory

docker-mastery-for-nodejs/user-node on ๎‚  master [!] is ๐Ÿ“ฆ v1.0.0 via โฌข v6.3.0 on ๐Ÿณ v18.09.2
โžœ docker build -t user-node .
Sending build context to Docker daemon  29.18kB
Error response from daemon: Dockerfile parse error line 17: Missing a value on flag: chown

Cheers!
Pascal

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.