Skip to content

Commit

Permalink
Add customizable & optional parameter: ES_HEAP_SIZE
Browse files Browse the repository at this point in the history
  • Loading branch information
remoteeng00 committed Jul 19, 2022
1 parent 83ace19 commit 600a9b3
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export AWS_SECRET_KEY=
export BIOTHINGS_REPOSITORY=https://github.com/biothings/biothings.api.git
export BIOTHINGS_VERSION=master
export PYTHON_VERSION=
export ES_HEAP_SIZE=
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ ADD ansible_playbook /tmp/ansible_playbook
ADD inventory /etc/ansible/hosts

COPY --from=build-webapp --chown=root:www-data /build/src/github.com/biothings/biothings_studio/webapp/dist /srv/www/webapp
ARG ES_HEAP_SIZE

WORKDIR /tmp/ansible_playbook
RUN if [ -n "$API_NAME" ]; \
Expand All @@ -240,12 +241,14 @@ RUN if [ -n "$API_NAME" ]; \
-e "studio_version=$STUDIO_VERSION" \
-e "api_name=$API_NAME" \
-e "api_version=$API_VERSION" \
-e "es_heap_size=$ES_HEAP_SIZE" \
-c local; \
else \
ansible-playbook biothings_studio.yml \
-e "biothings_version=$BIOTHINGS_VERSION" \
-e "biothings_repository=$BIOTHINGS_REPOSITORY" \
-e "studio_version=$STUDIO_VERSION" \
-e "es_heap_size=$ES_HEAP_SIZE" \
-c local; \
fi

Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ BIOTHINGS_VERSION ?= master
BIOTHINGS_REPOSITORY ?= https://github.com/biothings/biothings.api.git
DOCKER_BUILD_EXTRA_OPTS ?= --force-rm
PYTHON_VERSION ?=
ES_HEAP_SIZE ?=

biothings-studio:
docker build $(DOCKER_BUILD_EXTRA_OPTS) \
--build-arg STUDIO_VERSION=$(STUDIO_VERSION) \
--build-arg BIOTHINGS_REPOSITORY=$(BIOTHINGS_REPOSITORY) \
--build-arg BIOTHINGS_VERSION=$(BIOTHINGS_VERSION) \
--build-arg PROD=1 \
-t biothings-studio:$$(git branch | grep ^\* | sed "s#\* ##") .
Expand Down Expand Up @@ -76,6 +76,7 @@ demohub:
--build-arg STUDIO_VERSION=$(STUDIO_VERSION) \
--build-arg BIOTHINGS_VERSION=$(BIOTHINGS_VERSION) \
--build-arg BIOTHINGS_REPOSITORY=$(BIOTHINGS_REPOSITORY) \
--build-arg ES_HEAP_SIZE=512m \
--build-arg API_VERSION=master \
--build-arg TEST=1 \
--build-arg AWS_ACCESS_KEY=$(AWS_ACCESS_KEY) \
Expand All @@ -87,6 +88,7 @@ demohub-test:
--build-arg STUDIO_VERSION=$(STUDIO_VERSION) \
--build-arg BIOTHINGS_VERSION=$(BIOTHINGS_VERSION) \
--build-arg BIOTHINGS_REPOSITORY=$(BIOTHINGS_REPOSITORY) \
--build-arg ES_HEAP_SIZE=512m \
--build-arg API_VERSION=master \
--build-arg TEST=1 \
--build-arg PYTHON_VERSION=$(PYTHON_VERSION) \
Expand Down
21 changes: 14 additions & 7 deletions ansible_playbook/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@
- name: mongodb data directory
file: path="{{ software.common_configurations.mongodb.dbpath }}" state=directory owner=mongodb group=mongodb

#- debug: var=software.web_node

- name: biothings (override requirement_web.txt version)
git: repo={{ biothings_repository }} dest=/home/biothings/biothings.api version={{ software.web_node.biothings_git_version }}
git: repo={{ software.web_node.biothings_repository }} dest=/home/biothings/biothings.api version={{ software.web_node.biothings_git_version }}
become_user: "biothings"
become: true

Expand Down Expand Up @@ -177,9 +179,14 @@
- {"line": "", "re": "^cluster.initial_master_nodes.*$"}
- {"line": "xpack.security.enabled: false", "re": "^xpack.security.enabled.*$"}

- name: update /etc/elasticsearch/jvm.options again replacing min/max heap size
replace: dest=/etc/elasticsearch/jvm.options replace="{{ item.line }}" regexp="{{ item.re }}"
become: yes
with_items:
- {"line": "-Xms1g", "re": "^## -Xms4g$"}
- {"line": "-Xmx1g", "re": "^## -Xmx4g$"}

- name: Update /etc/elasticsearch/jvm.options.d/heap.options again replacing min/max heap size
when: software.web_node.elasticsearch.heap_size != ''
shell:
cmd: |
cat > /etc/elasticsearch/jvm.options.d/heap.options << EOF
-Xms{{ software.web_node.elasticsearch.heap_size }}
-Xmx{{ software.web_node.elasticsearch.heap_size }}
EOF
args:
executable: /bin/sh
4 changes: 2 additions & 2 deletions ansible_playbook/vars/biothings_studio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ software:
plugin:
head: "mobz/elasticsearch-head"
bigdesk: "lukas-vlcek/bigdesk"
heap_size: "2g"
heap_size: "{{ es_heap_size | default('')}}"
node_roles: ['data', 'master']
biothings_repository: "{{ biothings_repository | default('https://github.com/biothings/biothings.api.git') }}"
biothings_repository: "{{ biothings_repository | default('https://github.com/biothings/biothings.api.git', true) }}"
studio_git_version: "{{ studio_version | default('master')}}"
biothings_git_version: "{{ biothings_version | default('master')}}"
common_configurations:
Expand Down

0 comments on commit 600a9b3

Please sign in to comment.