stacker.news: Unable to run stacker.news locally
Description
I wonder if the instructions here are still up to date. I don’t seem to get the outcome that I would expect after running docker-compose up --build.
Steps to Reproduce I followed the first two steps (installed docker-compose and cloned the project from github).
Expected behavior I get these last 3 messages in my console logs. Attaching the full console logs here too. log.txt
app exited with code 0
Gracefully stopping... (press Ctrl+C again to force)
dependency failed to start: container app exited (0)
I would expect the app not to exit so that I can access the site at localhost:3000.
Environment: If you only experience the issue on certain devices or browsers, provide that info.
- Device: Macbook Pro from 2019 (also tried on an older iMac, with same results).
- Browser: Chrome
About this issue
- Original URL
- State: closed
- Created 4 months ago
- Comments: 55 (55 by maintainers)
Mhh, not sure why the CSP would block these requests which are essential for the app to load. Those are the ones using nonces. If your browser doesn’t support CSP nonces, it should fall back to host-based matching, so only inline scripts and scripts from the same domain are allowed:
– https://csp.withgoogle.com/docs/strict-csp.html
Does CSP also block the requests in Chrome?
You could try to disable the CSP using this patch:
patch
Copy the content into a file and run
git apply <file>.Does that fix the issue?
Yes, for shared volumes the files that docker creates in the shared volume have root perms on linux (doesn’t happen on windows and mac as the host for docker is actually a vm). The solve here (I think) is to tell docker to run commands unprivileged as a user with the host’s uid and gid … which is what I did in the follow on commits.
I think it’s because docker requires root permissions and then everything that is created inside a container has the owner root on the host machine
just an educated guess, not sure
I just pushed a change that might fix it:
From
useradd -h:I added
--verboseto thedocker composecommand and this is the output:It should be possible I’m looking into it. This might explain why some people have always had a hard time with our docker setup.
ohhhh hmmmmm I can assume and uid on builds maybe
That error code
23502suggests there a uniqueness constraint getting violated. I’m not sure why that would be the case but I’ll let you know if anything comes up.If you want, checkout this branch: https://github.com/stackernews/stacker.news/tree/localdev
Then run
./sndev startIt has a number of refinements to the docker setup that should make it more reliable and deterministic (in addition to populating db/search with a seed).
One more screenshot. I think this one might be helpful:
Output for
docker-compose up appActually, while I was resolving the issues that i encountered when using the
npm run workerapproach, it now works when using thedocker-compose up --buildapproach. I’m not sure what did the trick, I suspect it is because of the environment variable for OPENSEARCH, i.e. export OPENSEARCH_NODE which was export OPENSEARCH_URL on my system, but I can run SN locally athttp://localhost:3000/. I do get another error at this point, but just thought of updating here before I waste more of your time.EDIT: My hunch seems confirmed, I had to run
export OPENSEARCH_URL=http://localhost:3000before being able to run the container.