Skip to content

Commit

Permalink
Merge pull request #74 from TAnas0/feature/70-update-docker-setup
Browse files Browse the repository at this point in the history
Update Docker setup
  • Loading branch information
TAnas0 authored Sep 12, 2024
2 parents 7e727e7 + 3647c9b commit 01e2019
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 49 deletions.
3 changes: 3 additions & 0 deletions .env.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Environment variables to use for local Docker setup
DATABASE_URL="postgresql://postgres:password@db:5432/prisma?schema=public"
NODE_ENV="development"
22 changes: 10 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
FROM node:8.12.0-alpine as Builder
FROM node:22.8.0-alpine3.20 AS builder

WORKDIR /usr/app

# See .dockerignore for copied files
COPY . .

RUN npm install --no-package-lock
RUN npm run build:production
RUN npm install
RUN npm run build

FROM node:8.12.0-alpine
WORKDIR /app
COPY --from=Builder /usr/app/dist /app/dist
COPY --from=Builder /usr/app/package.json /app/package.json
RUN npm install --no-package-lock --production
# EXPOSE 4000

CMD ["node", "./dist/main.js"]
FROM node:22.8.0-alpine3.20

WORKDIR /app
COPY --from=builder /usr/app/dist /app/dist
COPY --from=builder /usr/app/package.json /app/package.json
COPY --from=builder /usr/app/src/prisma/schema.prisma /app/src/prisma/schema.prisma
RUN npm install


CMD ["node", "./dist/main.js"]
49 changes: 12 additions & 37 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,19 @@ services:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: prisma
networks:
- "prisma"

prisma:
container_name: "prisma"
image: prismagraphql/prisma:1.22
restart: always
# The API is better launched using `npm run dev` for hot reloading
api:
container_name: graphql-api
build: .
env_file:
- ./.env.docker
command: >
sh -c '
sleep 5 &&
npx prisma migrate dev --name init &&
npx prisma generate'
ports:
- 7766:7766
environment:
PRISMA_CONFIG: |
port: 7766
databases:
default:
connector: postgres
active: true
host: db
port: 5432
user: postgres
password: password
migrations: true
- 4000:4000
depends_on:
# - api
- db
networks:
- "prisma"

# The API is better launched using `npm run dev` for hot reloading
# api:
# container_name: graphql-api
# build:
# context: ./backend
# dockerfile: ./Dockerfile
# env_file:
# - ./backend/.env.dev
# ports:
# - 4000:4000

networks:
prisma:
driver: "bridge"

0 comments on commit 01e2019

Please sign in to comment.