Skip to content

Commit

Permalink
fix: changes working locally
Browse files Browse the repository at this point in the history
  • Loading branch information
aht007 committed Dec 12, 2022
1 parent 363c531 commit c754d20
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 111 deletions.
43 changes: 26 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
FROM ubuntu:focal as app

ENV DEBIAN_FRONTEND noninteractive
# System requirements.
RUN apt update && \
apt-get install -qy \
curl \
# required by bower installer
git \
language-pack-en \
build-essential \
python3.8-dev \
Expand All @@ -21,28 +24,24 @@ 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 COMMON_CFG_DIR="/edx/etc"
ARG DISCOVERY_SERVICE_NAME="discovery"
ARG DISCOVERY_HOME "${COMMON_APP_DIR}/${DISCOVERY_SERVICE_NAME}"
ARG DISCOVERY_APP_DIR="${COMMON_APP_DIR}/${DISCOVERY_SERVICE_NAME}"
ARG DISCOVERY_VENV_DIR="${COMMON_APP_DIR}/${DISCOVERY_SERVICE_NAME}/venvs/${DISCOVERY_SERVICE_NAME}"
ARG DISCOVERY_CODE_DIR="${DISCOVERY_APP_DIR}/${DISCOVERY_SERVICE_NAME}"
ARG DISCOVERY_NODEENV_DIR="${DISCOVERY_HOME}/nodeenvs/${DISCOVERY_SERVICE_NAME}"

ARG DISCOVERY_NODEENV_DIR="${DISCOVERY_APP_DIR}/nodeenvs/${DISCOVERY_SERVICE_NAME}"

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}"
ENV DISCOVERY_APP_DIR "${DISCOVERY_APP_DIR}"

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

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

RUN nodeenv ${DISCOVERY_NODEENV_DIR} --node=16.14.0 --prebuilt
RUN npm install -g [email protected]

RUN nodeenv ${DISCOVERY_NODEENV_DIR} --node=16.14.0 --prebuilt && npm install -g [email protected]

# Working directory will be root of repo.
WORKDIR ${DISCOVERY_CODE_DIR}
Expand All @@ -51,13 +50,7 @@ WORKDIR ${DISCOVERY_CODE_DIR}
COPY package.json package.json
COPY package-lock.json package-lock.json
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 . .
RUN npm install --production && ./node_modules/.bin/bower install --allow-root --production

# Expose canonical Discovery port
EXPOSE 18381
Expand All @@ -70,13 +63,29 @@ COPY requirements/production.txt ${DISCOVERY_CODE_DIR}/requirements/production.t

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

ENTRYPOINT ["/edx/app/discovery/discovery.sh"]
# 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 . .

CMD gunicorn --bind=0.0.0.0:8381 --workers 2 --max-requests=1000 -c course_discovery/docker_gunicorn_configuration.py course_discovery.wsgi:application

FROM app as dev

ENV DJANGO_SETTINGS_MODULE "course_discovery.settings.devstack"

COPY requirements/local.txt ${DISCOVERY_CODE_DIR}/requirements/local.txt
COPY requirements/django.txt ${DISCOVERY_CODE_DIR}/requirements/django.txt

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

# Devstack related step for backwards compatibility
RUN touch ${DISCOVERY_HOME}/${DISCOVERY_SERVICE_NAME}_env
RUN touch ${DISCOVERY_APP_DIR}/discovery_env

# 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 . .

CMD while true; do python ./manage.py runserver 0.0.0.0:8381; sleep 2; done
94 changes: 0 additions & 94 deletions configuration_files/discovery.yml

This file was deleted.

0 comments on commit c754d20

Please sign in to comment.