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

Add docker-compose #1666

Merged
merged 2 commits into from
Jul 12, 2024
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,9 @@ log/
*.log
*.history

# Ignore all docker-compose.yaml files created by users, except docker-compose.yaml
*docker-compose*.yaml
!docker-compose.yaml

# (TBD) .env file for docker-compose
#
101 changes: 101 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
version: "3.6"
services:
# CB-Spider
cb-spider:
image: cloudbaristaorg/cb-spider:0.9.0
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
image: cloudbaristaorg/cb-spider:0.9.0
image: cloudbaristaorg/cb-spider:${SP_TAG}

SP_TAG=0.9.0
SP_TAG=latest

환경변수로 지정할 수 있게하면 어떨까요?

Copy link
Member Author

@yunkon-kim yunkon-kim Jul 11, 2024

Choose a reason for hiding this comment

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

@seokho-son 말씀주신 의견에 대해 검토 의견을 말씀드립니다.

docker-compose.yaml은 container를 구동 및 연관 관계를 명시해 놓은 파일이라고 생각합니다.

예를 들어, docker-composel.yaml의 envrionment에는 container 구동에 필요한 환경 변수(Dockerfile에 명시된 환경 변수)를 명시하고 있습니다. 이를 환경 변수로 만들면 재차 환경변수를 뽑는 상황이 되는 것으로 보이고 가독성이 상당히 떨어지는 것 같습니다. (아래 적용 버전을 참고하시면 될 것 같습니다.)

그래서 API_USERNAME, API_PASSWORD, DB_USER, DB_PASSWROD 등과 같이 민감함 정보에 대해서만 .env에서 읽도록만들고, GitHub 상에 오픈되지 않도록 하는 방법이 좋겠습니다.

(docker-compose의 TB environment sample)

    environment:
      - CBTUMBLEBUG_ROOT=${TB_CBTUMBLEBUG_ROOT}
      - CBSTORE_ROOT=${TB_CBSTORE_ROOT}
      - CBLOG_ROOT=${TB_CBLOG_ROOT}
      - SPIDER_CALL_METHOD=${TB_SPIDER_CALL_METHOD}
      - SPIDER_REST_URL=${TB_SPIDER_REST_URL}
      # - DRAGONFLY_CALL_METHOD=${TB_RAGONFLY_CALL_METHOD}
      # - DRAGONFLY_REST_URL=${TB_DRAGONFLY_REST_URL}
      - DB_URL=${TB_DB_URL}
      - DB_DATABASE=${TB_DB_DATABASE}
      - DB_USER=${TB_DB_USER}
      - DB_PASSWORD=${TB_DB_PASSWORD}
      - ALLOW_ORIGINS=${TB_ALLOW_ORIGINS}
      - ENABLE_AUTH=${TB_ENABLE_AUTH}
      - API_USERNAME=${TB_API_USERNAME}
      - API_PASSWORD=${TB_API_PASSWORD}
      - AUTOCONTROL_DURATION_MS=${TB_AUTOCONTROL_DURATION_MS}
      - SELF_ENDPOINT=${TB_SELF_ENDPOINT}
      - API_DOC_PATH=${TB_API_DOC_PATH}
      - DEFAULT_NAMESPACE=${TB_DEFAULT_NAMESPACE}
      - DEFAULT_CREDENTIALHOLDER=${TB_DEFAULT_CREDENTIALHOLDER}
      - LOGFILE_PATH=${TB_LOGFILE_PATH}
      - LOGFILE_MAXSIZE=${TB_LOGFILE_MAXSIZE}
      - LOGFILE_MAXBACKUPS=${TB_LOGFILE_MAXBACKUPS}
      - LOGFILE_MAXAGE=${TB_LOGFILE_MAXAGE}
      - LOGFILE_COMPRESS=${TB_LOGFILE_COMPRESS}
      - LOGLEVEL=${TB_LOGLEVEL}
      - LOGWRITER=${TB_LOGWRITER}
      - NODE_ENV=${TB_NODE_ENV}

(.env sample)

# 'latest' indicates the most recent release tag (e.g., 0.9.0), 
# which is the stable version. `--force-recreate` option required when executing `docker-compose up` command.
TB_CONTAINER_TAG=latest 
TB_HOST_PORT_OF_REST=1323

TB_CBTUMBLEBUG_ROOT=/app
TB_CBSTORE_ROOT=/app \
TB_CBLOG_ROOT=/app \
TB_SPIDER_CALL_METHOD=REST
TB_SPIDER_REST_URL=http://cb-spider:1025/spider
# TB_RAGONFLY_CALL_METHOD=REST
# TB_DRAGONFLY_REST_URL=http://cb-dragonfly:9090/dragonfly
TB_DB_URL=localhost:3306 
TB_DB_DATABASE=cb_tumblebug 
TB_DB_USER=cb_tumblebug 
TB_DB_PASSWORD=cb_tumblebug 
TB_ALLOW_ORIGINS=*
TB_ENABLE_AUTH=true
TB_API_USERNAME=default
TB_API_PASSWORD=default
TB_AUTOCONTROL_DURATION_MS=10000
TB_SELF_ENDPOINT=localhost:1323
TB_API_DOC_PATH=/app/src/api/rest/docs/swagger.json
TB_DEFAULT_NAMESPACE=ns01
TB_DEFAULT_CREDENTIALHOLDER=admin
TB_LOGFILE_PATH=/app/log/tumblebug.log
TB_LOGFILE_MAXSIZE=10
TB_LOGFILE_MAXBACKUPS=3
TB_LOGFILE_MAXAGE=30
TB_LOGFILE_COMPRESS=false
TB_LOGLEVEL=debug
TB_LOGWRITER=both
TB_NODE_ENV=development

Copy link
Member Author

@yunkon-kim yunkon-kim Jul 12, 2024

Choose a reason for hiding this comment

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

@seokho-son

#1661 의 제안 취지에 부합하기 위해서,
이 부분에 대해서는 시간을 가지고 정리하는 편이 좋을 것 같습니다.

그래서, 이번 PR에서는 환경변수 관련 사항을 제외한 부분에 대해서 보완하고, 별도의 사안(PR)으로 환경변수 관련 사항을 다루고자 합니다.

관련하여 검토 및 의견을 부탁드립니다.

Copy link
Member

Choose a reason for hiding this comment

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

@yunkon-kim 넵 동의합니다. 현재도 대부분의 기능을 갖추고 있으니, PR 대략 정리되시면 알려주세요! :)

container_name: cb-spider
platform: linux/amd64
ports:
- target: 1024
published: 1024
protocol: tcp
volumes:
# - ./conf/log_conf.yaml:/root/go/src/github.com/cloud-barista/cb-spider/conf/log_conf.yaml
- ./conf/store_conf.yaml:/root/go/src/github.com/cloud-barista/cb-spider/conf/store_conf.yaml
- ./container-volume/cb-spider-container/meta_db/:/root/go/src/github.com/cloud-barista/cb-spider/meta_db/
- ./container-volume/cb-spider-container/log/:/root/go/src/github.com/cloud-barista/cb-spider/log/
environment:
- PLUGIN_SW=OFF
- SERVER_ADDRESS=localhost
# if you leave these values empty, REST Auth will be disabled.
# - API_USERNAME=
# - API_PASSWORD=
- SPIDER_LOG_LEVEL=error
- SPIDER_HISCALL_LOG_LEVEL=error
- ID_TRANSFORM_MODE=ON
healthcheck: # for CB-Spider
test: [ "CMD", "curl", "-f", "http://localhost:1024/spider/readyz" ]
interval: 1m
timeout: 5s
retries: 3
start_period: 10s
# CB-Tumblebug
cb-tumblebug:
image: cloudbaristaorg/cb-tumblebug:0.9.0
build:
context: .
dockerfile: Dockerfile
container_name: cb-tumblebug
platform: linux/amd64
ports:
- target: 1323
published: 1323
protocol: tcp
depends_on:
- cb-spider
volumes:
- ./conf/:/app/conf/
- ./container-volume/cb-tumblebug-container/meta_db/:/app/meta_db/
- ./container-volume/cb-tumblebug-container/log/:/app/log/
environment:
# - CBTUMBLEBUG_ROOT=/app
# - CBSTORE_ROOT=/app
# - CBLOG_ROOT=/app
# - SPIDER_CALL_METHOD=REST
- SPIDER_REST_URL=http://cb-spider:1024/spider
# - DRAGONFLY_CALL_METHOD=REST
- DRAGONFLY_REST_URL=http://cb-dragonfly:9090/dragonfly
# - DB_URL=localhost:3306
# - DB_DATABASE=cb_tumblebug
# - DB_USER=cb_tumblebug
# - DB_PASSWORD=cb_tumblebug
# - ALLOW_ORIGINS=*
# - ENABLE_AUTH=true
# - API_USERNAME=default
# - API_PASSWORD=default
# - AUTOCONTROL_DURATION_MS=10000
- SELF_ENDPOINT=localhost:1323
# - API_DOC_PATH=/app/src/api/rest/docs/swagger.json
# - DEFAULT_NAMESPACE=ns01
# - DEFAULT_CREDENTIALHOLDER=admin
# - LOGFILE_PATH=/app/log/tumblebug.log
# - LOGFILE_MAXSIZE=10
# - LOGFILE_MAXBACKUPS=3
# - LOGFILE_MAXAGE=30
# - LOGFILE_COMPRESS=false
# - LOGLEVEL=debug
# - LOGWRITER=both
# - NODE_ENV=development
healthcheck: # for CB-Tumblebug
test: [ "CMD", "curl", "-f", "http://localhost:1323/tumblebug/readyz" ]
interval: 1m
timeout: 5s
retries: 3
start_period: 10s

# cb-mapui
cb-mapui:
image: cloudbaristaorg/cb-mapui:0.9.0
container_name: cb-mapui
ports:
- target: 1324
published: 1324
protocol: tcp
# depends_on:
# - cb-tumblebug
healthcheck: # for cb-mapui
test: ["CMD", "nc", "-vz", "localhost", "1324"]
interval: 1m
timeout: 5s
retries: 3
start_period: 10s