Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add db seed command in docker files #996

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions Dockerfiles/Dockerfile.agent-provisioning
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,43 @@
FROM node:18-alpine as build

RUN set -eux \
# Install packages and dependencies
&& apk --no-cache add \
openssh-client \
aws-cli \
docker \
docker-compose \
postgresql-client \
# Install pnpm globally without running scripts
&& npm install -g pnpm --ignore-scripts \
# Update PATH for pnpm
&& export PATH=$PATH:/usr/lib/node_modules/pnpm/bin \
# Clean up
&& rm -rf /var/cache/apk/*

# Add PostgreSQL client to the image
RUN apk add --no-cache postgresql-client

# Set the working directory
WORKDIR /app

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

# Install dependencies
RUN pnpm i
# Install dependencies safely
RUN pnpm i --ignore-scripts \
&& pnpm add -D ts-node typescript @types/node --ignore-scripts

# Copy the rest of the application code
COPY . .

RUN chown -R node:node /app/libs/prisma-service/prisma/scripts/
RUN chmod +x /app/libs/prisma-service/prisma/scripts/geo_location_data_import.sh
RUN chmod +x /app/libs/prisma-service/prisma/scripts/update_client_credential_data.sh

# Generate Prisma client
# RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate && npx prisma db seed
RUN ls -R /app/apps/agent-provisioning/AFJ/

# Build the user service
Expand Down Expand Up @@ -70,4 +83,4 @@ RUN chmod 777 /app/agent-provisioning/AFJ/token
COPY libs/ ./libs/

# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/agent-provisioning/main.js"]
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx prisma db seed && cd ../.. && node dist/apps/agent-provisioning/main.js"]
21 changes: 16 additions & 5 deletions Dockerfiles/Dockerfile.agent-service
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,32 @@ RUN npm install -g pnpm --ignore-scripts \
&& apk add aws-cli \
&& apk add docker \
&& apk add docker-compose


# Add PostgreSQL client to the image
RUN apk add --no-cache postgresql-client

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
# Install dependencies safely
RUN pnpm i --ignore-scripts \
&& pnpm add -D ts-node typescript @types/node --ignore-scripts


# Copy the rest of the application code
COPY . .

RUN chown -R node:node /app/libs/prisma-service/prisma/scripts/
RUN chmod +x /app/libs/prisma-service/prisma/scripts/geo_location_data_import.sh
RUN chmod +x /app/libs/prisma-service/prisma/scripts/update_client_credential_data.sh

# RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate && npx prisma db seed

# Build the user service
RUN pnpm run build agent-service
Expand Down Expand Up @@ -49,4 +60,4 @@ COPY --from=build /app/libs/ ./libs/
COPY --from=build /app/node_modules ./node_modules

# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/agent-service/main.js"]
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx prisma db seed && cd ../.. && node dist/apps/agent-service/main.js"]
18 changes: 14 additions & 4 deletions Dockerfiles/Dockerfile.api-gateway
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
# Stage 1: Build the application
FROM node:18-alpine as build
RUN npm install -g pnpm

# Add PostgreSQL client to the image
RUN apk add --no-cache postgresql-client

# Set the working directory
WORKDIR /app

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

# Install dependencies
RUN pnpm i
# Install dependencies safely
RUN pnpm i --ignore-scripts \
&& pnpm add -D ts-node typescript @types/node --ignore-scripts

# Copy the rest of the application code
COPY . .

RUN chown -R node:node /app/libs/prisma-service/prisma/scripts/
RUN chmod +x /app/libs/prisma-service/prisma/scripts/geo_location_data_import.sh
RUN chmod +x /app/libs/prisma-service/prisma/scripts/update_client_credential_data.sh

# RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate && npx prisma db seed

# Build the api-gateway service
RUN pnpm run build api-gateway
Expand All @@ -34,4 +44,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 && cd ../.. && node dist/apps/api-gateway/main.js"]
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx prisma db seed && cd ../.. && node dist/apps/api-gateway/main.js"]
17 changes: 13 additions & 4 deletions Dockerfiles/Dockerfile.cloud-wallet
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
FROM node:18-slim as build
RUN npm install -g pnpm

# Add PostgreSQL client to the image
RUN apk add --no-cache postgresql-client

RUN apt-get update -y
RUN apt-get --no-install-recommends install -y openssl
# Set the working directory
Expand All @@ -10,13 +13,19 @@ WORKDIR /app
# Copy package.json and package-lock.json
COPY package.json ./

# Install dependencies
RUN pnpm install
# Install dependencies safely
RUN pnpm i --ignore-scripts \
&& pnpm add -D ts-node typescript @types/node --ignore-scripts

# Copy the rest of the application code
COPY . .

RUN chown -R node:node /app/libs/prisma-service/prisma/scripts/
RUN chmod +x /app/libs/prisma-service/prisma/scripts/geo_location_data_import.sh
RUN chmod +x /app/libs/prisma-service/prisma/scripts/update_client_credential_data.sh

# RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate && npx prisma db seed

# Build the user service
RUN pnpm run build cloud-wallet
Expand All @@ -40,4 +49,4 @@ COPY --from=build /app/node_modules ./node_modules


# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/cloud-wallet/main.js"]
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx prisma db seed && cd ../.. && node dist/apps/cloud-wallet/main.js"]
18 changes: 14 additions & 4 deletions Dockerfiles/Dockerfile.connection
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
# Stage 1: Build the application
FROM node:18-alpine as build
RUN npm install -g pnpm

# Add PostgreSQL client to the image
RUN apk add --no-cache postgresql-client

# Set the working directory
WORKDIR /app

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

# Install dependencies
RUN pnpm i
# Install dependencies safely
RUN pnpm i --ignore-scripts \
&& pnpm add -D ts-node typescript @types/node --ignore-scripts

# Copy the rest of the application code
COPY . .

RUN chown -R node:node /app/libs/prisma-service/prisma/scripts/
RUN chmod +x /app/libs/prisma-service/prisma/scripts/geo_location_data_import.sh
RUN chmod +x /app/libs/prisma-service/prisma/scripts/update_client_credential_data.sh

# RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate && npx prisma db seed

# Build the connection service
RUN pnpm run build connection
Expand All @@ -37,4 +47,4 @@ COPY --from=build /app/node_modules ./node_modules
#RUN npm i --only=production

# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/connection/main.js"]
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx prisma db seed && cd ../.. && node dist/apps/connection/main.js"]
18 changes: 14 additions & 4 deletions Dockerfiles/Dockerfile.ecosystem
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
# Stage 1: Build the application
FROM node:18-alpine as build
RUN npm install -g pnpm

# Add PostgreSQL client to the image
RUN apk add --no-cache postgresql-client

# Set the working directory
WORKDIR /app

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

# Install dependencies
RUN pnpm i
# Install dependencies safely
RUN pnpm i --ignore-scripts \
&& pnpm add -D ts-node typescript @types/node --ignore-scripts

# Copy the rest of the application code
COPY . .

RUN chown -R node:node /app/libs/prisma-service/prisma/scripts/
RUN chmod +x /app/libs/prisma-service/prisma/scripts/geo_location_data_import.sh
RUN chmod +x /app/libs/prisma-service/prisma/scripts/update_client_credential_data.sh

# RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate && npx prisma db seed

# Build the issuance service
RUN pnpm run build ecosystem
Expand All @@ -35,4 +45,4 @@ COPY --from=build /app/node_modules ./node_modules


# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/ecosystem/main.js"]
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx prisma db seed && cd ../.. && node dist/apps/ecosystem/main.js"]
18 changes: 15 additions & 3 deletions Dockerfiles/Dockerfile.geolocation
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Stage 1: Build the application
FROM node:18-alpine as build
RUN npm install -g pnpm

# Add PostgreSQL client to the image
RUN apk add --no-cache postgresql-client

# Set the working directory
WORKDIR /app

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

# Install dependencies
RUN pnpm i
# Install dependencies safely
RUN pnpm i --ignore-scripts \
&& pnpm add -D ts-node typescript @types/node --ignore-scripts


# Copy the rest of the application code
COPY . .

RUN chown -R node:node /app/libs/prisma-service/prisma/scripts/
RUN chmod +x /app/libs/prisma-service/prisma/scripts/geo_location_data_import.sh
RUN chmod +x /app/libs/prisma-service/prisma/scripts/update_client_credential_data.sh

# RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate && npx prisma db seed

# Build the connection service
RUN pnpm run build geo-location
Expand All @@ -37,4 +49,4 @@ COPY --from=build /app/node_modules ./node_modules
#RUN npm i --only=production

# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/geo-location/main.js"]
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx prisma db seed && cd ../.. && node dist/apps/geo-location/main.js"]
19 changes: 15 additions & 4 deletions Dockerfiles/Dockerfile.issuance
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
# Stage 1: Build the application
FROM node:18-alpine as build
RUN npm install -g pnpm

# Add PostgreSQL client to the image
RUN apk add --no-cache postgresql-client

# Set the working directory
WORKDIR /app

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

# Install dependencies
RUN pnpm i
# Install dependencies safely
RUN pnpm i --ignore-scripts \
&& pnpm add -D ts-node typescript @types/node --ignore-scripts


# Copy the rest of the application code
COPY . .

RUN chown -R node:node /app/libs/prisma-service/prisma/scripts/
RUN chmod +x /app/libs/prisma-service/prisma/scripts/geo_location_data_import.sh
RUN chmod +x /app/libs/prisma-service/prisma/scripts/update_client_credential_data.sh

# RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate && npx prisma db seed

# Build the issuance service
RUN pnpm run build issuance
Expand All @@ -36,4 +47,4 @@ COPY --from=build /app/node_modules ./node_modules


# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/issuance/main.js"]
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx prisma db seed && cd ../.. && node dist/apps/issuance/main.js"]
19 changes: 15 additions & 4 deletions Dockerfiles/Dockerfile.ledger
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
# Stage 1: Build the application
FROM node:18-alpine as build
RUN npm install -g pnpm

# Add PostgreSQL client to the image
RUN apk add --no-cache postgresql-client

# Set the working directory
WORKDIR /app

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

# Install dependencies
RUN pnpm i
# Install dependencies safely
RUN pnpm i --ignore-scripts \
&& pnpm add -D ts-node typescript @types/node --ignore-scripts


# Copy the rest of the application code
COPY . .

RUN chown -R node:node /app/libs/prisma-service/prisma/scripts/
RUN chmod +x /app/libs/prisma-service/prisma/scripts/geo_location_data_import.sh
RUN chmod +x /app/libs/prisma-service/prisma/scripts/update_client_credential_data.sh

# RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate
RUN cd libs/prisma-service && npx prisma migrate deploy && npx prisma generate && npx prisma db seed

# Build the ledger service
RUN npm run build ledger
Expand All @@ -35,4 +46,4 @@ COPY --from=build /app/libs/ ./libs/
COPY --from=build /app/node_modules ./node_modules

# Set the command to run the microservice
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && cd ../.. && node dist/apps/ledger/main.js"]
CMD ["sh", "-c", "cd libs/prisma-service && npx prisma migrate deploy && npx prisma db seed && cd ../.. && node dist/apps/ledger/main.js"]
Loading