Software-Engineering-Jagiellonian / django-celery-frege

Tool for measuring open source code repositories
GNU General Public License v3.0
6 stars 36 forks source link

Frontend: Missing react-scripts in containerised dev environment #71

Closed Iwomichu closed 1 year ago

Iwomichu commented 1 year ago

Outline

Clean startup of dev environment fails to start frontend container.

Steps to reproduce

  1. Clone repository
  2. Run docker-compose -f docker-compose.yml --profile dev up in repository root 2a. To make logs more readable, you can run docker-compose -f docker-compose.yml --profile dev up fregepoc-frontend-dev or use some kind of UI to see logs of fregepoc-frontend-dev container
  3. Check logs and see output similar to
    2023-03-06 20:39:53 > frontend@0.1.0 start
    2023-03-06 20:39:53 > react-scripts start
    2023-03-06 20:39:48 sh: react-scripts: not found

Potential cause

Frontend tries to start on clean node image without installed requirements. This error can go unnoticed when the environment is started from the developer machine due to the fact that node_modules directory is being added as a volume. It may prevent clean release (to on-prem server, vendor cloud etc.) in the future.

Quick solution

Go to frontend directory cd frontend and run npm install. After that, the node_modules directory will be attached as a volume to the container, fixing the issue.

Proposed solutions

  1. Create custom Docker image that will install required dependencies, for instance:
    FROM node:current-alpine
    COPY package.json .
    COPY package-lock.json .
    RUN npm install
  2. Add new points to readme that describe npm installation and node modules installation processes