Skip to content

Commit

Permalink
fix: remove supervisor and misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
aht007 committed Dec 2, 2022
1 parent d5a7d3f commit 3c98c0b
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 184 deletions.
89 changes: 14 additions & 75 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ FROM ubuntu:focal as app
RUN apt update && \
apt-get install -qy \
curl \
vim \
git-core \
language-pack-en \
build-essential \
python3.8-dev \
Expand All @@ -23,97 +21,43 @@ ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8

ARG COMMON_APP_DIR="/edx/app"
ARG COMMON_CFG_DIR "/edx/etc"
ARG DISCOVERY_SERVICE_NAME="discovery"
ENV DISCOVERY_HOME "${COMMON_APP_DIR}/${DISCOVERY_SERVICE_NAME}"
ARG DISCOVERY_HOME "${COMMON_APP_DIR}/${DISCOVERY_SERVICE_NAME}"
ARG DISCOVERY_APP_DIR="${COMMON_APP_DIR}/${DISCOVERY_SERVICE_NAME}"
ARG SUPERVISOR_APP_DIR="${COMMON_APP_DIR}/supervisor"
ARG DISCOVERY_VENV_DIR="${COMMON_APP_DIR}/${DISCOVERY_SERVICE_NAME}/venvs/${DISCOVERY_SERVICE_NAME}"
ARG SUPERVISOR_VENVS_DIR="${SUPERVISOR_APP_DIR}/venvs"
ARG SUPERVISOR_VENV_DIR="${SUPERVISOR_VENVS_DIR}/supervisor"
ARG DISCOVERY_CODE_DIR="${DISCOVERY_APP_DIR}/${DISCOVERY_SERVICE_NAME}"
ARG DISCOVERY_NODEENV_DIR="${COMMON_APP_DIR}/${DISCOVERY_SERVICE_NAME}/nodeenvs/${DISCOVERY_SERVICE_NAME}"
ARG SUPERVISOR_AVAILABLE_DIR="${COMMON_APP_DIR}/supervisor/conf.available.d"
ARG SUPERVISOR_VENV_BIN="${SUPERVISOR_VENV_DIR}/bin"
ARG SUPEVISOR_CTL="${SUPERVISOR_VENV_BIN}/supervisorctl"
ARG SUPERVISOR_VERSION="4.2.1"
ARG SUPERVISOR_CFG_DIR="${SUPERVISOR_APP_DIR}/conf.d"
ARG DISCOVERY_NODE_VERSION="16.14.0"
ARG DISCOVERY_NPM_VERSION="8.5.x"

# These variables were defined in Ansible configuration but I couldn't find them being used anywhere.
# I have commented these out for now but I would like to take opinion from someone having more knowledge about them
# and whether it is safe to comment them out. I did basic smoke testing and everything seems to be working fine.

# ENV DISCOVERY_ECOMMERCE_API_URL 'https://localhost:8002/api/v2/'
# ENV DISCOVERY_COURSES_API_URL '${DISCOVERY_LMS_ROOT_URL}/api/courses/v1/'
# ENV DISCOVERY_ORGANIZATIONS_API_URL '${DISCOVERY_LMS_ROOT_URL}/api/organizations/v0/'
# ENV DISCOVERY_MARKETING_API_URL 'https://example.org/api/catalog/v2/'
# ENV DISCOVERY_MARKETING_URL_ROOT 'https://example.org/'


ENV HOME /root
ENV PATH "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
ENV PATH "${DISCOVERY_VENV_DIR}/bin:${DISCOVERY_NODEENV_DIR}/bin:$PATH"
ENV COMMON_CFG_DIR "/edx/etc"
ENV DISCOVERY_CFG_DIR "${COMMON_CFG_DIR}/discovery"
ENV DISCOVERY_CFG "/edx/etc/discovery.yml"

ENV DISCOVERY_NODEENV_DIR "${DISCOVERY_HOME}/nodeenvs/${DISCOVERY_SERVICE_NAME}"
ENV DISCOVERY_NODEENV_BIN "${DISCOVERY_NODEENV_DIR}/bin"
ENV DISCOVERY_NODE_MODULES_DIR "${DISCOVERY_CODE_DIR}}/node_modules"
ENV DISCOVERY_NODE_BIN "${DISCOVERY_NODE_MODULES_DIR}/.bin"
ARG DISCOVERY_NODEENV_DIR="${DISCOVERY_HOME}/nodeenvs/${DISCOVERY_SERVICE_NAME}"

RUN addgroup discovery
RUN adduser --disabled-login --disabled-password discovery --ingroup discovery

# Make necessary directories and environment variables.
RUN mkdir -p /edx/var/discovery/staticfiles
RUN mkdir -p /edx/var/discovery/media
# Log dir
RUN mkdir /edx/var/log/
ENV PATH "${DISCOVERY_VENV_DIR}/bin:${DISCOVERY_NODEENV_DIR}/bin:$PATH"
ENV DISCOVERY_CFG "/edx/etc/discovery.yml"
ENV DISCOVERY_CODE_DIR "${DISCOVERY_CODE_DIR}"
ENV DISCOVERY_HOME "${DISCOVERY_HOME}"

RUN virtualenv -p python3.8 --always-copy ${DISCOVERY_VENV_DIR}
RUN virtualenv -p python3.8 --always-copy ${SUPERVISOR_VENV_DIR}

# No need to activate discovery venv as it is already in path
RUN pip install nodeenv

#install supervisor and deps in its virtualenv
RUN . ${SUPERVISOR_VENV_BIN}/activate && \
pip install supervisor==${SUPERVISOR_VERSION} backoff==1.4.3 boto==2.48.0 && \
deactivate
RUN nodeenv ${DISCOVERY_NODEENV_DIR} --node=16.14.0 --prebuilt
RUN npm install -g [email protected]

RUN nodeenv ${DISCOVERY_NODEENV_DIR} --node=${DISCOVERY_NODE_VERSION} --prebuilt
RUN npm install -g npm@${DISCOVERY_NPM_VERSION}

COPY requirements/production.txt ${DISCOVERY_CODE_DIR}/requirements/production.txt

RUN pip install -r ${DISCOVERY_CODE_DIR}/requirements/production.txt

# Working directory will be root of repo.
WORKDIR ${DISCOVERY_CODE_DIR}

# Copy just JS requirements and install them.
COPY package.json package.json
COPY package-lock.json package-lock.json
RUN npm install --production
COPY bower.json bower.json
RUN npm install --production
RUN ./node_modules/.bin/bower install --allow-root --production

# Copy over rest of code.
# We do this AFTER requirements so that the requirements cache isn't busted
# every time any bit of code is changed.
COPY . .
COPY /configuration_files/discovery_gunicorn.py ${DISCOVERY_HOME}/discovery_gunicorn.py
COPY /configuration_files/discovery-workers.sh ${DISCOVERY_HOME}/discovery-workers.sh
COPY /configuration_files/discovery.yml ${DISCOVERY_CFG}
COPY /scripts/discovery.sh ${DISCOVERY_HOME}/discovery.sh
# create supervisor job
COPY /configuration_files/supervisor.service /etc/systemd/system/supervisor.service
COPY /configuration_files/supervisor.conf ${SUPERVISOR_CFG_DIR}/supervisor.conf
COPY /configuration_files/supervisorctl ${SUPERVISOR_VENV_BIN}/supervisorctl
# Manage.py symlink
COPY /manage.py /edx/bin/manage.discovery

# Expose canonical Discovery port
EXPOSE 18381
Expand All @@ -122,7 +66,9 @@ FROM app as prod

ENV DJANGO_SETTINGS_MODULE "course_discovery.settings.production"

RUN make static
COPY requirements/production.txt ${DISCOVERY_CODE_DIR}/requirements/production.txt

RUN pip install -r ${DISCOVERY_CODE_DIR}/requirements/production.txt

ENTRYPOINT ["/edx/app/discovery/discovery.sh"]

Expand All @@ -132,12 +78,5 @@ ENV DJANGO_SETTINGS_MODULE "course_discovery.settings.devstack"

RUN pip install -r ${DISCOVERY_CODE_DIR}/requirements/local.txt

COPY /scripts/devstack.sh ${DISCOVERY_HOME}/devstack.sh

RUN chown discovery:discovery /edx/app/discovery/devstack.sh && chmod a+x /edx/app/discovery/devstack.sh

# Devstack related step for backwards compatibility
RUN touch /edx/app/${DISCOVERY_SERVICE_NAME}/${DISCOVERY_SERVICE_NAME}_env

ENTRYPOINT ["/edx/app/discovery/devstack.sh"]
CMD ["start"]
RUN touch ${DISCOVERY_HOME}/${DISCOVERY_SERVICE_NAME}_env
7 changes: 0 additions & 7 deletions configuration_files/discovery-workers.sh

This file was deleted.

14 changes: 0 additions & 14 deletions configuration_files/discovery_gunicorn.py

This file was deleted.

13 changes: 0 additions & 13 deletions configuration_files/supervisor.conf

This file was deleted.

29 changes: 0 additions & 29 deletions configuration_files/supervisor.service

This file was deleted.

10 changes: 0 additions & 10 deletions configuration_files/supervisorctl

This file was deleted.

30 changes: 0 additions & 30 deletions scripts/devstack.sh

This file was deleted.

6 changes: 0 additions & 6 deletions scripts/discovery.sh

This file was deleted.

0 comments on commit 3c98c0b

Please sign in to comment.