Skip to content

Commit

Permalink
build: add dockerfile to build greptimedb container image (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyy17 authored Aug 22, 2022
1 parent 144ea34 commit 86dd19d
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/).
Expand All @@ -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
Expand All @@ -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/):
Expand Down
32 changes: 32 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]

0 comments on commit 86dd19d

Please sign in to comment.