-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add docker-compose #1666
Conversation
* Add docker-compose.yaml to provide a stable set of subsystems * Ignore all docker-compose files created by users, except docker-compose.yaml
앞으로, Tumblebug 사용자/기여자들께 docker-compose.yaml 복사, 수정 및 활용하는 것으로 가이드하면 좋을 것 같습니다. 이를 통해, scripts 디렉토리에서 관리되는 개별 컨테이너 구동 스크립트들을 Deprecated 하는 것도 고려해 보면 좋을 것 같습니다. 중복되는 메인테이닝 포인트를 줄이는 차원입니다. Deprecated 시점은 급할 필요는 없고요. v0.10.0 릴리스 이후가 좋을 것 같다는 개인 의견을 말씀드립니다. |
WoW! Thanks! I am working on the review. ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yunkon-kim 감사합니다! 여러가지 개선 의견들이 있습니다. 한번 살펴봐주세요.
docker-compose.yaml
Outdated
platform: linux/amd64 | ||
ports: | ||
- "1024:1024" | ||
- "2048:2048" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- "2048:2048" |
grpc 관련된 사항이라서 이제 필요없는 것 같습니다.
docker-compose.yaml
Outdated
timeout: 1s | ||
retries: 3 | ||
start_period: 5s | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
profiles: | |
- sp | |
env 파일로 dockercopomse up 시에 동작하는 컴포넌트를 조정할 수 있게 하면 어떨까요?
# .env 파일
COMPOSE_PROFILES=sp,tb,map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
COMPOSE_PROFILES=sp,map docker-compose up
이런식으로도 조작 가능
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
profiles을 사용해본 경험이 없어서 찾아봤는데요. 목적이 살짝 다른 것으로 보입니다.
Ref: https://docs.docker.com/compose/profiles/
말씀주신 내용은 아래와 같이 구동하면 될 것 같습니다. (이후 리뷰의견들을 반영 후 마지막에 테스트해보겠습니다.)
docker compose up -d [서비스명]
docker compose up -d cb-spider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yunkon-kim 음.. 넵!
docker compose up -d [서비스1명] [서비스2명]
로 해도 크게 다르지 않을 것 같네요. ^^
services: | ||
# CB-Spider | ||
cb-spider: | ||
image: cloudbaristaorg/cb-spider:0.9.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
image: cloudbaristaorg/cb-spider:0.9.0 | |
image: cloudbaristaorg/cb-spider:${SP_TAG} |
SP_TAG=0.9.0
SP_TAG=latest
환경변수로 지정할 수 있게하면 어떨까요?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#1661 의 제안 취지에 부합하기 위해서,
이 부분에 대해서는 시간을 가지고 정리하는 편이 좋을 것 같습니다.
그래서, 이번 PR에서는 환경변수 관련 사항을 제외한 부분에 대해서 보완하고, 별도의 사안(PR)으로 환경변수 관련 사항을 다루고자 합니다.
관련하여 검토 및 의견을 부탁드립니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yunkon-kim 넵 동의합니다. 현재도 대부분의 기능을 갖추고 있으니, PR 대략 정리되시면 알려주세요! :)
docker-compose.yaml
Outdated
- 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
마찬가지로 SP_XXX 형태로 외부 환경변수로 주입하면 좋지 않을까 싶습니다.
docker-compose.yaml
Outdated
- API_DOC_PATH=/app/src/api/rest/docs/swagger.json | ||
- DEFAULT_NAMESPACE=ns01 | ||
- DEFAULT_CREDENTIALHOLDER=admin | ||
- LOGFILE_PATH=$CBTUMBLEBUG_ROOT/log/tumblebug.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- LOGFILE_PATH=$CBTUMBLEBUG_ROOT/log/tumblebug.log | |
- LOGFILE_PATH=$CBTUMBLEBUG_ROOT/log/tumblebug.log |
$CBTUMBLEBUG_ROOT 는 의도하신 사항일까요?
docker-compose.yaml
Outdated
interval: 5s | ||
timeout: 1s | ||
retries: 3 | ||
start_period: 5s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interval: 5s | |
timeout: 1s | |
retries: 3 | |
start_period: 5s | |
interval: 60s | |
timeout: 5s | |
retries: 3 | |
start_period: 10s |
docker-compose.yaml
Outdated
depends_on: | ||
- cb-tumblebug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
depends_on: | |
- cb-tumblebug |
의존성 없이 동작 가능하므로, 의존성을 제외해도 좋을 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
의존성 없이 동작 될 수 있는 서비스가 맞습니다. 다만, docker-compose로 일괄 구동하는 것을 가정했을 때, Tumblebug이 떠 있지 않다면 정상적으로 구동되지 않을 것이라는 생각에 의존성 체크를 추가하였습니다.
혹시, docker compse up -d cb-mapui 처럼 개별 구동을 고려하시는 것일까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yunkon-kim 개별 구동에도 영향이 없도록 하는 제안이 맞습니다. 아무튼 의존성 없이 별개로 구동 가능하니까요. ^^ 실제 TB 연동 및 활용 가능여부는 MapUI 내부 로직에서 잘 처리해주고 있습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵! 해당 부분은 주석 처리해 놓겠습니다.
.gitignore
Outdated
@@ -62,3 +62,6 @@ log/ | |||
*.log | |||
*.history | |||
|
|||
# Ignore all docker-compose files created by users, except docker-compose.yaml | |||
*docker-compose*.yaml | |||
!docker-compose.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docker-compose.env
같은걸 추가해서, 사용자용 env 구성을 지원하면 좋을 것 같네요. :)
아래와 같은 구분자로, 각 ENV 들을 구분 및 활용하면 어떨까 싶습니다.
TB_XXXX
SP_XXXX
MAP_XXX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
helm 스타일을 차용해서 ignore를 아래와 같은 스타일로 적용해보겠습니다 ^^
*docker-compose*.yaml
!docker-compose.yaml
*value*.env
!value.env
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
파일명으로 .env
는 어떨까요? 많이 사용하는 방식이라고는 하는데.. 음..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코멘트 주신 내용이 일반적인 .env
과는 다르다고 느껴져 위와 같이 제안 드렸던 부분입니다.
다른 방법을 찾아보도록 하겠습니다.
docker-compose.yaml
Outdated
# build: | ||
# context: . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# build: | |
# context: . | |
build: | |
context: . |
docker-compose up --build 했을때, 공용 컨테이너 이미지가 아니라, 현재 소스기준으로 컨테이너 구동하게 하려고 하셨던거죠?
활성화하면 매우 유용할 것 같습니다.
docker-compose.yaml
Outdated
container_name: cb-spider | ||
platform: linux/amd64 | ||
ports: | ||
- "1024:1024" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- "1024:1024" | |
- "${SP_HOST_PORT}:1024" |
컨테이너 컴포넌트의 호스트 포트를 환경변수로 제공하면 좋을 것 같습니다.
* Update ports configuration * Update healthcheck configuration * Update environment configuration * Add build configuration for cb-tumblebug service
아래와 같이 업데이트하여 공유드립니다.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!!!!!!!!!!!! :)
Tumblebug users/contributors can make and use their copies from docker-compose.yaml.
(e.g,.
docker-compose -f my-docker-compose.yaml up
,docker-compose -f docker-compose2.yaml up
, and so on)docker-compose.yaml has been tested on the following environment.
Test completed
Please review the changes in this pull request :-)
Close #1661