mirror of
https://github.com/ChristianLight/tutor.git
synced 2025-02-12 06:08:26 +00:00
Make forum container available even when services are missing
This is especially useful on Kubernetes. With this change, the forum container no longer crashes whenever mongodb or elasticsearch are unavailable. Instead, it just waits for thoses services to be up. Previously, we could not run forum migrations in Kubernetes because they relied on exec-ing the migration command in the running container -- and there was no such container, because the services where not already up.
This commit is contained in:
parent
02a7bd5cbc
commit
d012a7cfaf
@ -7,8 +7,14 @@ RUN apt update && \
|
||||
apt upgrade -y && \
|
||||
apt install -y git wget autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev
|
||||
|
||||
# Install dockerize to wait for mongodb/elasticsearch availability
|
||||
ARG DOCKERIZE_VERSION=v0.6.1
|
||||
RUN wget -O /tmp/dockerize.tar.gz https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
|
||||
&& tar -C /usr/local/bin -xzvf /tmp/dockerize.tar.gz \
|
||||
&& rm /tmp/dockerize.tar.gz
|
||||
|
||||
# Install ruby-build for building specific version of ruby
|
||||
RUN git clone https://github.com/sstephenson/ruby-build.git /openedx/ruby-build
|
||||
RUN git clone https://github.com/rbenv/ruby-build.git /openedx/ruby-build
|
||||
WORKDIR /openedx/ruby-build
|
||||
RUN PREFIX=/usr/local ./install.sh
|
||||
|
||||
@ -28,10 +34,17 @@ RUN git clone https://github.com/edx/cs_comments_service.git --branch open-relea
|
||||
WORKDIR /openedx/cs_comments_service
|
||||
RUN bundle install --deployment
|
||||
|
||||
COPY ./bin /openedx/bin
|
||||
ENV PATH /openedx/bin:${PATH}
|
||||
ENTRYPOINT ["docker-entrypoint.sh"]
|
||||
|
||||
ENV RACK_ENV staging
|
||||
ENV NEW_RELIC_ENABLE false
|
||||
ENV API_KEY forumapikey
|
||||
ENV SEARCH_SERVER "http://elasticsearch:9200"
|
||||
ENV MONGOHQ_URL "mongodb://mongodb/cs_comments_service"
|
||||
ENV MONGODB_AUTH ""
|
||||
ENV MONGODB_HOST "mongodb"
|
||||
ENV MONGODB_PORT "27017"
|
||||
ENV MONGOHQ_URL "mongodb://$MONGODB_AUTH$MONGODB_HOST:$MONGODB_PORT/cs_comments_service"
|
||||
EXPOSE 4567
|
||||
CMD ./bin/unicorn -c config/unicorn_tcp.rb -I '.'
|
||||
|
6
tutor/templates/build/forum/bin/docker-entrypoint.sh
Executable file
6
tutor/templates/build/forum/bin/docker-entrypoint.sh
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
echo "Waiting for mongodb/elasticsearch..."
|
||||
dockerize -wait tcp://$MONGODB_HOST:$MONGODB_PORT -wait $SEARCH_SERVER/content -wait-retry-interval 5s -timeout 600s
|
||||
|
||||
exec "$@"
|
@ -69,8 +69,12 @@ spec:
|
||||
env:
|
||||
- name: SEARCH_SERVER
|
||||
value: "http://{{ ELASTICSEARCH_HOST }}:{{ ELASTICSEARCH_PORT }}"
|
||||
- name: MONGOHQ_URL
|
||||
value: "mongodb://{% if MONGODB_USERNAME and MONGODB_PASSWORD %}{{ MONGODB_USERNAME}}:{{ MONGODB_PASSWORD }}@{% endif %}{{ MONGODB_HOST }}:{{ MONGODB_PORT }}/cs_comments_service"
|
||||
- name: MONGODB_AUTH
|
||||
value: "{% if MONGODB_USERNAME and MONGODB_PASSWORD %}{{ MONGODB_USERNAME}}:{{ MONGODB_PASSWORD }}@{% endif %}"
|
||||
- name: MONGODB_HOST
|
||||
value: "{{ MONGODB_HOST }}"
|
||||
- name: MONGODB_PORT
|
||||
value: "{{ MONGODB_PORT }}"
|
||||
{% endif %}
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
|
@ -95,7 +95,9 @@ services:
|
||||
image: {{ DOCKER_REGISTRY }}{{ DOCKER_IMAGE_FORUM }}
|
||||
environment:
|
||||
SEARCH_SERVER: "http://{{ ELASTICSEARCH_HOST }}:{{ ELASTICSEARCH_PORT }}"
|
||||
MONGOHQ_URL: "mongodb://{% if MONGODB_USERNAME and MONGODB_PASSWORD %}{{ MONGODB_USERNAME}}:{{ MONGODB_PASSWORD }}@{% endif %}{{ MONGODB_HOST }}:{{ MONGODB_PORT }}/cs_comments_service"
|
||||
MONGODB_AUTH: "{% if MONGODB_USERNAME and MONGODB_PASSWORD %}{{ MONGODB_USERNAME}}:{{ MONGODB_PASSWORD }}@{% endif %}"
|
||||
MONGODB_HOST: "{{ MONGODB_HOST }}"
|
||||
MONGODB_PORT: "{{ MONGODB_PORT }}"
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
{% if ACTIVATE_ELASTICSEARCH %}- elasticsearch{% endif %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user