adding docker resources for class

This commit is contained in:
Omar Santos 2021-04-11 13:33:39 -04:00
parent 5c52f16bda
commit 6860cdf409
5 changed files with 84 additions and 0 deletions

View file

@ -0,0 +1,24 @@
### First Stage ###
# Base Image
FROM node:12-slim as build
WORKDIR /usr/src/app
# Install Dependencies
COPY package*.json ./
RUN npm install
# Copy in the application we created
COPY . .
### Second Stage ###
FROM gcr.io/distroless/nodejs:12
# Copy App + Dependencies from Build Stage
COPY --from=build /usr/src/app /usr/src/app
WORKDIR /usr/src/app
# Set User to Non-Root
USER 1000
# Run Server
CMD [ "server.js" ]

View file

@ -0,0 +1,13 @@
# Base Image
FROM node:12-slim
WORKDIR /usr/src/app
# Install Dependencies
COPY package*.json ./
RUN npm install
# Copy in Application
COPY . .
# Run Server
CMD [ "server.js" ]

View file

@ -0,0 +1,16 @@
# Base Image
FROM node:12-slim
WORKDIR /usr/src/app
# Install Dependencies
COPY package*.json ./
RUN npm install
# Copy in Application
COPY . .
# Set User to Non-Root
USER node
# Run Server
CMD [ "server.js" ]

View file

@ -0,0 +1,20 @@
run:
docker run -i -d -p 8080:8080 node-distroless
build-naive:
docker build \
-f $(CURDIR)/Dockerfile.naive \
-t node-naive \
.
build-non-root:
docker build \
-f $(CURDIR)/Dockerfile.non-root \
-t node-non-root \
.
build-distroless:
docker build \
-f $(CURDIR)/Dockerfile.distroless \
-t node-distroless \
.

View file

@ -0,0 +1,11 @@
{
"name": "hello-world",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}