Skip to content

Commit

Permalink
Dockerize
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrahimjaved12 committed Jan 15, 2024
1 parent 140656d commit 91868f5
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,4 @@ cython_debug/
.DS_Store

# OER Export JSON and CSV files created
ocw_api_data.json
ocw_oer_export.csv
output/
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 91868f5

Please sign in to comment.