DEV Community

Dockerized SailsJS/ReactJS/MongoDB/Redis/RabbitMQ/Nginx denvironment

Sven Varkel on October 11, 2019

This post describes steps to set up expendable full stack denvironment. What's a denvironment, you may ask? It's development environment. That is j...
Collapse
 
fjvalles profile image
Francisco Vallés

Hi Sven, cool article! I cloned your repo and tried to run it and I got a permission error running git submodule update:

Cloning into '/Users/fjvalles/Projects/players/api'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@github.com:svenvarkel/players-api.git' into submodule path '/Users/fjvalles/Projects/players/api' failed
Failed to clone 'api'. Retry scheduled
Cloning into '/Users/fjvalles/Projects/players/web'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git@github.com:svenvarkel/players-web.git' into submodule path '/Users/fjvalles/Projects/players/web' failed
Failed to clone 'web'. Retry scheduled
Cloning into '/Users/fjvalles/Projects/players/api'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Also, I had to run "docker swarm init" before "docker-compose up", which throwed an error I guess because of the failed "git submodule update" from before:

...
Digest: sha256:1a9478d8188d6be31dd2e8de076d402edf20446e54933aad7ff49f5b457d486c
Status: Downloaded newer image for mongo:4.2
Building api
ERROR: Cannot locate specified Dockerfile: Dockerfile

I would appreciate if you could guide me please!

Thanks

Collapse
 
noitidart profile image
Noitidart

Awesome article Sven!

Collapse
 
nguyenhuutinh profile image
nguyenhuutinh

Thanks a lot for your article.
Can you give me some instruction for production build
Specially because react create a static files.
Thanks

Collapse
 
svenvarkel profile image
Sven Varkel • Edited

Hi, Nguyen. Thank you that you routed your question from GitHub to here :)

About production - yes, your React app would build static files, JS, HTML and CSS, right. So how I would do it?
Here's a guide that basically builds the react app and installs Nginx into the same container. So Nginx would serve the static files from the build results folder.
However - in my article I proposed a stack where Nginx is in a separate container and let it be that way, for fun :)
In this case I would probably create a new data volume called "common" and mount it to both containers - Nginx and web.

web:
    ...
    volumes:
        common:/var/app/current/public
nginx:
    ...
    volumes:
        common:/var/app/current/public

Add into web/Dockerfile:

...
RUN npm i
RUN npm run build
...

In Nginx conf I'd set the document root to /var/app/current/public

I haven't exactly tested it in production but it could work, in theory at least. Worth to try?

Please mind - right now I don't have a ReactJS app handy, I'm playing with Svelte. So the build folders etc may differ. But I hope you get the idea.

If this doesn't work then try with shared folder and mount it with bind option.