From 39e30c102b08a43a93d1efe8c4c3adf5776ccac7 Mon Sep 17 00:00:00 2001 From: Deki Date: Sun, 28 Aug 2022 04:43:04 +0700 Subject: [PATCH] fix deployment, run npm install at deployment --- Dockerfile | 2 +- README.md | 108 +++++++++++++++++++--------------------- docker-compose.prod.yml | 2 +- 3 files changed, 53 insertions(+), 59 deletions(-) diff --git a/Dockerfile b/Dockerfile index 63ad2b2..1e064a6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM node:gallium-slim WORKDIR /app -COPY . /app +ADD ./ /app RUN npm i -g @nestjs/cli USER node \ No newline at end of file diff --git a/README.md b/README.md index 08173d6..930fe8f 100644 --- a/README.md +++ b/README.md @@ -6,87 +6,81 @@ Image Optimizer Backend is a application for [image optimizer frontend](https:// ### Backend (this repo) - #### Without docker - - ```bash - # Clone this repository - git clone https://github.com/dekiakbar/image-optimizer - ``` - ```bash - # Navigate to project dir - cd image-optimizer - ``` + # Clone this repository + git clone https://github.com/dekiakbar/image-optimizer + ``` - ```bash - # Install node modules and dependencies - npm install + # Navigate to project dir + cd image-optimizer ``` - + - ```bash - # Run app + # Install node modules and dependencies + npm install + ``` - # development - $ npm run start - - # Watch mode - $ npm run start:dev - - # production mode - $ npm run start:prod - ``` + - ```bash + # Run app + + # development + $ npm run start + + # Watch mode + $ npm run start:dev + + # production mode + $ npm run start:prod + ``` - ```bash - # access swager api - http://localhost:3000 - ``` + # access swager api + http://localhost:3000 + ``` - #### Docker - ```bash - # Clone this repository - git clone https://github.com/dekiakbar/image-optimizer - ``` - - - ```bash - # Navigate to project dir - cd image-optimizer - ``` + # Clone this repository + git clone https://github.com/dekiakbar/image-optimizer + ``` - ```bash - # Build image and start container - docker-compose run --rm node npm install --legacy-peer-deps - ``` + # Navigate to project dir + cd image-optimizer + ``` - ```bash - # Build image and start container - docker-compose up -d - ``` + # Build image and start container + docker-compose up -d + ``` - ```bash - # access swager api - http://localhost:3000 - ``` - + # access swager api + http://localhost:3000 + ``` + - #### NOTE : if you wanna run npm command, please use this. + ```bash + docker-compose run --rm node npm install --legacy-peer-deps + ``` ## Deployment - #### Docker - ```bash - # Clone this repository - git clone https://github.com/dekiakbar/image-optimizer - ``` + # Clone this repository + git clone https://github.com/dekiakbar/image-optimizer + ``` - ```bash - # Navigate to project dir - cd image-optimizer - ``` - - - ```bash - # Build image and start container - docker-compose run --rm node npm install --legacy-peer-deps - ``` - + # Navigate to project dir + cd image-optimizer + ``` + - ```bash - # Build image and start container - docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d - ``` - + # Build image and start container + docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d + ``` + ## Environment Variable Copy `env.example` to `.env` diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index ade317f..e71f1cf 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -1,4 +1,4 @@ version: "3" services: node: - command: bash -c "npm run build && npm run start:prod" \ No newline at end of file + command: bash -c "npm install --legacy-peer-deps && npm run build && npm run start:prod" \ No newline at end of file