From 86dd19dcc85f7243ea0c631b621f5b33a022e355 Mon Sep 17 00:00:00 2001 From: Yong Date: Mon, 22 Aug 2022 12:20:20 +0800 Subject: [PATCH] build: add dockerfile to build greptimedb container image (#194) --- .dockerignore | 25 +++++++++++++++++++++++++ README.md | 18 ++++++++++++++++++ docker/Dockerfile | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 .dockerignore create mode 100644 docker/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000000..415d03e0bc3b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,25 @@ +# macOS trash +.DS_Store + +# Visual Studio Code +.vscode/ +.devcontainer/ + +# Eclipse files +.classpath +.project +.settings/** + +# Vim swap files +*.swp + +# Files generated by JetBrains IDEs, e.g. IntelliJ IDEA +.idea/ +*.iml +out/ + +# Rust +target/ + +# Git +.git diff --git a/README.md b/README.md index e59ff811d3d2..73eb5fdd929c 100644 --- a/README.md +++ b/README.md @@ -7,15 +7,18 @@ GreptimeDB: the next-generation hybrid timeseries/analytics processing database ## Getting Started ### Prerequisites + To compile GreptimeDB from source, you'll need the following: - Rust - Protobuf - OpenSSL #### Rust + The easiest way to install Rust is to use [`rustup`](https://rustup.rs/), which will check our `rust-toolchain` file and install correct Rust version for you. #### Protobuf + `protoc` is required for compiling `.proto` files. `protobuf` is available from major package manager on macos and linux distributions. You can find an installation instructions [here](https://grpc.io/docs/protoc-installation/). @@ -37,6 +40,12 @@ For macOS: brew install openssl ``` +### Build the Docker Image + +``` +docker build --network host -f docker/Dockerfile -t greptimedb . +``` + ## Usage ### Start Datanode @@ -62,6 +71,15 @@ Start datanode with config file: cargo run -- --log-dir=logs --log-level=debug datanode start -c ./config/datanode.example.toml ``` +Start datanode by runing docker container: + +``` +docker run -p 3000:3000 \ +-p 3001:3001 \ +-p 3306:3306 \ +greptimedb +``` + ### SQL Operations 1. Connecting DB by [mysql client](https://dev.mysql.com/downloads/mysql/): diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000000..3a02c1195d48 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,32 @@ +FROM ubuntu:22.04 as builder + +ENV LANG en_US.utf8 +WORKDIR /greptimedb + +# Install dependencies. +RUN apt-get update && apt-get install -y \ + libssl-dev \ + protobuf-compiler \ + curl \ + build-essential \ + pkg-config + +# Install Rust. +SHELL ["/bin/bash", "-c"] +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --no-modify-path --default-toolchain none -y +ENV PATH /root/.cargo/bin/:$PATH + +# Build the project in release mode. +COPY . . +RUN cargo build --release + +# Export the binary to the clean image. +# TODO(zyy17): Maybe should use the more secure container image. +FROM ubuntu:22.04 as base + +WORKDIR /greptimedb +COPY --from=builder /greptimedb/target/release/greptime /greptimedb/bin/ +ENV PATH /greptimedb/bin/:$PATH + +ENTRYPOINT [ "greptime" ] +CMD [ "datanode", "start"]