Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ tags
# queries
*.sql
*.sh
!docker-entrypoint.sh

# modules
node_modules
Expand Down
91 changes: 75 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,79 @@
FROM lsvih/gcc-cmake-boost:v1
RUN apt -qqy update \
&& apt install -qqy --no-install-recommends \
libssl-dev libcurl4-openssl-dev libreadline-dev uuid-dev \
&& ldconfig -v \
&& echo "* - nofile 65535" >> /etc/security/limits.conf \
&& echo "* - noproc 65535" >> /etc/security/limits.conf
# SPDX-License-Identifier: BSD-3-Clause

FROM debian:buster-slim AS builder

LABEL vendor="pkumod"
LABEL description="gStore RDF Database Engine"

# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
libboost-regex-dev \
libboost-system-dev \
libboost-thread-dev \
libboost-system-dev \
curl \
libcurl4 \
libcurl4-openssl-dev \
libssl-dev \
libzmq3-dev \
pkg-config \
wget \
zlib1g-dev \
uuid-dev \
libjemalloc-dev \
libreadline-dev

RUN mkdir -p /src

COPY . /usr/src/gstore
WORKDIR /usr/src/gstore

ENV LANG C.UTF-8
# Compile gStore dependencies
COPY tools/ /usr/src/gstore/tools

COPY makefile /usr/src/gstore/

RUN mkdir -p lib && make pre

# Copy gStore source code; run `make tarball` to generate this file
ADD gstore.tar.gz /usr/src/gstore

RUN make

FROM debian:buster-slim AS runtime

RUN apt-get update && apt-get install -y \
libboost-regex1.67.0 \
libboost-system1.67.0 \
libboost-thread1.67.0 \
libcurl4 \
libssl1.1 \
libzmq5 \
uuid-runtime \
libjemalloc2 \
libreadline7 \
libopenmpi3 \
coreutils \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /usr/src/gstore/bin/ /usr/local/bin/

COPY --from=builder /usr/src/gstore/lib/ /docker-init/lib/

COPY backup.json init.conf conf.ini ipAllow.config ipDeny.config slog.properties slog.stdout.properties \
/docker-init/
COPY data/ /docker-init/data/
COPY docker-entrypoint.sh /

WORKDIR /app/
VOLUME [ "/app/" ]

RUN echo "* - nofile 65535" >> /etc/security/limits.conf \
&& echo "* - noproc 65535" >> /etc/security/limits.conf

EXPOSE 9000

ENTRYPOINT [ "sh", "/docker-entrypoint.sh" ]

RUN make pre -j && make -j FIRST_BUILD=y \
&& apt autoclean && apt clean \
&& rm -rf /usr/src/gstore/.git \
&& rm -rf /usr/src/gstore/tools \
&& rm -rf /tmp/* /var/tmp/* \
&& rm -rf /usr/share/doc/* \
&& rm -rf /var/lib/apt/lists/*
CMD [ "/usr/local/bin/ghttp" ]
45 changes: 45 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m'

if [ ! -f /app/init.conf ]; then
echo "${BLUE}[INIT] No init.conf file found. Copying default...${NC}"
cp -r /docker-init/* /app/

# Check if GSTORE_ROOT_PASSWORD is set
if [ -z "$GSTORE_ROOT_PASSWORD" ]; then
echo "${RED}[INIT] GSTORE_ROOT_PASSWORD is not set. We strongly recommend setting a strong password.${NC}"
else
echo "${BLUE}[INIT] Setting root password...${NC}"
# Replace the line in the file
sed -i -e "s/^#\\?\\s*root_password=.*/root_password=${GSTORE_ROOT_PASSWORD}/" init.conf
fi

fi

if [ ! -d /app/bin ]; then
echo "${BLUE}[INIT] Creating directories...${NC}"
mkdir -p bin lib backups data logs .tmp
fi

if [ ! -d /app/system.db ]; then
echo "${BLUE}[INIT] Creating system.db...${NC}"
/usr/local/bin/ginit --make

# list all directories in /app/data
for dir in /app/data/*; do
# get the directory name
dir_name=$(basename "$dir")
if [ $dir_name != "system" ] && [ -d "data/$dir_name" ] && [ -f "data/$dir_name/$dir_name.nt" ] ; then
# create the database
echo "${BLUE}[INIT] Creating $dir_name...${NC}"
/usr/local/bin/gbuild -db "$dir_name" -f "data/$dir_name/$dir_name.nt"
fi
done
fi

echo "${BLUE}[INIT] Command: $@${NC}"

exec "$@"
22 changes: 22 additions & 0 deletions docs/DOCKER_DEPLOY_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,28 @@ After having the correct Docker environment and network, use `git clone` to down

After the building, using `docker run -p 9000:80 -it gstore` directly to start and enter the container and execute other operations.

### Playground Mode

The docker image has been built with some sample data. You can run the following command to start the container in playground mode:

```bash
docker run --rm -it gstore sh -c "(/usr/local/bin/ghttp &); bash"
```

Press Enter to start the bash shell. Then you can play with the sample data in the container.

```bash
gquery -db small -q data/small/small_q0.sql
```

### Server Mode

Expose the port 9000, persist the data and run the container in background:

```bash
docker run -d -p 9000:9000 -v /path/to/data:/app gstore
```

## 0x02. pulling the mirror directly to run

Instead of downloading project or building on your own, input `docker pull pkumodlab/gstore:latest` to pull the mirror which has been automatically built well on the docker hub. Then input `docker run -p 9000:80 -it pkumodlab/gstore:latest` to start and enter the container and execute other operations.
Expand Down
9 changes: 5 additions & 4 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -745,10 +745,11 @@ dist: clean
rm -rf backups/*.db

tarball:
tar -czvf gstore.tar.gz api backups bin lib tools .debug .tmp .objs scripts docs data logs \
Main Database KVstore Util Query Signature VSTree Parser Server README.md init.conf conf.ini StringIndex COVERAGE \
Dockerfile LICENSE makefile Trie

tar -czvf gstore.tar.gz api backups bin lib tools .debug .tmp .objs scripts data logs \
Main Database KVstore Util Query Signature Parser Server StringIndex Trie GRPC COVERAGE \
makefile init.conf conf.ini backup.json ipAllow.config ipDeny.config slog.properties slog.stdout.properties \
README.md LICENSE

APIexample: $(api_cpp) $(api_socket)
$(MAKE) -C api/http/cpp/example
$(MAKE) -C api/socket/cpp/example
Expand Down