From 69cbe53a905e135dba4cc01caf77dd88115ef897 Mon Sep 17 00:00:00 2001 From: Riccardo Senica <46839416+RiccardoSenica@users.noreply.github.com> Date: Sat, 5 Aug 2023 19:51:53 +0200 Subject: [PATCH] chore: add Dockerfile and docker-compose (#3) --- Dockerfile | 19 +++++++++++++++++++ docker-compose.yml | 34 ++++++++++++++++++++++++++++++++++ prisma/schema.prisma | 1 + 3 files changed, 54 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d6aa60c --- /dev/null +++ b/Dockerfile @@ -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"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..e890b0f --- /dev/null +++ b/docker-compose.yml @@ -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: diff --git a/prisma/schema.prisma b/prisma/schema.prisma index c759ca1..ba276fb 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -3,6 +3,7 @@ generator client { provider = "prisma-client-js" + binaryTargets = ["native", "linux-arm64-openssl-3.0.x"] } datasource db {