Skip to content

Instantly share code, notes, and snippets.

@evbruno
Created April 21, 2022 12:37
Show Gist options
  • Save evbruno/80ea32222b9e52c450b9e281dcff6133 to your computer and use it in GitHub Desktop.
Save evbruno/80ea32222b9e52c450b9e281dcff6133 to your computer and use it in GitHub Desktop.
docker build / buildkit
FROM node:lts
WORKDIR /app
RUN echo "const express = require('express')" > index.js
RUN echo "const app = express()" >> index.js
RUN echo "app.get('/', function (req, res) {" >> index.js
RUN echo "res.send('Hello World')" >> index.js
RUN echo "})" >> index.js
RUN echo "app.listen(3000)" >> index.js
RUN npm install --save express
CMD node index.js
@evbruno
Copy link
Author

evbruno commented Apr 21, 2022

1st test - build with the current bash config

docker build -t test:default-env https://gist.githubusercontent.com/evbruno/80ea32222b9e52c450b9e281dcff6133/raw/79fdf76e4c42630edd5c5c87d9f60e3b3feee887/Dockerfile && \
docker run --rm test:default-env bash -c "ls -lah"

total 52K
drwxr-xr-x  1 root root 4.0K Apr 20 23:49 .
drwxr-xr-x  1 root root 4.0K Apr 21 12:39 ..
-rw-r--r--  1 root root  136 Apr 20 23:49 index.js
drwxr-xr-x 52 root root 4.0K Apr 20 23:49 node_modules
-rw-r--r--  1 root root  32K Apr 20 23:49 package-lock.json
-rw-r--r--  1 root root   53 Apr 20 23:49 package.json

2nd test - disable DOCKER_BUILDKIT and build it

DOCKER_BUILDKIT=0 docker build -t test:disabled-env https://gist.githubusercontent.com/evbruno/80ea32222b9e52c450b9e281dcff6133/raw/79fdf76e4c42630edd5c5c87d9f60e3b3feee887/Dockerfile && \
docker run --rm test:disabled-env bash -c "ls -lah"

total 52K
drwxr-xr-x  1 root root 4.0K Apr 20 23:49 .
drwxr-xr-x  1 root root 4.0K Apr 21 12:39 ..
-rw-r--r--  1 root root  136 Apr 20 23:49 index.js
drwxr-xr-x 52 root root 4.0K Apr 20 23:49 node_modules
-rw-r--r--  1 root root  32K Apr 20 23:49 package-lock.json
-rw-r--r--  1 root root   53 Apr 20 23:49 package.json

3rd test - enable DOCKER_BUILDKIT and build it

DOCKER_BUILDKIT=1 docker build -t test:enabled-env https://gist.githubusercontent.com/evbruno/80ea32222b9e52c450b9e281dcff6133/raw/79fdf76e4c42630edd5c5c87d9f60e3b3feee887/Dockerfile && \
docker run --rm test:enabled-env bash -c "ls -lah"

total 52K
drwxr-xr-x  1 root root 4.0K Apr 20 23:49 .
drwxr-xr-x  1 root root 4.0K Apr 21 12:39 ..
-rw-r--r--  1 root root  136 Apr 20 23:49 index.js
drwxr-xr-x 52 root root 4.0K Apr 20 23:49 node_modules
-rw-r--r--  1 root root  32K Apr 20 23:49 package-lock.json
-rw-r--r--  1 root root   53 Apr 20 23:49 package.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment