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

Fix Docker issue #10

Merged
merged 3 commits into from
Oct 24, 2023
Merged
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
32 changes: 19 additions & 13 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
services:
gateway:
build:
dockerfile: ./packages/api-gateway/Dockerfile.dev
dockerfile: Dockerfile.dev
context: ./packages/api-gateway/
volumes:
- /app/node_modules
- ./packages/api-gateway:/app
- ./packages/proto:/proto
- ./packages/api-gateway:/app/src
- ./packages/proto:/app/proto
ports:
- '3000:3000'
entrypoint: yarn start:dev
Expand All @@ -19,11 +19,11 @@ services:

auth-service:
build:
dockerfile: ./packages/auth-service/Dockerfile.dev
dockerfile: Dockerfile.dev
context: ./packages/auth-service
volumes:
- /app/node_modules
- ./packages/auth-service:/app
- ./packages/proto:/proto
- ./packages/auth-service:/app/src
- ./packages/proto:/app/proto
ports:
- '50052:50052'
entrypoint: yarn start:dev
Expand All @@ -37,11 +37,11 @@ services:

db-service:
build:
dockerfile: ./packages/db-service/Dockerfile.dev
dockerfile: Dockerfile.dev
context: ./packages/db-service
volumes:
- /app/node_modules
- ./packages/db-service:/app
- ./packages/proto:/proto
- ./packages/db-service:/app/src
- ./packages/proto:/app/proto
ports:
- '50053:50053'
entrypoint: ./entrypoint.sh
Expand All @@ -52,7 +52,8 @@ services:
networks:
- bog-api-net
depends_on:
- db
db:
condition: service_healthy

db:
image: postgres
Expand All @@ -64,6 +65,11 @@ services:
POSTGRES_USER: user
networks:
- bog-api-net
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U user']
interval: 5s
timeout: 5s
retries: 5

networks:
bog-api-net:
Expand Down
14 changes: 10 additions & 4 deletions packages/api-gateway/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
FROM node:18 as deps
FROM node:18-alpine as deps

WORKDIR /app

COPY package.json yarn.lock
RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/*

RUN yarn install --frozen-lockfile
COPY package.json ./

RUN yarn install

FROM node:18 as dev

WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules/

ENV PATH=/app/node_modules/.bin:$PATH

WORKDIR /app/src

COPY . .

EXPOSE 3000
EXPOSE 3000
1 change: 1 addition & 0 deletions packages/api-gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"tsc": "tsc"
},
"dependencies": {
"@grpc/grpc-js": "^1.9.7",
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.1.1",
"@nestjs/core": "^10.0.0",
Expand Down
12 changes: 9 additions & 3 deletions packages/auth-service/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
FROM node:18 as deps
FROM node:18-alpine as deps

WORKDIR /app

COPY package.json yarn.lock
RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/*

RUN yarn install --frozen-lockfile
COPY package.json ./

RUN yarn install

FROM node:18 as dev

WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules/

ENV PATH=/app/node_modules/.bin:$PATH

WORKDIR /app/src

COPY . .

EXPOSE 50052
1 change: 1 addition & 0 deletions packages/db-service/.dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
**/node_modules
!prisma/
22 changes: 19 additions & 3 deletions packages/db-service/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
FROM node:18 as deps
FROM node:18-alpine as deps

WORKDIR /app

COPY package.json yarn.lock
RUN apk add --update python3 make g++ && rm -rf /var/cache/apk/*

RUN yarn install --frozen-lockfile
RUN yarn global add node-gyp prisma

COPY package.json ./

RUN mkdir prisma

RUN yarn install

FROM node:18 as dev

RUN yarn global add nest prisma

WORKDIR /app

COPY --from=deps /app/node_modules ./node_modules/

ENV PATH=/app/node_modules/.bin:$PATH

COPY ./prisma/ ./prisma/

RUN prisma generate

WORKDIR /app/src

COPY . .

EXPOSE 50053
4 changes: 1 addition & 3 deletions packages/db-service/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash

yarn prisma migrate deploy

yarn prisma generate
prisma migrate dev

yarn start:dev