From a36daaaec358a7682e6d0218bb35c633b46c4785 Mon Sep 17 00:00:00 2001 From: Riccardo Date: Wed, 30 Aug 2023 20:53:42 +0200 Subject: [PATCH] fix: correction to Docker files --- .dockerignore | 17 +++++++++++++++++ Dockerfile | 9 +++++---- docker-compose.yml | 4 +--- package.json | 5 +++-- prisma/schema.prisma | 4 ++-- yarn.lock | 5 ----- 6 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..0c861c8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,17 @@ +# Exclude locally installed packages +node_modules/ + +# Exclude build files +.dockerignore +Dockerfile + +# Exclude git history and configuration +.gitignore + +# Exclude IDE configuration +.husky +.github +.nvmrc +.prettierrc +commitlint.config.js +jest.config.js \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 5a8dfbc..96906bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,10 @@ # Development stage -FROM node:18-alpine3.18 as builder +FROM node:18 as builder WORKDIR /app -COPY package*.json ./ +COPY package*.json yarn.lock ./ +RUN yarn install --frozen-lockfile COPY . . @@ -17,10 +18,10 @@ RUN apt-get update && apt-get install -y openssl WORKDIR /app COPY --from=builder /app/package*.json ./ -COPY --from=builder /app/yarn.lock ./ COPY --from=builder /app/build ./build +COPY --from=builder /app/prisma ./prisma -RUN yarn install --production +RUN yarn install --frozen-lockfile --production EXPOSE 3000 diff --git a/docker-compose.yml b/docker-compose.yml index e890b0f..2e43801 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,13 +5,11 @@ services: build: context: ./ dockerfile: Dockerfile - image: backend_image + image: backend container_name: backend restart: unless-stopped ports: - '3000:3000' - volumes: - - .:/app environment: - PORT=3000 - DATABASE_URL=postgresql://postgres:postgres@postgres:5432/postgres diff --git a/package.json b/package.json index 5ba1065..5214c7b 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "node-with-typescript", + "name": "node-template-with-typescript", "version": "1.0.0", "description": "Backend with NodeJS in TypeScript", "main": "src/index.ts", @@ -7,10 +7,11 @@ "author": "riccardo.s@hey.com", "license": "MIT", "scripts": { + "start": "node build/index.js", "dev": "nodemon --watch 'src/**/*.ts' --exec 'ts-node' src/index.ts", "build": "tsc", "lint": "eslint --ext .ts . --fix", - "typecheck": "tsc", + "typecheck": "tsc --noEmit", "format": "prettier --config .prettierrc 'src/**/*.ts' --write", "test": "jest --runInBand", "prepare": "husky install", diff --git a/prisma/schema.prisma b/prisma/schema.prisma index ba276fb..74bdcc0 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -2,8 +2,8 @@ // learn more about it in the docs: https://pris.ly/d/prisma-schema generator client { - provider = "prisma-client-js" - binaryTargets = ["native", "linux-arm64-openssl-3.0.x"] + provider = "prisma-client-js" + // binaryTargets = ["native", "linux-arm64-openssl-3.0.x", "linux-arm64-openssl-1.1.x"] } datasource db { diff --git a/yarn.lock b/yarn.lock index e0fbb3b..78a3190 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1939,11 +1939,6 @@ cross-spawn@^7.0.2, cross-spawn@^7.0.3: shebang-command "^2.0.0" which "^2.0.1" -crypto@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/crypto/-/crypto-1.0.1.tgz#2af1b7cad8175d24c8a1b0778255794a21803037" - integrity sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig== - dargs@^7.0.0: version "7.0.0" resolved "https://registry.npmjs.org/dargs/-/dargs-7.0.0.tgz"