Skip to content

Commit 4951f72

Browse files
authored
Merge pull request #1228 from credebl/refactor/optimise-dockerfile
refactor: update dockerfile to reduce dockerimages
1 parent 91e5052 commit 4951f72

File tree

6 files changed

+26
-52
lines changed

6 files changed

+26
-52
lines changed

Dockerfiles/Dockerfile.cloud-wallet

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# Stage 1: Build the application
2-
FROM node:18-slim as build
2+
FROM node:18-alpine AS build
33
# Install OpenSSL
4+
RUN apk add --no-cache openssl
45
RUN npm install -g pnpm
56

6-
RUN apt-get update -y
7-
RUN apt-get --no-install-recommends install -y openssl
87
# Set the working directory
98
WORKDIR /app
109

@@ -25,10 +24,10 @@ RUN cd libs/prisma-service && npx prisma generate
2524
RUN pnpm run build cloud-wallet
2625

2726
# Stage 2: Create the final image
28-
FROM node:18-slim
27+
FROM node:18-alpine
28+
29+
RUN apk add --no-cache openssl
2930

30-
RUN apt-get update -y
31-
RUN apt-get --no-install-recommends install -y openssl
3231
# Set the working directory
3332
WORKDIR /app
3433
# RUN npm install -g pnpm

Dockerfiles/Dockerfile.seed

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
FROM node:18 as build
1+
FROM node:18-alpine
22

33
# Install pnpm
44
RUN npm install -g pnpm
55

6-
# Install PostgreSQL client (use apt for Debian-based images)
7-
RUN apt-get update && apt-get install -y postgresql-client
6+
RUN apk add --no-cache postgresql-client openssl
87

98
# Set working directory
109
WORKDIR /app
1110

1211
COPY . .
12+
RUN chmod +x /app/libs/prisma-service/prisma/scripts/geo_location_data_import.sh
13+
RUN chmod +x /app/libs/prisma-service/prisma/scripts/update_client_credential_data.sh
1314

15+
ENV PUPPETEER_SKIP_DOWNLOAD=true
1416
RUN pnpm i --ignore-scripts
1517

1618
# Run Prisma commands

Dockerfiles/Dockerfile.user

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,20 @@
11
# Stage 1: Build the application
2-
FROM node:18-slim as build
3-
4-
2+
FROM node:18-alpine AS build
53

4+
# Install OpenSSL
5+
RUN apk add --no-cache openssl
66
RUN npm install -g pnpm
77

8-
# We don't need the standalone Chromium
9-
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
10-
ENV PUPPETEER_SKIP_DOWNLOAD true
11-
12-
# Install Google Chrome Stable and fonts
13-
# Note: this installs the necessary libs to make the browser work with Puppeteer.
14-
RUN apt-get update && apt-get install openssl gnupg wget -y && \
15-
wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
16-
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
17-
apt-get update && \
18-
apt-get install google-chrome-stable -y --no-install-recommends && \
19-
rm -rf /var/lib/apt/lists/*
20-
21-
# RUN apk update && apk list --all-versions chromium
228
# Set the working directory
239
WORKDIR /app
2410

2511
# Copy package.json and package-lock.json
2612
COPY package.json ./
2713

14+
ENV PUPPETEER_SKIP_DOWNLOAD=true
15+
2816
# Install dependencies
29-
RUN pnpm install
17+
RUN pnpm i --ignore-scripts
3018

3119
# Copy the rest of the application code
3220
COPY . .
@@ -37,24 +25,11 @@ RUN cd libs/prisma-service && npx prisma generate
3725
RUN pnpm run build user
3826

3927
# Stage 2: Create the final image
40-
FROM node:18-slim
41-
42-
# We don't need the standalone Chromium
43-
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
44-
ENV PUPPETEER_SKIP_DOWNLOAD true
45-
46-
# Install Google Chrome Stable and fonts
47-
# Note: this installs the necessary libs to make the browser work with Puppeteer.
48-
RUN apt-get update && apt-get install openssl gnupg wget -y && \
49-
wget --quiet --output-document=- https://dl-ssl.google.com/linux/linux_signing_key.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/google-archive.gpg && \
50-
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
51-
apt-get update && \
52-
apt-get install google-chrome-stable -y --no-install-recommends && \
53-
rm -rf /var/lib/apt/lists/*
28+
FROM node:18-alpine
5429

30+
RUN apk add --no-cache openssl
5531
# Set the working directory
5632
WORKDIR /app
57-
RUN npm install -g pnpm
5833

5934
# Copy the compiled code from the build stage
6035
COPY --from=build /app/dist/apps/user/ ./dist/apps/user/

Dockerfiles/Dockerfile.utility

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# Stage 1: Build the application
2-
FROM node:18-slim as build
2+
FROM node:18-alpine AS build
33

4+
# Install OpenSSL
5+
RUN apk add --no-cache openssl
46
RUN npm install -g pnpm
5-
6-
RUN apt-get update -y
7-
RUN apt-get --no-install-recommends install -y openssl
87
# Set the working directory
98
WORKDIR /app
109

@@ -25,10 +24,9 @@ RUN cd libs/prisma-service && npx prisma generate
2524
RUN pnpm run build utility
2625

2726
# Stage 2: Create the final image
28-
FROM node:18-slim
27+
FROM node:18-alpine
2928

30-
RUN apt-get update -y
31-
RUN apt-get --no-install-recommends install -y openssl
29+
RUN apk add --no-cache openssl
3230
# Set the working directory
3331
WORKDIR /app
3432
# RUN npm install -g pnpm

libs/prisma-service/prisma/scripts/geo_location_data_import.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
# Database connection details
44
DB_URL=$1

libs/prisma-service/prisma/scripts/update_client_credential_data.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

33
# Database connection URL
44
DB_URL=$1
@@ -30,7 +30,7 @@ update_client_credentials() {
3030
}
3131

3232
# Check if CLIENT_ID and CLIENT_SECRET are not empty
33-
if [[ -n "$CLIENT_ID" && -n "$CLIENT_SECRET" ]]; then
33+
if [ -n "$CLIENT_ID" ] && [ -n "$CLIENT_SECRET" ]; then
3434
# Update client credentials if both CLIENT_ID and CLIENT_SECRET are provided
3535
update_client_credentials
3636
else

0 commit comments

Comments
 (0)