Skip to content

Commit d6d10af

Browse files
author
ba-tno
committed
Update README with docker instructions. Reduce docker image size. Removed trailing whitespaces
1 parent 8faad7f commit d6d10af

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ npm run build
2727

2828
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).
2929

30+
## Docker ##
31+
To run this on a system without `make` and `node` you can use Docker.
32+
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.
33+
34+
To use it:
35+
36+
```
37+
git clone --depth 1 https://github.com/magjac/graphviz-visual-editor
38+
cd graphviz-visual-editor
39+
docker-compose up -d
40+
```
3041
## Implemented Features ##
3142

3243
* Rendering of a graph from a textual [DOT](https://www.graphviz.org/doc/info/lang.html) representation.

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
version: "3.8"
1+
version: "3"
22
services:
33
graphviz-editor:
44
build:
55
context: ./docker
66
dockerfile: Dockerfile
77
container_name: graphviz-editor
88
ports:
9-
- "5000:5000"
10-
restart: always
9+
- "3000:3000"
10+
restart: always

docker/Dockerfile

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,33 @@
1-
FROM node:15.14.0-buster-slim
1+
# Multi-stage build to reduce final image size
2+
FROM node:lts-alpine3.15 as BUILD_IMAGE
23

3-
# Install git and install make
4-
RUN apt update
5-
RUN apt install git -y
6-
RUN apt install make -y
4+
# Install git and make
5+
RUN apk update
6+
RUN apk add git
7+
RUN apk add make
78

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

1112
WORKDIR /graphviz-visual-editor
1213

14+
# Install and make the dependencies
1315
RUN npm install
1416
RUN make
1517
RUN npm run build
18+
19+
# Reduce the image size: remove development dependencies
20+
RUN npm prune --production
21+
22+
# The stage that actually runs the application
23+
FROM node:lts-alpine3.15
24+
25+
WORKDIR /graphviz-visual-editor
26+
27+
# Copy the built artifacts from the build image
28+
COPY --from=BUILD_IMAGE /graphviz-visual-editor/build ./build
29+
COPY --from=BUILD_IMAGE /graphviz-visual-editor/node_modules ./node_modules
30+
1631
RUN npm install -g serve
1732

18-
CMD ["serve", "-s", "build"]
33+
CMD ["serve", "-s", "build"]

0 commit comments

Comments
 (0)