12joan / twitter-client

A temporary Twitter client for fetching recent tweets for use while Twitter is closed to guest users
The Unlicense
26 stars 5 forks source link

nodemon: not found #6

Open regystro opened 1 year ago

regystro commented 1 year ago

Hi.

I get this error when deploying locally:

web_1    | yarn run v1.22.19
web_1    | $ nodemon src/server.ts -w src
web_1    | /bin/sh: nodemon: not found
web_1    | error Command failed with exit code 127.
web_1    | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
twitter-client_web_1 exited with code 127

Thanks for your effort and sharing.

12joan commented 1 year ago

Hi, sorry about that.

It looks like the app volume in docker-compose.yml is overriding the node_modules/ directory built by the Dockerfile. As a temporary fix, just run yarn install on host and try again.

Steeven9 commented 1 year ago

Hold on, why would you need to mount the whole directory? Just remove the volume and command lines from the docker-compose file, it works perfectly without having to install node modules on the host :)

moppman commented 1 year ago

Steeven9 is correct, the following is working fine:

diff --git a/docker-compose.yml b/docker-compose.yml
index fca6735..4a82d1a 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -3,11 +3,8 @@ version: '3'
 services:
   web:
     build: .
-    volumes:
-      - ./:/app
     ports:
       - '3000:3000'
-    command: yarn dev
     environment:
       REDIS_URL: redis://redis:6379
       HOST: '0.0.0.0'
12joan commented 1 year ago

The /docker-compose.yml is intended for development, so having the files inside Docker change when the files outside are changed is essential for DX. 🙂

I usually use a separate docker-compose.yml file for deployment, outside the repo. If we want to include one here without the volume and yarn dev lines, we could call it docker-compose.prod.yml?

Steeven9 commented 1 year ago

Fair enough, but tbh for development why not run nodemon on the host machine directly since you have to install node modules anyway? You could just spin up redis with docker run on the side :)

12joan commented 1 year ago

That's certainly one way of doing it. Generally, I prefer to either keep everything in Docker or not use it at all.

I wonder if there's a way to tell Node to keep node_modules somewhere else, where it won't be overridden by the volume?

IngwiePhoenix commented 1 year ago

Ran into this as well when trying to build an arm64 image on my maschine since none was available on Docker Hub. Thanks for the temporary fix!

Is there a way I could contribute the arm64 build? Might be useful since this is a very low-resource service, so it would do great on smaller boxes like SBCs.

12joan commented 1 year ago

Is there a way I could contribute the arm64 build? Might be useful since this is a very low-resource service, so it would do great on smaller boxes like SBCs.

I'm not sure what this would involve. Perhaps changing the deployment scripts (push.yml and deploy.yml) in some way? If you can figure out how to do it, please go ahead and open a PR. You can use act to test the GitHub actions locally.