Skip to content

Commit

Permalink
Merge pull request #660 from credebl/Dockerfile_updation
Browse files Browse the repository at this point in the history
Changes in dockerfiles for nonroot user
  • Loading branch information
vivekayanworks authored Apr 12, 2024
2 parents fd5964f + 44083b7 commit 9a48260
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 138 deletions.
20 changes: 9 additions & 11 deletions Dockerfiles/Dockerfile.agent-provisioning
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# Stage 1: Build the application
FROM node:18-alpine as build
# RUN npm install -g pnpm
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot

USER nonroot


# Install AWS CLI
# RUN apk update
# RUN apk add openssh-client
# RUN apk update
# RUN apk add aws-cli
RUN set -eux \
&& apk --no-cache add \
Expand All @@ -33,7 +31,7 @@ WORKDIR /app
COPY package.json ./

# Install dependencies
RUN pnpm i --ignore-scripts
RUN pnpm i

# Copy the rest of the application code
COPY . .
Expand All @@ -47,10 +45,10 @@ RUN pnpm run build agent-provisioning

# Stage 2: Create the final image
FROM node:18-alpine as prod
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot

USER nonroot
# Install AWS CLI
# RUN apk update
# RUN apk add openssh-client
# RUN apk update
# RUN apk add aws-cli
RUN set -eux \
&& apk --no-cache add \
Expand Down
4 changes: 2 additions & 2 deletions Dockerfiles/Dockerfile.agent-service
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ WORKDIR /app
COPY package.json ./

# Install dependencies
RUN pnpm i --ignore-scripts
RUN pnpm i

# Copy the rest of the application code
COPY . .
Expand Down Expand Up @@ -52,4 +52,4 @@ CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx pri

# docker build -t agent-service -f Dockerfiles/Dockerfile.agent-service .
# docker run -d --env-file .env --name agent-service docker.io/library/agent-service
# docker logs -f agent-service
# docker logs -f agent-service
16 changes: 4 additions & 12 deletions Dockerfiles/Dockerfile.api-gateway
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Stage 1: Build the application
FROM node:18-alpine as build
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot

USER nonroot
RUN npm install --ignore-scripts -g pnpm
RUN npm install -g pnpm
# Set the working directory
WORKDIR /app

Expand All @@ -13,7 +9,7 @@ COPY package.json ./
# COPY package-lock.json ./

# Install dependencies
RUN pnpm i --ignore-scripts
RUN pnpm i

# Copy the rest of the application code
COPY . .
Expand All @@ -24,11 +20,7 @@ RUN pnpm run build api-gateway

# Stage 2: Create the final image
FROM node:18-alpine
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot

USER nonroot
RUN npm install --ignore-scripts -g pnpm
RUN npm install -g pnpm
# Set the working directory
WORKDIR /app

Expand All @@ -41,4 +33,4 @@ COPY --from=build /app/node_modules ./node_modules
# COPY --from=build /app/uploadedFiles ./uploadedFiles

# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate && cd ../.. && node dist/apps/api-gateway/main.js"]
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate && cd ../.. && node dist/apps/api-gateway/main.js"]
16 changes: 4 additions & 12 deletions Dockerfiles/Dockerfile.connection
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Stage 1: Build the application
FROM node:18-alpine as build
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot

USER nonroot
RUN npm install --ignore-scripts -g pnpm
RUN npm install -g pnpm
# Set the working directory
WORKDIR /app

Expand All @@ -13,7 +9,7 @@ COPY package.json ./
#COPY package-lock.json ./

# Install dependencies
RUN pnpm i --ignore-scripts
RUN pnpm i

# Copy the rest of the application code
COPY . .
Expand All @@ -24,11 +20,7 @@ RUN pnpm run build connection

# Stage 2: Create the final image
FROM node:18-alpine
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot

USER nonroot
RUN npm install --ignore-scripts -g pnpm
RUN npm install -g pnpm
# Set the working directory
WORKDIR /app

Expand All @@ -48,4 +40,4 @@ CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx pri

# docker build -t connection -f Dockerfiles/Dockerfile.connection .
# docker run -d --env-file .env --name connection docker.io/library/connection
# docker logs -f connection
# docker logs -f connection
16 changes: 4 additions & 12 deletions Dockerfiles/Dockerfile.ecosystem
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Stage 1: Build the application
FROM node:18-alpine as build
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot

USER nonroot
RUN npm install --ignore-scripts -g pnpm
RUN npm install -g pnpm
# Set the working directory
WORKDIR /app

Expand All @@ -13,7 +9,7 @@ COPY package.json ./
#COPY package-lock.json ./

# Install dependencies
RUN pnpm i --ignore-scripts
RUN pnpm i

# Copy the rest of the application code
COPY . .
Expand All @@ -24,11 +20,7 @@ RUN pnpm run build ecosystem

# Stage 2: Create the final image
FROM node:18-alpine
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot

USER nonroot
RUN npm install --ignore-scripts -g pnpm
RUN npm install -g pnpm
# Set the working directory
WORKDIR /app

Expand All @@ -46,4 +38,4 @@ CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx pri

# docker build -t ecosystem -f Dockerfiles/Dockerfile.ecosystem .
# docker run -d --env-file .env --name ecosystem docker.io/library/ecosystem
# docker logs -f ecosystem
# docker logs -f ecosystem
16 changes: 4 additions & 12 deletions Dockerfiles/Dockerfile.issuance
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Stage 1: Build the application
FROM node:18-alpine as build
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot

USER nonroot
RUN npm install --ignore-scripts -g pnpm
RUN npm install -g pnpm
# Set the working directory
WORKDIR /app

Expand All @@ -13,7 +9,7 @@ COPY package.json ./
#COPY package-lock.json ./

# Install dependencies
RUN pnpm i --ignore-scripts
RUN pnpm i

# Copy the rest of the application code
COPY . .
Expand All @@ -24,11 +20,7 @@ RUN pnpm run build issuance

# Stage 2: Create the final image
FROM node:18-alpine
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot

USER nonroot
RUN npm install --ignore-scripts -g pnpm
RUN npm install -g pnpm
# Set the working directory
WORKDIR /app

Expand All @@ -47,4 +39,4 @@ CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx pri

# docker build -t issuance -f Dockerfiles/Dockerfile.issuance .
# docker run -d --env-file .env --name issuance docker.io/library/issuance
# docker logs -f issuance
# docker logs -f issuance
16 changes: 4 additions & 12 deletions Dockerfiles/Dockerfile.ledger
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Stage 1: Build the application
FROM node:18-alpine as build
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot

USER nonroot
RUN npm install --ignore-scripts -g pnpm
RUN npm install -g pnpm
# Set the working directory
WORKDIR /app

Expand All @@ -13,7 +9,7 @@ COPY package.json ./
#COPY package-lock.json ./

# Install dependencies
RUN pnpm i --ignore-scripts
RUN pnpm i

# Copy the rest of the application code
COPY . .
Expand All @@ -25,11 +21,7 @@ RUN npm run build ledger

# Stage 2: Create the final image
FROM node:18-alpine
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot

USER nonroot
RUN npm install --ignore-scripts -g pnpm
RUN npm install -g pnpm
# Set the working directory
WORKDIR /app

Expand All @@ -46,4 +38,4 @@ CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx pri

# docker build -t ledger -f Dockerfiles/Dockerfile.ledger .
# docker run -d --env-file .env --name ledger docker.io/library/ledger
# docker logs -f ledger
# docker logs -f ledger
2 changes: 1 addition & 1 deletion Dockerfiles/Dockerfile.notification
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx pri

# docker build -t notification -f Dockerfiles/Dockerfile.notification .
# docker run -d --env-file .env --name notification docker.io/library/notification
# docker logs -f notification
# docker logs -f notification
16 changes: 4 additions & 12 deletions Dockerfiles/Dockerfile.organization
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# Stage 1: Build the application
FROM node:18-alpine as build
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot

USER nonroot
RUN npm install --ignore-scripts -g pnpm
RUN npm install -g pnpm
# Set the working directory
WORKDIR /app

# Copy package.json and package-lock.json
COPY package.json ./

# Install dependencies
RUN pnpm i --ignore-scripts
RUN pnpm i

# Copy the rest of the application code
COPY . .
Expand All @@ -24,11 +20,7 @@ RUN pnpm run build organization

# Stage 2: Create the final image
FROM node:18-alpine
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot

USER nonroot
RUN npm install --ignore-scripts -g pnpm
RUN npm install -g pnpm
# Set the working directory
WORKDIR /app

Expand All @@ -45,4 +37,4 @@ CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx pri

# docker build -t organization -f Dockerfiles/Dockerfile.organization .
# docker run -d --env-file .env --name issuance docker.io/library/organization
# docker logs -f organization
# docker logs -f organization
22 changes: 6 additions & 16 deletions Dockerfiles/Dockerfile.user
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Stage 1: Build the application
FROM node:18-slim as build
RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot

USER nonroot
RUN npm install --ignore-scripts -g pnpm
RUN npm install -g pnpm

# We don't need the standalone Chromium
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
Expand All @@ -14,7 +10,7 @@ ENV PUPPETEER_SKIP_DOWNLOAD true
# Note: this installs the necessary libs to make the browser work with Puppeteer.
RUN apt-get update && apt-get install gnupg wget -y && \
wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
sh -c 'echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
apt-get update && \
apt-get install google-chrome-stable -y --no-install-recommends && \
rm -rf /var/lib/apt/lists/*
Expand All @@ -27,7 +23,7 @@ WORKDIR /app
COPY package.json ./

# Install dependencies
RUN pnpm i --ignore-scripts
RUN pnpm install

# Copy the rest of the application code
COPY . .
Expand All @@ -39,12 +35,6 @@ RUN pnpm run build user
# Stage 2: Create the final image
FROM node:18-slim

RUN addgroup -S nonroot \
&& adduser -S nonroot -G nonroot

USER nonroot

RUN npm install --ignore-scripts -g pnpm
# We don't need the standalone Chromium
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV PUPPETEER_SKIP_DOWNLOAD true
Expand All @@ -53,14 +43,14 @@ ENV PUPPETEER_SKIP_DOWNLOAD true
# Note: this installs the necessary libs to make the browser work with Puppeteer.
RUN apt-get update && apt-get install gnupg wget -y && \
wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
sh -c 'echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
apt-get update && \
apt-get install google-chrome-stable -y --no-install-recommends && \
rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /app

RUN npm install -g pnpm

# Copy the compiled code from the build stage
COPY --from=build /app/dist/apps/user/ ./dist/apps/user/
Expand All @@ -76,4 +66,4 @@ CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx pri

# docker build -t user -f Dockerfiles/Dockerfile.user .
# docker run -d --env-file .env --name user docker.io/library/user
# docker logs -f user
# docker logs -f user
Loading

0 comments on commit 9a48260

Please sign in to comment.