yoonic / nicistore

Isomorphic React E-Commerce Storefront
MIT License
662 stars 202 forks source link

Deploying on Digital Ocean with Docker #13

Closed mateomorrison closed 7 years ago

mateomorrison commented 7 years ago

Any quickstart on deploying this on Digital Ocean with Docker?

mateomorrison commented 7 years ago

First: Create your Docker Machine.

docker-machine create \
  --driver digitalocean \
  --digitalocean-access-token <Your API Key> \
  --digitalocean-size 1gb \
yoonic

Second: Point your Docker to launch containers eval "$(docker-machine env yoonic)"

Third: Run Yoonic

??? How to do it

mateomorrison commented 7 years ago

@andreftavares When running the command, I think the structure should be like this:

docker run -d \ -p 80:80 (what port?) -e ROOT_URL="http://website.com" docker:docker what hub.docker.com repository, if there is any?

andrecrt commented 7 years ago

Well... it all depends on the level of orchestration you want. The simplest approach is to launch a droplet using the Docker Application they provide, which provide you an environment suitable for running your containers out-of-the-box.

Then you would launch 3 containers: rethinkdb, atlas and nicistore.

You can use the "Dockerfile" from atlas/nicistore or base your own on it. They are in a production state of development, so you can use them.

mateomorrison commented 7 years ago

Can you tell me which commands to use to get it started? First lo launch nicistore and test it against nicistore.com API. @andreftavares

andrecrt commented 7 years ago

1) docker build -t yoonic/nicistore . 2) docker run -d --name nicistore -p 3000:3000 -t yoonic/nicistore

mateomorrison commented 7 years ago

@andreftavares Some errors found: docker-build -t yoonic/nicistore

"docker build" requires exactly 1 argument(s). See 'docker build --help'

Usage: docker build [OPTIONS] PATH | URL | -

Build an image from a Dockerfile`

and docker run -d --name nicistore -p 3000:3000 -t yoonic/nicistore

Unable to find image 'yoonic/nicistore:latest' locally docker: Error response from daemon: repository yoonic/nicistore not found: does not exist or no pull access. See 'docker run --help'.

I think you should have a repository on https://hub.docker.com/ too to have it working.

andrecrt commented 7 years ago

1) You need the "." on the end of the build command I posted. It means that the dockerfile is in the current directory. 2) Run won't work if the image does not exist. Since build failed, run will fail.

mateomorrison commented 7 years ago

If anyone gets confused. To run the commands the actual process is:

  1. git clone https://github.com/yoonic/nicistore.git && cd nicistore Need to git clone
  2. docker build -t yoonic/nicistore . This step will actually build the environment and run all needed commands.
  3. docker run -d --name nicistore -p 3000:3000 -t yoonic/nicistore Running your macine!
  4. Check docker-machine ls it should show Running on STATE.
  5. Check docker ps -a it should have yoonic/nicistore on IMAGE.

Added as a gist for those interested πŸ’― This worked for me!

mateomorrison commented 7 years ago

Thanks @andreftavares

One more thing: When I docker-machine ip <machine name> it outputs my IP Address. But when I access it on my website it's not showing anything. So I can't point out my DNS.

Maybe because it's showing to 0.0.0.0:3000 instead of :3000?

If so how to fix it? screen shot 2017-02-26 at 8 05 41 pm

mateomorrison commented 7 years ago

When I docker inspect the container it shows me the host IP as 0.0.0.0 and Port 3000. Why is this container not connecting to my docker-machine and actually now showing anything. Something done wrong? @andreftavares

andrecrt commented 7 years ago

I don't have any experience with Docker Machine. Sorry, can't help you with that :/

phoenixvk commented 7 years ago

Use pm2. It is more simple.

Vaibhav Kadam B.Tech.(Information Technology) +91 9404241842 Optional Email - vaibhav.kadam45@live.com, Vita, District- Sangli, State- Maharashtra,India.

On Mon, Feb 27, 2017 at 2:35 PM, AndrΓ© Tavares notifications@github.com wrote:

I don't have any experience with Docker Machine. Sorry, can't help you with that :/

β€” You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/yoonic/nicistore/issues/13#issuecomment-282664128, or mute the thread https://github.com/notifications/unsubscribe-auth/ANaQ0fWqyB55uc8OEeD9aMomnju3VcSEks5rgpG-gaJpZM4MMYxP .

mateomorrison commented 7 years ago

@phoenixvk Any quickstart? Which commands should I use?

pm2 -v 2.4.0

node -v 4.8.0

npm -v 2.15.11

mateomorrison commented 7 years ago

@andreftavares @phoenixvk I don't think open a new issue is necessary. I successfully installed npm install the nicistore like it was on my PC. But still the ip 0.0.0.0 is giving error. You should fix that to auto assign the IP, otherwise I don't see any other way to have this as a real store than just hacking around in the local machine.

It all compiled perfect but when going to the IP Address. Nothing shows up. Here is the timeline

  1. git clone https://github.com/yoonic/nicistore.git && cd nicistore
  2. npm install Had to add a SWAP file because npm is memory consuming
  3. Success, installed πŸ‘
  4. Running npm run build ... Done
  5. Running npm run dev ... Done .... Until
  6. Stopped at 'webpack: Compiled successfully.' Huh? Maybe it's already working! Let me go to my Digital Ocean Droplet IPV4 address.
  7. Nothing shows up πŸ‘Ž

UPDATE: To fix it, access YOUR.IP.ADDRESS.HERE:**3000**

Accessing using the port 3000 fix the issue πŸ‘

If you need to point out DNS to your IP droplet, run this command and it will redirect any request from port 80 to port 3000, which is where Nicistore is listening. sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000

Source

phoenixvk commented 7 years ago

I did follow this tutorial. It worked for me :+1: https://www.youtube.com/watch?v=kR06NoSzAXY

mateomorrison commented 7 years ago

@phoenixvk It was great! I learned how to do both, by failing over and over. However I strongly recommend hosting it on a container of Docker. Learning how to Nginx and Lets Encrypt docker now.

phoenixvk commented 7 years ago

@mateomorrison how did you fix issue with ip address 0.0.0.0:3000? I'm not getting I'm having same issue with docker

phoenixvk commented 7 years ago

@andreftavares How did you deploy Nicistore and Atlas any doc available?

phoenixvk commented 7 years ago

@mateomorrison anybody can elaborate step by step process to deploy this app using docker

phoenixvk commented 7 years ago

@andreftavares @mateomorrison @briankereszturi I've same query which mateo have that

When I docker inspect the container it shows me the host IP as 0.0.0.0 and Port 3000. Why is this container not connecting to my docker-machine and actually now showing anything. Something done wrong? Please resolve my issue. thank you.