Skip to content

Commit

Permalink
added dockerfile and docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
KDwevedi committed Dec 18, 2024
1 parent 4398e27 commit f8a2406
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 17 deletions.
26 changes: 26 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Schema Service
SCHEMA_BASE_URL=https://example.com/schema-service

# Credential Service
CREDENTIAL_BASE_URL=https://example.com/credential-service
C4GT_DID=did:example:123456789abcdefghi
DEFAULT_CERTIFICATE_LIFETIME=31536000

# Identity Service
IDENTITY_BASE_URL=url

# Certificates Verification
VERIFICATION_BASE_URL=https://example.com/verification-service

# MinIO Configuration
MINIO_USERNAME=your-minio-username
MINIO_PASSWORD=your-minio-password
MINIO_BUCKETNAME=your-bucket-name
MINIO_PORT=9000
MINIO_ENDPOINT=minioadminpassword
MINIO_SECRET_KEY=your-minio-secret-key
MINIO_ACCESS_KEY=minioadmin
MINIO_USE_SSL=true

# DB Config
C4GT_BFF_POSTGRES_BASE_URL=postgresql://postgres:password@localhost:5432/c4gtbff?schema=public
39 changes: 30 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
FROM node:16
# FROM --platform=linux/amd64 node:18-slim
# Stage 1: Build
FROM --platform=linux/amd64 node:18 AS builder

WORKDIR /app

# Install dependencies and build the application
COPY package.json ./
COPY yarn.lock ./
COPY prisma ./prisma/

RUN yarn
COPY . .
RUN yarn run build

# Stage 2: Runtime
FROM --platform=linux/amd64 node:18 AS runtime

WORKDIR /app

# Install required runtime dependencies
RUN apt-get update \
&& apt-get install -y wget gnupg \
&& wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& 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 -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 \
&& apt-get install -y google-chrome-stable fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf libxss1 ghostscript \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get install ghostscript=10.02.0
&& rm -rf /var/lib/apt/lists/*

# Copy necessary files from the builder stage
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/package.json ./
COPY --from=builder /app/yarn.lock ./
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/prisma ./prisma
COPY --from=builder /app/tsconfig.json ./

WORKDIR /app
COPY . ./
RUN yarn
EXPOSE 3001
CMD ["yarn", "start"]
CMD ["yarn", "start:prod"]
63 changes: 57 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,60 @@
version: '3'
version: '3.8'

services:
c4gt-bff:
image: c4gt-bff
build: https://github.com/techsavvyash/c4gt-bff.git
env_file: .env
restart: always
build:
context: .
dockerfile: Dockerfile
container_name: c4gt-bff
ports:
- '${SERVICE_PUBLIC_PORT}:3001'
- "3001:3001"
environment:
SCHEMA_BASE_URL: https://example.com/schema-service
CREDENTIAL_BASE_URL: https://example.com/credential-service
C4GT_DID: did:example:123456789abcdefghi
DEFAULT_CERTIFICATE_LIFETIME: 31536000
IDENTITY_BASE_URL: url
VERIFICATION_BASE_URL: https://example.com/verification-service
MINIO_USERNAME: your-minio-username
MINIO_PASSWORD: your-minio-password
MINIO_BUCKETNAME: your-bucket-name
MINIO_PORT: 9000
MINIO_ENDPOINT: minioadminpassword
MINIO_SECRET_KEY: your-minio-secret-key
MINIO_ACCESS_KEY: minioadmin
MINIO_USE_SSL: "true"
C4GT_BFF_POSTGRES_BASE_URL: postgres://postgres:postgres@postgres:5432/c4gt-bff
depends_on:
- postgres
- minio

postgres:
image: postgres:14
container_name: postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: c4gt-bff
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data

minio:
image: minio/minio:latest
container_name: minio
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadminpassword
ports:
- "9000:9000" # MinIO web access
- "9001:9001" # MinIO console access
command: server /data --console-address ":9001"
volumes:
- minio_data:/data

volumes:
postgres_data:
driver: local
minio_data:
driver: local
4 changes: 2 additions & 2 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ generator client {

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
url = env("C4GT_BFF_POSTGRES_BASE_URL")
}

model Schema {
Expand All @@ -27,7 +27,7 @@ model Template {
type String
verificationTemplate Template? @relation("TemplateToVerification", fields: [verificationTemplateId], references: [id])
verificationTemplateId String? // Foreign key for the self-relation
referencedBy Template[]? @relation("TemplateToVerification")
referencedBy Template[] @relation("TemplateToVerification")
}


0 comments on commit f8a2406

Please sign in to comment.