Skip to content

Commit

Permalink
chore: fix image build (apache#232)
Browse files Browse the repository at this point in the history
* fix image build

* add latest tag

* add cleanup

* minimal bind to 0.0.0.0
  • Loading branch information
jiacai2050 authored Sep 5, 2022
1 parent 5590c95 commit 7e9d675
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 21 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
target
docs
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ on:
- '.github/**'
- '**.md'
- '**.yml'
- '.dockerignore'
- 'docker/**'
pull_request:
branches:
- main
Expand All @@ -22,6 +24,8 @@ on:
- '.github/**'
- '**.md'
- '**.yml'
- '.dockerignore'
- 'docker/**'

# Common environment variables
env:
Expand Down
26 changes: 15 additions & 11 deletions .github/workflows/docker-build-image.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Test Docker image build

on:
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/docker-build-image.yml'
Expand All @@ -15,6 +16,8 @@ on:
env:
CERESDB_ADDR: 127.0.0.1
CERESDB_PORT: 5440
IMAGE_NAME: ceresdb-server:latest
SERVER_NAME: standalone-server

jobs:
docker:
Expand All @@ -23,16 +26,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
- name: Build Docker image
run: docker build -t ceresdb-server .
run: docker build -t ${IMAGE_NAME} .
- name: Test the Built Image
run: >-
docker run -p ${CERESDB_ADDR}:${CERESDB_PORT}:${CERESDB_PORT} -d ceresdb-server &&
sleep 10 &&
bash ./docker/basic.sh &&
docker rm -f ceresdb-server
run: |
docker run --name ${SERVER_NAME} -p ${CERESDB_ADDR}:${CERESDB_PORT}:${CERESDB_PORT} -d ${IMAGE_NAME}
sleep 10
bash ./docker/basic.sh
docker rm -f ${SERVER_NAME}
- name: Test the Built Image With Config
run: >-
docker run -p ${CERESDB_ADDR}:${CERESDB_PORT}:${CERESDB_PORT} -v `pwd`/docs/minimal.toml:/etc/ceresdb/ceresdb.toml -d ceresdb-server &&
sleep 10 &&
bash ./docker/basic.sh &&
docker rm -f ceresdb-server
run: |
docker run --name ${SERVER_NAME} -p ${CERESDB_ADDR}:${CERESDB_PORT}:${CERESDB_PORT} \
-v `pwd`/docs/minimal.toml:/etc/ceresdb/ceresdb.toml -d ${IMAGE_NAME}
sleep 10
bash ./docker/basic.sh
docker rm -f ${SERVER_NAME}
1 change: 1 addition & 0 deletions .github/workflows/dockerhub-description.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Update Docker Hub Description

on:
push:
branches:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/dockerhub-publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build Docker Image and Push to Docker Hub on Tags
name: Publish Docker image

on:
workflow_dispatch:
push:
tags:
- 'v*'
Expand All @@ -24,4 +25,4 @@ jobs:
with:
context: .
push: true
tags: ceresdb/ceresdb-server:${{github.ref_name}}
tags: ceresdb/ceresdb-server:latest,ceresdb/ceresdb-server:${{github.ref_name}}
10 changes: 10 additions & 0 deletions docker/basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

set -exo pipefail

trap cleanup EXIT

cleanup() {
exit_code=$?
# cat server log when script failed
if [[ ${exit_code} -ne 0 ]]; then
docker logs -n 200 ${SERVER_NAME}
fi
}

ADDR=${CERESDB_ADDR:-"127.0.0.1"}
PORT=${CERESDB_PORT:-"5440"}

Expand Down
10 changes: 4 additions & 6 deletions docs/dockerhub-description.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,26 @@ docker run -d --name ceresdb-server \
-p 8831:8831 \
-p 3307:3307 \
-p 5440:5440 \
ceresdb/ceresdb-server:v0.2.0
ceresdb/ceresdb-server:$(version)
```

CeresDB will listen three ports when start:
- 8831, gRPC port
- 3307, MySQL port
- 5440, HTTP port

There are some files used by server inside Docker image, the following two are most important:
- `/home/admin/logs/ceresdb/out.log`, log
There are some files used by server inside Docker image, the following one is the most important:
- `/etc/ceresdb/ceresdb.toml`, config

You overwrite those files with this command:
You overwrite config with this command:

```bash
docker run -d --name ceresdb-server \
-p 8831:8831 \
-p 3307:3307 \
-p 5440:5440 \
-v $(path/to/log):/home/admin/logs/ceresdb/out.log \
-v $(path/to/config):/etc/ceresdb/ceresdb.toml \
ceresdb/ceresdb-server:v0.2.0
ceresdb/ceresdb-server:$(version)
```

# Documentation
Expand Down
2 changes: 1 addition & 1 deletion docs/minimal.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bind_addr = "127.0.0.1"
bind_addr = "0.0.0.0"
http_port = 5440
grpc_port = 8831
log_level = "info"
Expand Down

0 comments on commit 7e9d675

Please sign in to comment.