nickjj / docker-rails-example

A production ready example Rails app that's using Docker and Docker Compose.
MIT License
941 stars 185 forks source link

Delete the contents of the /tmp directory #76

Closed edruder closed 3 months ago

edruder commented 3 months ago

Cached files in the /tmp directory can cause errors after renaming the project--nuke them so they don't cause grief.

edruder commented 3 months ago

I just pushed changes that I think simplify things the way that you want, though I haven't changed to a find that doesn't delete the .keep file.

edruder commented 3 months ago
nickjj commented 3 months ago

I changed your find suggestion slightly s.t. it works on both MacOS and Ubuntu.

Do you have a source around needing to set mindepth for it to work on macOS? I don't have a Mac to test.

I tweaked the comment s.t. it explains the need to delete the contents of the tmp directory.

I think we can remove the comments all together and adjust it to: https://github.com/nickjj/docker-rails-example/pull/76#discussion_r1527201497

Other than these 2 things, you can delete this text from the readme file too:

If you get an error upping the project related to RuntimeError: invalid bytecode then you have old tmp/ files sitting around related to the old project name, you can run ./run clean to clear all temporary files and fix the error.

edruder commented 3 months ago

I changed your find suggestion slightly s.t. it works on both MacOS and Ubuntu.

Do you have a source around needing to set mindepth for it to work on macOS? I don't have a Mac to test.

macOS didn't need mindepth–it worked fine with your exact suggestion. When I tried the same command on an Ubuntu VPS that I have, it didn't work–I found mindepth in an example somewhere, tried it, and it worked on my Ubuntu VPS. Then tried the command with mindepth on macOS and it still worked. WDYT?

I tweaked the comment s.t. it explains the need to delete the contents of the tmp directory.

I think we can remove the comments all together and adjust it to: #76 (comment)

Other than these 2 things, you can delete this text from the readme file too:

If you get an error upping the project related to RuntimeError: invalid bytecode then you have old tmp/ files sitting around related to the old project name, you can run ./run clean to clear all temporary files and fix the error.

OK. I'll modify the PR to reflect this.

nickjj commented 3 months ago

Sounds good, we can keep it in. I made a test directory and filled it with touch .keep && mkdir -p ok/cool && touch ok/cool/yep && touch sure. Both commands left a .keep file but without -mindepth 1, it threw a non-empty directory error.

JBerendes commented 3 months ago

I don't seem to have any problems with anything else in the tmp except the server.pid not getting cleaned up on a crash or computer restart.

I added this function and haven't had issues function dc_up { rm -f tmp/pids/server.pid docker compose up "${@}" }

now i use ./run dc_up or ./run dc_up --build

nickjj commented 3 months ago

Yep that's what I noticed too in practice but other changes can trigger it, https://github.com/nickjj/docker-rails-example/issues/16 has more details.

For pid files, there's https://github.com/nickjj/docker-rails-example/issues/65, there's a few ways to solve this such as configuring Puma and other services not to write pid files or cleaning them up automatically in an entrypoint.