Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the docker/compose setup #3802

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,7 @@ docs/_site
tsconfig.tsbuildinfo

# VS-Code
.vscode
.vscode

# docker
docker-compose.override.yml
28 changes: 19 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9.13
FROM python:3.9.13 as base
LABEL maintainer "ODL DevOps <[email protected]>"

# Add package files, install updated node and pip
Expand All @@ -8,13 +8,12 @@ WORKDIR /tmp
COPY apt.txt /tmp/apt.txt
RUN apt-get update
RUN apt-get install -y $(grep -vE "^\s*#" apt.txt | tr "\n" " ")
RUN apt-get update && apt-get install libpq-dev postgresql-client -y

# pip
RUN curl --silent --location https://bootstrap.pypa.io/get-pip.py | python3 -

# Add, and run as, non-root user.
RUN mkdir /src
RUN mkdir /app
RUN adduser --disabled-password --gecos "" mitodl
RUN mkdir /var/media && chown -R mitodl:mitodl /var/media

Expand All @@ -24,16 +23,27 @@ COPY test_requirements.txt /tmp/test_requirements.txt
RUN pip install -r requirements.txt -r test_requirements.txt

# Add project
COPY . /src
WORKDIR /src
RUN chown -R mitodl:mitodl /src
COPY . /app
WORKDIR /app
RUN chown -R mitodl:mitodl /app

RUN apt-get clean && apt-get purge
USER mitodl

# Set pip cache folder, as it is breaking pip when it is on a shared volume
ENV XDG_CACHE_HOME /tmp/.cache

EXPOSE 8063
ENV PORT 8063
FROM base as django

USER mitodl

FROM base as django-server

EXPOSE 8013
ENV PORT 8013
CMD uwsgi uwsgi.ini

FROM base as jupyter-notebook

RUN pip install --force-reinstall jupyter

USER mitodl
10 changes: 0 additions & 10 deletions Dockerfile-nb

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ otherwise do in a Django shell. To get started:
```
- Build the `notebook` container _(for first time use, or when requirements change)_
```bash
docker-compose -f docker-compose-notebook.yml build
docker-compose --profile notebook build
```
- Run all the standard containers (`docker-compose up`)
- In another terminal window, run the `notebook` container
- In another terminal window, run the app with the `notebook` container
```bash
docker-compose -f docker-compose-notebook.yml run --rm --service-ports notebook
docker-compose --profile notebook up
```
- Visit the running notebook server in your browser. The `notebook` container log output will
indicate the URL and `token` param with some output that looks like this:
Expand Down
2 changes: 2 additions & 0 deletions apt.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ net-tools
pkg-config
libffi-dev
libxmlsec1-dev
libpq-dev
postgresql-client
41 changes: 0 additions & 41 deletions docker-compose-notebook.yml

This file was deleted.

34 changes: 0 additions & 34 deletions docker-compose.override.yml

This file was deleted.

37 changes: 35 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ version: '3.7'

x-environment:
&py-environment
DEBUG: 'False'
DEBUG: ${DEBUG:-True}
DEV_ENV: 'True' # necessary to have nginx connect to web container
NODE_ENV: 'production'
NODE_ENV: ${NODE_ENV:-development}
DATABASE_URL: postgres://postgres@db:5432/postgres
OPEN_DISCUSSIONS_SECURE_SSL_REDIRECT: 'False'
OPEN_DISCUSSIONS_DB_DISABLE_SSL: 'True'
Expand Down Expand Up @@ -55,6 +55,9 @@ services:
- "8063:8063"
links:
- web
volumes:
- ./config/nginx.conf:/etc/nginx/conf.d/web.conf
- ./:/src

web:
build:
Expand All @@ -75,6 +78,9 @@ services:
- redis
- watch
extra_hosts: *default-extra-hosts
volumes:
- .:/src
- django_media:/var/media

watch:
image: node:16.15.1
Expand All @@ -92,6 +98,7 @@ services:
env_file: .env
volumes:
- .:/src
- yarn-cache:/home/mitodl/.cache/yarn

celery:
build:
Expand All @@ -107,9 +114,35 @@ services:
- db
- redis
extra_hosts: *default-extra-hosts
volumes:
- .:/src
- django_media:/var/media

tika:
image: apache/tika:1.23
entrypoint: java -jar tika-server-1.23.jar -h 0.0.0.0 -spawnChild
ports:
- "9998:9998"

notebook:
build:
context: .
dockerfile: Dockerfile
target: jupyter-notebook
profiles: ["notebook"]
volumes:
- .:/app
environment:
<< : *py-environment
BASE_DJANGO_APP_NAME: open_discussions
env_file: .env
command: >
/bin/bash -c '
sleep 3 &&
jupyter notebook --no-browser --ip=0.0.0.0 --port=8080'
ports:
- "8080:8080"

volumes:
django_media: {}
yarn-cache: {}