Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker (compose) #227

Open
mawoka-myblock opened this issue Nov 19, 2021 · 6 comments
Open

Docker (compose) #227

mawoka-myblock opened this issue Nov 19, 2021 · 6 comments
Labels

Comments

@mawoka-myblock
Copy link

I think Docker would be a very nice addition since I'm having problems setting it up and docker(-compose) would make it way easier!

@Skabunkel
Copy link

Skabunkel commented Nov 19, 2021

I think so too, and I started working on a Dockerfile for it, but I'm a little out of it after work, so I'm like a few stairs short of a full shoe collection right now.

But I have something that I think work.
It's very dirty, but it's a start.

Dockerfile

FROM golang:1.17.3-buster AS base

#My brain is full of butterflies and spagett after work if i remove install npm it will not let me run dgraph make install (╯°□°)╯︵ ┻━┻
RUN apt-get -y update && apt-get -y install npm && curl -sL https://deb.nodesource.com/setup_15.x | bash - && apt-get -y update && apt-get -y install nodejs && apt-get -y clean
RUN npm install -g yarn

FROM base AS build-unigraph-dev-dgraph 

WORKDIR /src/dgraph
RUN git clone https://github.com/unigraph-dev/dgraph.git . && make install 

FROM build-unigraph-dev-dgraph  AS build-unigraph-dev

WORKDIR /src/unigraph
RUN git clone https://github.com/unigraph-dev/unigraph-dev.git .
RUN yarn install && yarn build-deps && npm install
RUN mkdir -p /data/unigraph

Build this with.
docker build -t unigraph-dev:latest .

docker-compose.yml

version: '3'

services:
  backend:
    image: unigraph-dev:latest
    entrypoint: ./scripts/start_server.sh -d /data/unigraph -b /go/bin/dgraph
    ports:
      - 3001:3001

  frontend:
    image: unigraph-dev:latest
    entrypoint: yarn explorer-start
    depends_on:
      - backend
    ports:
      - 3000:3000
      

Edit... I'm going to sleep now... the server port was in the wrong place, Good night.

@the-ebdm
Copy link

the-ebdm commented Nov 20, 2021

I've created a more fleshed out version of this with SRP (separate dgraph image and services) - just running into a bug in the codebase itself but I'll get a PR in once I've got it all running properly

Edit: grammar

@reeseovine
Copy link

@Skabunkel's Dockerfile and compose file work for me as-is, but when I try to put the frontend behind Traefik it gives me this react-style SecurityError:
image

@aquarial
Copy link

aquarial commented Dec 7, 2021

@katacarbix

That's a websocket error. Unigraph tries to open a websocket to ws://hostname.com:3001. This works if everything is running on localhost, but if you have a proxy (nginx, traefik, etc) it won't be secure. Got some help in the discord; Two things to fix: 1 configure proxy to route websockets. 2 change unigraph websocket address

  1. This is what a working nginx config looks like, I'm not familiar with traefik. Note the two location blocks, one for the ui, one for websockets on /ws/
server {
    server_name <hostname>;
    location / {
        proxy_pass http://localhost:3000;
    }
    location /ws/ {
        proxy_pass http://localhost:3001;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
    }

    # ssl / letsencrypt stuff
    listen [::]:443 ssl;
    listen 443 ssl;
}
  1. Go to the running react-frontend. In settings, theres a config option for websocket url. use wss://hostename.com/ws/ (instead of ws://hostname.com:3001).

@jerrywcy
Copy link

maybe try this one written by @101stArrow from Discord community?

version: '3.3'
services:
  dgraph-zero:
    ports:
      - '5080:5080'
      - '6080:6080'
    restart: unless-stopped
    image: ebdm/unigraph-dgraph
    command: dgraph zero --my=dgraph-zero:5080
  dgraph-alpha:
    ports:
      - '9080:9080'
      - '8080:8080'
    restart: unless-stopped
    image: ebdm/unigraph-dgraph
    command: dgraph alpha --my=dgraph-alpha:7080 --zero=dgraph-zero:5080 --whitelist="172.22.0.0/24"
networks:
  default:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: "172.22.0.0/24"
          gateway: "172.22.0.1"

@jerrywcy
Copy link

save to docker-compose.yml and simply docker compose up can set up dgraph but unigraph had to be manually configured

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants