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

Add a docker release flow for building production services #19

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 3 additions & 3 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
gateway:
build:
dockerfile: Dockerfile.dev
dockerfile: ./docker/Dockerfile.dev
target: gateway-dev
context: .
volumes:
Expand All @@ -20,7 +20,7 @@ services:

auth-service:
build:
dockerfile: Dockerfile.dev
dockerfile: ./docker/Dockerfile.dev
target: auth-service-dev
context: .
volumes:
Expand All @@ -39,7 +39,7 @@ services:

db-service:
build:
dockerfile: Dockerfile.dev
dockerfile: ./docker/Dockerfile.dev
target: db-service-dev
context: .
volumes:
Expand Down
58 changes: 58 additions & 0 deletions docker-compose-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
services:
gateway:
image: gateway
ports:
- '3000:3000'
environment:
DB_SERVICE_ADDR: db-service
AUTH_SERVICE_ADDR: auth-service
networks:
- bog-api-net
depends_on:
- auth-service

auth-service:
image: auth-service
ports:
- '50052:50052'
environment:
AUTH_SERVICE_ADDR: auth-service
DB_SERVICE_ADDR: db-service
networks:
- bog-api-net
depends_on:
- db-service

db-service:
image: db-service
ports:
- '50053:50053'
environment:
AUTH_SERVICE_ADDR: auth-service
DB_SERVICE_ADDR: db-service
DATABASE_URL: postgresql://user:password@db
networks:
- bog-api-net
depends_on:
db:
condition: service_healthy

db:
image: postgres
restart: always
ports:
- '5432:5432'
environment:
POSTGRES_PASSWORD: password
POSTGRES_USER: user
networks:
- bog-api-net
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U user']
interval: 2s
timeout: 5s
retries: 10

networks:
bog-api-net:
driver: bridge
15 changes: 15 additions & 0 deletions docker/Dockerfile-auth-service.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM juno/deps AS deps

FROM node:18 as auth-service

WORKDIR /app

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

COPY --from=deps /app/packages/auth-service/node_modules ./packages/node_modules/

COPY . .

WORKDIR /app/packages/auth-service

CMD ["yarn", "start:prod"]
19 changes: 19 additions & 0 deletions docker/Dockerfile-db-service.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM juno/deps AS deps

FROM node:18 as db-service

WORKDIR /app

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

COPY --from=deps /app/packages/db-service/node_modules ./packages/node_modules/

COPY . .

RUN yarn global add prisma

WORKDIR /app/packages/db-service

RUN prisma generate

CMD ["yarn", "start:prod"]
15 changes: 15 additions & 0 deletions docker/Dockerfile-gateway.release
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM juno/deps AS deps

FROM node:18 as gateway

WORKDIR /app

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

COPY --from=deps /app/packages/api-gateway/node_modules ./packages/node_modules/

COPY . .

WORKDIR /app/packages/api-gateway

CMD ["yarn", "start:prod"]
33 changes: 33 additions & 0 deletions docker/Dockerfile.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM node:18-alpine as deps

WORKDIR /app

COPY . .

RUN apk add --update python3 make g++ protoc bash && rm -rf /var/cache/apk/*

RUN yarn global add node-gyp prisma

RUN yarn install --frozen-lockfile

RUN chmod a+x ./gen_protos.sh

RUN /bin/bash ./gen_protos.sh

WORKDIR /app/packages/api-gateway

RUN yarn install --frozen-lockfile

RUN yarn build

WORKDIR /app/packages/auth-service

RUN yarn install --frozen-lockfile

RUN yarn build

WORKDIR /app/packages/db-service

RUN yarn install --frozen-lockfile

RUN yarn build
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/api-gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"start": "yarn gen-proto && nest start",
"start:dev": "yarn start --watch",
"start:debug": "yarn start --debug --watch",
"start:prod": "yarn gen-proto && node dist/main",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
Expand Down
2 changes: 1 addition & 1 deletion packages/auth-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"start": "yarn gen-proto && nest start",
"start:dev": "yarn start --watch",
"start:debug": "yarn start --debug --watch",
"start:prod": "yarn gen-proto && node dist/main",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
Expand Down
2 changes: 1 addition & 1 deletion packages/db-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"start": "yarn gen-proto && nest start",
"start:dev": "yarn start --watch",
"start:debug": "yarn start --debug --watch",
"start:prod": "yarn gen-proto && node dist/main",
"start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
Expand Down