Skip to content

Commit 033fe86

Browse files
authored
Docker support for Express + PostgreSQL + Prisma Sample Application (#66)
* docker support for express-postgresql-prisma * added migrate command
1 parent 47bc3fc commit 033fe86

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use an official Node.js runtime as a parent image
2+
FROM node:18
3+
4+
# Set the working directory
5+
WORKDIR /usr/src/app
6+
7+
# Copy the package.json and package-lock.json files
8+
COPY package*.json ./
9+
10+
# Install dependencies
11+
RUN npm install
12+
13+
# Copy the rest of the application code
14+
COPY . .
15+
16+
RUN npm run generate
17+
RUN npm run migrate init
18+
19+
RUN npm run clean-build
20+
21+
# Expose the port the app runs on
22+
EXPOSE 3000
23+
24+
# Command to start the app
25+
CMD ["npm", "run", "start"]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
version: '3'
2+
services:
3+
app:
4+
build: .
5+
ports:
6+
- "3000:3000"
7+
environment:
8+
DATABASE_URL: "postgresql://postgres:mysecretpassword@db:5432/postgres"
9+
PORT: 3000
10+
depends_on:
11+
- db
12+
13+
db:
14+
image: postgres
15+
environment:
16+
POSTGRES_USER: postgres
17+
POSTGRES_PASSWORD: mysecretpassword
18+
ports:
19+
- "5432:5432"
20+
volumes:
21+
- postgres-data:/var/lib/postgresql/data
22+
23+
volumes:
24+
postgres-data:

0 commit comments

Comments
 (0)