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

feat: add Dockerfile for server & studio (0.10) #845

Merged
merged 10 commits into from
Nov 20, 2020

Conversation

imbajin
Copy link
Member

@imbajin imbajin commented Feb 1, 2020

Fix #1284 / Fix #840 / Fix #989 :

  1. Use rocksdb as the default storage engine
  2. Add hosts to speed up image build (comment by default)
  3. Modify some configs to enable the server to run better in container
  4. Because Dockerfile doesn't allow multiple startup commands, currently only the server will be automatically started after the container is started. If you want to start studio, enter the container to start it.

Here are some simple using commands:

# 0. download image
docker pull imbajin/hugegraph

# 1. start container
docker run -itd imbajin/hugegraph  # quick start

# (Optional configs)
docker run -itd --name=graph -p 18080:8080 -p 18088:8088 imbajin/hugegraph

# 2. (Optional) enter the container & start hugegraph-studio
docker exec -it graph /bin/bash
xxxx (start hugegraph studio by command)

TODOs:

  1. Build from the latest code instead of tar package.
  2. Support hubble studio
  3. Add & split studio/loader into separate images, use docker-compose to manage them.
  4. Maybe have better way to modify the configs to satisfied the container (like add a option for running in the foreground)

After the above completed, it can provides a one-click pure test environment for graph

@codecov

This comment was marked as outdated.

1. Add hosts to speed up image download
2. Modify some configs to enable the server to run better in container
3. Because Dockerfile doesn't allow multiple startup commands, currently only the server will be automatically started after the container is started. If you want to start studio, you can enter the container to start it.

Here is a simple container start command:
```bash
docker run -it --name=graph -p 18080:8080 -p 18088:8088 hugegraph:0.10 /bin/bash
```
Copy link
Contributor

@javeme javeme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job

Dockerfile Outdated
RUN set -e \
&& echo "192.30.253.112 github.com\n151.101.44.249 github.global.ssl.fastly.net" >> /etc/hosts \
&& mkdir -p /root/server \
&& curl -L -S ${PKG_URL}/hugegraph/releases/download/v0.10.4/hugegraph-0.10.4.tar.gz -o /root/server.tar.gz \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer to add an env var for version

&& tar xzf /root/server.tar.gz --strip-components 1 -C /root/server \
&& rm /root/server.tar.gz \
&& cd /root/server/ \
&& sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it be a real ip instead of 0.0.0.0

Dockerfile Outdated

# 2. Init HugeGraph Sever (speed up)
RUN set -e \
&& echo "192.30.253.112 github.com\n151.101.44.249 github.global.ssl.fastly.net" >> /etc/hosts \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the ip stable?

@@ -0,0 +1,46 @@
FROM ubuntu:xenial
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also support centos?

Copy link
Member Author

@imbajin imbajin Feb 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can only write a basically similar Dockerfile for CentOS. (Generally use Debian/Ubuntu)
Usually , I haven't seen the official image provide two types of Dockerfile,
Maybe we can see the opinions of other community users.

And here are some refers:

  1. Cassandra_Dockerfile
  2. Nginx_Dockerfile
  3. Other Official Dockerfile

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

Dockerfile Outdated
EXPOSE 8088
WORKDIR /root

ENTRYPOINT ["./server/bin/start-hugegraph.sh"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace server with hugegraph-server

&& sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties \
&& sed -n '63p' ./bin/start-hugegraph.sh | grep "&" > /dev/null && sed -i 63{s/\&$/#/g} ./bin/start-hugegraph.sh \
&& sed -n '74p' ./bin/start-hugegraph.sh | grep "exit" > /dev/null && sed -i 74{s/^/#/g} ./bin/start-hugegraph.sh \
&& ./bin/init-store.sh
Copy link
Contributor

@javeme javeme Feb 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a shell install-server.sh to improve readability?
some references found https://github.com/search?l=Dockerfile&p=99&q=RUN++install.sh&type=Code

Copy link
Member Author

@imbajin imbajin Feb 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need test it:
if there is a file named start.sh

echo "old msg"
  1. RUN start.sh
  2. RUN echo "old msg" && echo "new msg"

If we use a shell file to change the code, would dockerfile think this is a repeated step and skip the rebuild?

Dockerfile Outdated
RUN set -e \
&& echo "192.30.253.112 github.com\n151.101.44.249 github.global.ssl.fastly.net" >> /etc/hosts \
&& mkdir -p /root/studio \
&& curl -L -S ${PKG_URL}/hugegraph-studio/releases/download/v0.10.0/hugegraph-studio-0.10.0.tar.gz -o /root/studio.tar.gz \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems no studio tar when building server

Copy link
Contributor

@javeme javeme Feb 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may need to also trigger docker image building when studio release to resolve it.
and what is the behavior if studio tar don't exist: hugegraph-studio / releases / download / v0.10.0 / hugegraph-studio-0.10.0.tar.gz?

Dockerfile Outdated
lsof \
g++ \
gcc \
openjdk-8-jdk \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge the 11-15 lines, and align with apt-get

Dockerfile Outdated
# 3. Prepare for HugeGraph Studio
ENV STUDIO_VERSION 0.10.0
RUN set -e \
&& echo "192.30.253.112 github.com\n151.101.44.249 github.global.ssl.fastly.net" >> /etc/hosts \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it since added when building server

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each layer of docker image use a separate network layer.
So when leave current layer(step), other step cannot reuse it

And other ways are troublesome to solve it, like this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get it

Copy link
Contributor

@javeme javeme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Linary @zhoney please take a look

1. Github-IP is not fixed, comment it now
2. For the convenience of users, the apt-source is not cleared by default.
javeme
javeme previously approved these changes May 6, 2020
zhoney
zhoney previously approved these changes May 6, 2020
update auth default config in rest-server.properties
@imbajin imbajin dismissed stale reviews from zhoney and javeme via ea58576 May 19, 2020 13:57
@imbajin
Copy link
Member Author

imbajin commented May 19, 2020

Also update default values for auth for #706

@javeme
Copy link
Contributor

javeme commented May 20, 2020

Also update default values for auth for #706

There are indeed some errors, please update default value to ConfigAuthenticator:
auth.authenticator=com.baidu.hugegraph.auth.ConfigAuthenticator

@javeme
Copy link
Contributor

javeme commented May 20, 2020

@imbajin Can you split the commits not related to docker?

@imbajin
Copy link
Member Author

imbajin commented May 20, 2020

@imbajin Can you split the commits not related to docker?

OK, maybe it's better to update all the configuration files & shells separately later

@@ -42,7 +42,7 @@ cassandra.password=
# hbase backend config
#hbase.hosts=localhost
#hbase.port=2181
#hbase.znode_parent=/hbsae
#hbase.znode_parent=/hbase
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also move it to independent commit

@zhoney zhoney merged commit 67cfb6f into apache:master Nov 20, 2020
tmljob pushed a commit to tmljob/hugegraph that referenced this pull request Dec 10, 2020
1. Add hosts to speed up image download
2. Modify some configs to enable the server to run better in container
3. Because Dockerfile doesn't allow multiple startup commands, currently only the server will be automatically started after the container is started. If you want to start studio, you can enter the container to start it.

Here is a simple container start command:
```bash
docker run -it --name=graph -p 18080:8080 -p 18088:8088 hugegraph:0.10 /bin/bash
```

1. Github-IP is not fixed, comment it now
2. For the convenience of users, the apt-source is not cleared by default.
@imbajin imbajin changed the title Add Dockerfile for server & studio feat: add Dockerfile for server & studio (0.10) Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Support build docker image from Dockerfile (Task Summary) 盼docker运行的 dockerfile
4 participants