mirror of
https://github.com/The-Art-of-Hacking/h4cker.git
synced 2024-12-18 10:56:09 +00:00
adding docker resources for class
This commit is contained in:
parent
5c52f16bda
commit
6860cdf409
24
docker-and-k8s-security/docker/Dockerfile.distroless
Normal file
24
docker-and-k8s-security/docker/Dockerfile.distroless
Normal 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" ]
|
13
docker-and-k8s-security/docker/Dockerfile.naive
Normal file
13
docker-and-k8s-security/docker/Dockerfile.naive
Normal 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" ]
|
16
docker-and-k8s-security/docker/Dockerfile.non-root
Normal file
16
docker-and-k8s-security/docker/Dockerfile.non-root
Normal 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" ]
|
20
docker-and-k8s-security/docker/Makefile
Normal file
20
docker-and-k8s-security/docker/Makefile
Normal 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 \
|
||||
.
|
11
docker-and-k8s-security/docker/package.json
Normal file
11
docker-and-k8s-security/docker/package.json
Normal 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"
|
||||
}
|
Loading…
Reference in New Issue
Block a user