Skip to content

Commit

Permalink
feat: Completed the Docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
vasujain275 committed Apr 22, 2024
1 parent ccd1c0e commit fac3993
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 33 deletions.
12 changes: 5 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ COPY pnpm-lock.yaml .

RUN npm install -g pnpm

RUN pnpm install -P

# Install postgresql-client for the psql command
RUN apt-get update && apt-get install -y postgresql-client
RUN pnpm install

COPY . .

# Use the wait-for-postgres.js script to ensure Postgres is ready before running migrations and starting the server
CMD node scripts/wait-for-postgres.js && pnpm dlx prisma migrate deploy && pnpm run start

EXPOSE 8069

RUN pnpm dlx prisma generate

CMD [ "pnpm", "run", "start" ]
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ This project is a simple Express API that serves as a backend for managing a col

- Set up your PostgreSQL instance according to your preference. After setting up, run `pnpm dlx prisma migrate` to apply migrations using Prisma.

```bash
docker exec -it bookstore_api /bin/bash -c "cd /app && pnpm dlx prisma migrate deploy"
```


7. **Start the development server:**
- Finally, start the development server by running `pnpm dlx run dev`.

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres123}
POSTGRES_DB: ${POSTGRES_DB:-bookstoreDB}

api:
server:
build:
context: .
dockerfile: Dockerfile
Expand Down
25 changes: 0 additions & 25 deletions scripts/wait-for-postgres.js

This file was deleted.

0 comments on commit fac3993

Please sign in to comment.