Skip to content

Instantly share code, notes, and snippets.

@jessalfredsen
Last active August 17, 2023 12:56
Show Gist options
  • Select an option

  • Save jessalfredsen/73530b6623ef1b9ee80ee3c0665a528d to your computer and use it in GitHub Desktop.

Select an option

Save jessalfredsen/73530b6623ef1b9ee80ee3c0665a528d to your computer and use it in GitHub Desktop.
Go-to Docker development setup

Structure your repo like this:

my_project/
│
├── src/
│   ├── __init__.py
│   ├── module1.py
│   ├── module2.py
│   └── ...
│
├── notebooks/
│   ├── notebook1.ipynb
│   ├── notebook2.ipynb
│   └── ...
│
├── tests/
│   ├── test_module1.py
│   ├── test_module2.py
│   └── ...
│
├── setup.py
├── README.md
└── .gitignore

Run dev container with docker-compose up dev --build

If you're using pytest you can run them from the project root directory (my_project/) with pytest tests

Happy coding ;)

version: '3'
services:
# api:
# build:
# context: .
# volumes:
# - type: bind
# source: ./
# target: /app
# ports:
# - 8000:8000
dev:
build:
context: .
dockerfile: ./Dockerfile.dev
volumes:
- type: bind
source: ./
target: /app
ports:
- 8888:8888
FROM python
WORKDIR /app
RUN apt update -y
RUN pip install --upgrade pip
COPY ./requirements-dev.txt /app/requirements-dev.txt
# COPY ./requirements.txt /app/requirements.txt
RUN pip install -r requirements-dev.txt
# RUN pip install -r requirements.txt
COPY ./ /app
# Install local dir to be able to import from ./notebooks dir
RUN pip install -e .
CMD [ "jupyter", "lab", "--ip=0.0.0.0", "--allow-root", "--no-browser","--NotebookApp.token=''","--NotebookApp.password=''"]
from setuptools import setup, find_packages
setup(
name='my_project',
version='0.1',
packages=find_packages(where='src'),
package_dir={'': 'src'},
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment