chore: add Dockerfile and docker-compose (#3)

This commit is contained in:
Riccardo Senica
2023-08-05 19:51:53 +02:00
committed by GitHub
parent 392e0db67b
commit 69cbe53a90
3 changed files with 54 additions and 0 deletions

19
Dockerfile Normal file
View File

@@ -0,0 +1,19 @@
# Build the Node.js app
FROM node:18 as builder
WORKDIR /app
# Copy package.json and package-lock.json (or yarn.lock) to the container
COPY package*.json ./
# Install project dependencies
RUN yarn install
# Copy the rest of the application code to the container
COPY . .
# Expose the port that your Node.js app is running on (change 3000 to your desired port)
EXPOSE 3000
# Define the command to start your Node.js application
CMD ["bash", "-c", "yarn db:generate && yarn db:migrate && yarn dev"]

34
docker-compose.yml Normal file
View File

@@ -0,0 +1,34 @@
version: '3.8'
services:
backend:
build:
context: ./
dockerfile: Dockerfile
image: backend_image
container_name: backend
restart: unless-stopped
ports:
- '3000:3000'
volumes:
- .:/app
environment:
- PORT=3000
- DATABASE_URL=postgresql://postgres:postgres@postgres:5432/postgres
depends_on:
- postgres
postgres:
image: postgres:latest
container_name: postgres
restart: unless-stopped
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- '5432:5432'
volumes:
- pgdata:/var/lib/postgresql/data
volumes:
pgdata:

View File

@@ -3,6 +3,7 @@
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-arm64-openssl-3.0.x"]
}
datasource db {