Skip to content

Commit bd64656

Browse files
committed
feat(docker): add Dockerfile for integration service and update docker-compose for auth and integration services
1 parent 42b2715 commit bd64656

File tree

2 files changed

+117
-0
lines changed

2 files changed

+117
-0
lines changed

apps/integration/Dockerfile

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
FROM node:22-slim AS base
2+
3+
# Enable corepack and pnpm
4+
RUN corepack enable
5+
RUN corepack prepare pnpm@latest --activate
6+
RUN node --version && \
7+
npm --version && \
8+
pnpm --version
9+
10+
# Set up PNPM_HOME
11+
ENV PNPM_HOME="/pnpm"
12+
ENV PATH="$PNPM_HOME:$PATH"
13+
RUN mkdir -p $PNPM_HOME
14+
15+
# Install system dependencies for native modules
16+
RUN apt-get update && \
17+
apt-get install -y --no-install-recommends \
18+
python3 \
19+
build-essential \
20+
openssl \
21+
libvips-dev \
22+
protobuf-compiler \
23+
&& rm -rf /var/lib/apt/lists/*
24+
25+
FROM base AS builder
26+
27+
WORKDIR /workspace
28+
# Copy root config files
29+
COPY package.json ./
30+
COPY pnpm*.yaml ./
31+
COPY nx.json ./
32+
COPY tsconfig*.json ./
33+
COPY jest.config.ts ./
34+
COPY jest.preset.js ./
35+
COPY eslint.config.mjs ./
36+
COPY webpack.*.config.js ./
37+
38+
# Copy monorepo apps and libs
39+
COPY apps/integration ./apps/integration
40+
COPY libs/nestjs ./libs/nestjs
41+
COPY libs/microservice-client ./libs/microservice-client
42+
COPY libs/grpc ./libs/grpc
43+
44+
# Install dependencies
45+
RUN pnpm install --frozen-lockfile
46+
47+
# Build the application
48+
RUN npx nx build integration
49+
50+
FROM base AS runner
51+
52+
WORKDIR /app
53+
54+
# Copy necessary files for production install
55+
COPY --from=builder /workspace/package.json ./
56+
COPY --from=builder /workspace/apps/integration/package.json ./apps/integration/package.json
57+
COPY --from=builder /workspace/libs/nestjs/package.json ./libs/nestjs/package.json
58+
COPY --from=builder /workspace/libs/microservice-client/package.json ./libs/microservice-client/package.json
59+
COPY --from=builder /workspace/libs/grpc/package.json ./libs/grpc/package.json
60+
COPY --from=builder /workspace/pnpm*.yaml ./
61+
62+
# Set production environment
63+
ENV NODE_ENV=production
64+
65+
# Install only production dependencies
66+
RUN pnpm install --frozen-lockfile --prod
67+
68+
# Copy built output
69+
COPY --from=builder /workspace/dist ./dist
70+
71+
CMD ["node", "dist/apps/integration/main"]
72+

docker-compose.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,51 @@ services:
6262
volumes:
6363
- redis_data:/data
6464

65+
auth:
66+
profiles:
67+
- 'all'
68+
- 'api'
69+
build:
70+
context: .
71+
dockerfile: ./apps/auth/Dockerfile
72+
container_name: square_me_auth
73+
ports:
74+
- '3000:3000'
75+
- '3333:3333'
76+
environment:
77+
PORT: 3000
78+
SWAGGER_PATH: 'swagger'
79+
SWAGGER_TITLE: 'Auth Service'
80+
SWAGGER_DESCRIPTION: 'Manages user and authentication'
81+
CORS_ORIGINS: http://localhost:4000,http://localhost:3001
82+
JWT_SECRET: TDCYJMDvpGdL+t5qn8nKSQ2NGAM6UL9+QnPy87Ehrlw=
83+
JWT_EXPIRATION_MS: 28800000
84+
AUTH_GRPC_SERVICE_URL: auth:3333
85+
WALLET_GRPC_SERVICE_URL: localhost:5001
86+
INTEGRATION_GRPC_URL: integration:4444
87+
SERVICE_ENTITY_PREFIX: 'auth-service-'
88+
DATABASE_URL: postgres://postgres:example@postgres:5432/auth?schema=public
89+
90+
integration:
91+
profiles:
92+
- 'all'
93+
- 'api'
94+
build:
95+
context: .
96+
dockerfile: ./apps/integration/Dockerfile
97+
container_name: square_me_integration
98+
ports:
99+
- '4444:4444'
100+
environment:
101+
PORT: 4444
102+
EXCHANGE_RATE_API_KEY: '<Insert Key here>'
103+
EXCHANGE_RATE_URL: 'https://v6.exchangerate-api.com'
104+
WALLET_GRPC_SERVICE_URL: localhost:5001
105+
INTEGRATION_GRPC_URL: integration:4444
106+
SERVICE_ENTITY_PREFIX: 'auth-service-'
107+
REDIS_URL: redis://:mypassword@redis:6379/0
108+
env_file: ./apps/integration/docker.env
109+
65110
volumes:
66111
postgres_data:
67112
redis_data:

0 commit comments

Comments
 (0)