diff --git a/.gitignore b/.gitignore index 1bcef8b..11f59bd 100644 --- a/.gitignore +++ b/.gitignore @@ -163,5 +163,4 @@ cython_debug/ .DS_Store # OER Export JSON and CSV files created -ocw_api_data.json -ocw_oer_export.csv +output/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..378d0bd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,42 @@ +FROM python:3.9.6 + +WORKDIR /tmp + +# Add, and run as, non-root user. +RUN mkdir /src +RUN adduser --disabled-password --gecos "" --shell /bin/bash mitodl + +# Install Python packages +## Set some poetry config +ENV \ + POETRY_VERSION=1.5.1 \ + POETRY_VIRTUALENVS_CREATE=false \ + POETRY_CACHE_DIR='/tmp/cache/poetry' \ + POETRY_HOME='/home/mitodl/.local' \ + VIRTUAL_ENV="/opt/venv" +ENV PATH="$VIRTUAL_ENV/bin:$POETRY_HOME/bin:$PATH" + +COPY pyproject.toml /src/ +RUN chown -R mitodl:mitodl /src +RUN mkdir ${VIRTUAL_ENV} && chown -R mitodl:mitodl ${VIRTUAL_ENV} + +## Install poetry itself, and pre-create a venv with predictable name +USER mitodl +RUN curl -sSL https://install.python-poetry.org \ + | \ + POETRY_VERSION=${POETRY_VERSION} \ + POETRY_HOME=${POETRY_HOME} \ + python3 -q +WORKDIR /src +RUN python3 -m venv $VIRTUAL_ENV +RUN poetry install + +# Add project +USER root +COPY . /src +WORKDIR /src +RUN chown -R mitodl:mitodl /src + +RUN apt-get clean && apt-get purge + +USER mitodl diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d6341ef --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3.8' + +services: + app: + build: . + image: ocw_oer_export + entrypoint: ["python", "-m", "ocw_oer_export.cli"] + command: ["--create_csv"] + tty: true + volumes: + - ./output:/output