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

Added Dockerfile and docker-compose #161

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ npm run build

Learn more from the Create React App [README](https://github.com/facebook/create-react-app#npm-run-build-or-yarn-build) and [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment).

## Docker ##
To run this on a system without `make` and `node` you can use Docker.
The provided `docker-compose.yml` file builds a Docker image from the latest master commit of the current repository, starts the server and exposes port 3000.

To use it:

```
git clone --depth 1 https://github.com/magjac/graphviz-visual-editor
cd graphviz-visual-editor
docker-compose up -d
```
## Implemented Features ##

* Rendering of a graph from a textual [DOT](https://www.graphviz.org/doc/info/lang.html) representation.
Expand Down
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "3"
services:
graphviz-editor:
build:
context: ./docker
dockerfile: Dockerfile
container_name: graphviz-editor
ports:
- "3000:3000"
restart: always
33 changes: 33 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Multi-stage build to reduce final image size
FROM node:lts-alpine3.15 as BUILD_IMAGE

# Install git and make
RUN apk update
RUN apk add git
RUN apk add make

# Clone graphviz visual editor
RUN git clone --depth 1 https://github.com/magjac/graphviz-visual-editor

WORKDIR /graphviz-visual-editor

# Install and make the dependencies
RUN npm install
RUN make
RUN npm run build

# Reduce the image size: remove development dependencies
RUN npm prune --production

# The stage that actually runs the application
FROM node:lts-alpine3.15

WORKDIR /graphviz-visual-editor

# Copy the built artifacts from the build image
COPY --from=BUILD_IMAGE /graphviz-visual-editor/build ./build
COPY --from=BUILD_IMAGE /graphviz-visual-editor/node_modules ./node_modules

RUN npm install -g serve

CMD ["serve", "-s", "build"]