diff --git a/Dockerfile b/Dockerfile index 99a69344024..e4181b921d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \ @@ -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 npm@8.5.x - +RUN nodeenv ${DISCOVERY_NODEENV_DIR} --node=16.14.0 --prebuilt && npm install -g npm@8.5.x # Working directory will be root of repo. WORKDIR ${DISCOVERY_CODE_DIR} @@ -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 @@ -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 diff --git a/configuration_files/discovery.yml b/configuration_files/discovery.yml deleted file mode 100644 index 2a4da33d0af..00000000000 --- a/configuration_files/discovery.yml +++ /dev/null @@ -1,94 +0,0 @@ ---- - - -API_ROOT: null -AWS_SES_REGION_ENDPOINT: email.us-east-1.amazonaws.com -AWS_SES_REGION_NAME: us-east-1 -BACKEND_SERVICE_EDX_OAUTH2_KEY: discovery-backend-service-key -BACKEND_SERVICE_EDX_OAUTH2_PROVIDER_URL: http://localhost:18000/oauth2 -BACKEND_SERVICE_EDX_OAUTH2_SECRET: discovery-backend-service-secret -CACHES: - default: - BACKEND: django.core.cache.backends.memcached.MemcachedCache - KEY_PREFIX: discovery - LOCATION: - - edx.devstack.memcached:11211 -CELERY_BROKER_URL: redis://:@127.0.0.1:6379/ -CORS_ORIGIN_WHITELIST: [] -CSRF_COOKIE_SECURE: false -DATABASES: - default: - ATOMIC_REQUESTS: 'false' - CONN_MAX_AGE: 60 - ENGINE: django.db.backends.mysql - HOST: edx.devstack.mysql - NAME: discovery - OPTIONS: - connect_timeout: 10 - init_command: SET sql_mode='STRICT_TRANS_TABLES' - PASSWORD: password - PORT: 3306 - USER: discov001 - read_replica: - ATOMIC_REQUESTS: 'false' - CONN_MAX_AGE: 60 - ENGINE: django.db.backends.mysql - HOST: edx.devstack.mysql - NAME: discovery - OPTIONS: - connect_timeout: 10 - init_command: SET sql_mode='STRICT_TRANS_TABLES' - PASSWORD: password - PORT: 3306 - USER: discov001 -DEFAULT_PARTNER_ID: 1 -EDX_DRF_EXTENSIONS: - OAUTH2_USER_INFO_URL: http://127.0.0.1:8000/user_info -ELASTICSEARCH_CLUSTER_URL: http://127.0.0.1:9200/ -ELASTICSEARCH_INDEX_NAME: catalog -EMAIL_BACKEND: django_ses.SESBackend -EMAIL_HOST: localhost -EMAIL_HOST_PASSWORD: '' -EMAIL_HOST_USER: '' -EMAIL_PORT: 25 -EMAIL_USE_TLS: false -ENABLE_PUBLISHER: false -EXTRA_APPS: -- course_discovery.apps.edx_catalog_extensions -JWT_AUTH: - JWT_AUTH_COOKIE_HEADER_PAYLOAD: edx-jwt-cookie-header-payload - JWT_AUTH_COOKIE_SIGNATURE: edx-jwt-cookie-signature - JWT_AUTH_REFRESH_COOKIE: edx-jwt-refresh-cookie - JWT_ISSUERS: - - AUDIENCE: lms-key - ISSUER: http://edx.devstack.lms:18000/oauth2 - SECRET_KEY: lms-secret - JWT_PUBLIC_SIGNING_JWK_SET: '' -LANGUAGE_CODE: en -MEDIA_STORAGE_BACKEND: - DEFAULT_FILE_STORAGE: django.core.files.storage.FileSystemStorage - MEDIA_ROOT: /edx/var/discovery/media - MEDIA_URL: /media/ -OPENEXCHANGERATES_API_KEY: '' -PARLER_DEFAULT_LANGUAGE_CODE: en -PARLER_LANGUAGES: - 1: - - code: en - default: - fallbacks: - - en - hide_untranslated: 'False' -PLATFORM_NAME: Your Platform Name Here -PUBLISHER_FROM_EMAIL: null -SECRET_KEY: Your secret key here -SESSION_EXPIRE_AT_BROWSER_CLOSE: false -SOCIAL_AUTH_EDX_OAUTH2_ISSUER: http://127.0.0.1:8000 -SOCIAL_AUTH_EDX_OAUTH2_KEY: discovery-sso-key -SOCIAL_AUTH_EDX_OAUTH2_LOGOUT_URL: http://localhost:18000/logout -SOCIAL_AUTH_EDX_OAUTH2_SECRET: discovery-sso-secret -SOCIAL_AUTH_EDX_OAUTH2_URL_ROOT: http://127.0.0.1:8000 -SOCIAL_AUTH_REDIRECT_IS_HTTPS: false -STATICFILES_STORAGE: django.contrib.staticfiles.storage.StaticFilesStorage -STATIC_ROOT: /edx/var/discovery/staticfiles -TIME_ZONE: UTC -USERNAME_REPLACEMENT_WORKER: OVERRIDE THIS WITH A VALID USERNAME