Skip to content

Commit

Permalink
feat(unigraph): improve user experience with Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
thesophiaxu committed Apr 4, 2022
1 parent 5d9525c commit 487a11e
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 1 deletion.
28 changes: 28 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.git
# System files
.DS_Store

# Logs
*.log
npm-debug.log*

# Directories
node_modules
*/node_modules
packages/*/dist
.ignore
coverage/
.history

# Secrets
secrets.env.json

# Etc
packages/unigraph-dev-backend/exports.json

# Obsidian for docs
docs/.obsidian/workspace
docs/.obsidian/plugins

# Linting
.eslintcache
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# syntax=docker/dockerfile:1
FROM amd64/ubuntu:20.04

# Set up dependencies
RUN apt update && apt install -y curl wget

# Set up Node.js 16
RUN curl -sL https://deb.nodesource.com/setup_16.x -o /tmp/nodesource_setup.sh
RUN bash /tmp/nodesource_setup.sh
RUN apt update && apt install -y nodejs
RUN npm install yarn -g

# Set up dgraph
ADD https://github.com/unigraph-dev/dgraph/releases/latest/download/dgraph_linux_amd64 dgraph_linux_amd64
RUN mkdir /opt/unigraph
RUN mv dgraph_linux_amd64 /opt/dgraph
RUN chmod +x /opt/dgraph

# Set up unigraph, with incremental caches
COPY package.json yarn.lock /app/
COPY ./packages/unigraph-dev-backend/package.json /app/packages/unigraph-dev-backend/package.json
COPY ./packages/unigraph-dev-common/package.json /app/packages/unigraph-dev-common/package.json
COPY ./packages/unigraph-dev-electron/package.json /app/packages/unigraph-dev-electron/package.json
COPY ./packages/unigraph-dev-explorer/package.json /app/packages/unigraph-dev-explorer/package.json
RUN cd /app && yarn
COPY . /app
RUN cd /app && yarn
RUN cd /app && yarn build-deps

# Run Unigraph
WORKDIR /app
CMD ["sh", "-c", "./scripts/start_server.sh -b /opt/dgraph -d /opt/unigraph & yarn explorer-start"]

EXPOSE 3000
EXPOSE 4001
EXPOSE 4002
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ License:

## Getting started

### Running with Docker image

We provide an experimental Dockerfile for easy setup:

- Building Unigraph: `docker build -t unigraph-devserver.` (this should take roughly 10 minutes max),
- Running Unigraph: `docker run -d -p 4002:4002 -v <data directory>:/opt/unigraph -p 4001:4001 -p 3000:3000 -P unigraph-devserver`,

To update the Docker image, run `docker build` again after `git pull`.

### Building from source

**1)** Build the [`Dgraph`](https://github.com/unigraph-dev/dgraph) backend binary from source [[reference](https://github.com/unigraph-dev/dgraph#install-from-source)]

> requires `gcc`, `make`, `go>=1.13`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"scripts": {
"postinstall": "run-script-os",
"postinstall:linux:darwin": "(mkdir packages/unigraph-dev-explorer/public/vendor/ || true) && cp -R ./node_modules/monaco-editor/min/vs packages/unigraph-dev-explorer/public/vendor/monaco-editor_at_0.31.1/",
"postinstall:linux:darwin": "(mkdir packages/unigraph-dev-explorer/public/vendor/ || true) && (cp -R ./node_modules/monaco-editor/min/vs packages/unigraph-dev-explorer/public/vendor/monaco-editor_at_0.31.1/ || true)",
"postinstall:windows": "pwsh -Command \"mkdir -Force packages/unigraph-dev-explorer/public/vendor/ && Copy-Item ./node_modules/monaco-editor/min/vs -Destination packages/unigraph-dev-explorer/public/vendor/monaco-editor_at_0.31.1/ -Recurse -Force\"",
"backend-build": "yarn workspace unigraph-dev-backend build",
"backend-start": "yarn workspace unigraph-dev-backend start",
Expand Down
1 change: 1 addition & 0 deletions scripts/start_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fi

par=$( cd $(dirname $0) ; pwd -P )

eval 'mkdir $data || true'
eval 'cd $data && $dgraph alpha &'
eval 'cd $data && $dgraph zero &'
sleep 10
Expand Down

0 comments on commit 487a11e

Please sign in to comment.