Skip to content

Commit

Permalink
Add docker-compose tasks image and improve dockerfile for prisma
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeoriani committed Apr 8, 2024
1 parent 2c1f9a4 commit 933eff1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ ENV NODE_ENV production
WORKDIR /app

COPY package.json yarn.lock ./
COPY prisma ./prisma

RUN yarn install --production


# --------------------------------------------------------------------

FROM node:20-alpine3.18

ENV NODE_ENV production
ENV PORT 3000
ENV JWT c565bc45-1818-41f3-be52-2b4d11fe959d
ENV DATABASE_URL "postgresql://admin:123@db:5432/tasks?schema=public"

RUN addgroup -g 1001 -S nodejs
RUN adduser -S expressjs -u 1001
Expand All @@ -29,6 +32,8 @@ COPY --from=BUILD_IMAGE --chown=expressjs:nodejs /app/package.json ./
COPY --from=BUILD_IMAGE --chown=expressjs:nodejs /app/node_modules ./node_modules
COPY .build/src .

RUN yarn prisma generate

USER expressjs

EXPOSE 3000
Expand Down
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
version: '3.5'

services:
api01: &api
image: tasks
hostname: api01
container_name: task-service-1
networks:
- default
environment:
- PORT=3000
- NODE_ENV=production
- JWT=7a2fad42-ff31-4e7f-9366-be2b4506fb7f
- DATABASE_URL=postgresql://admin:123@db:5432/tasks?schema=public
ports:
- '3001:3000'
depends_on:
- db

db:
image: postgres:16
hostname: db
container_name: db
networks:
- default
Expand Down

0 comments on commit 933eff1

Please sign in to comment.