Docker container allowing you to build and test your Python project.
This container mainly targets Python web project developments (Understand Django) but you can try to make it work with your project even if your project is not using web technologies.
Extended from official Python image for Docker.
pip - The PyPA recommended tool for installing Python packages.poetry - Python packaging and dependency management made easyuv - An extremely fast Python package and project manager, written in Rust.We recommend you to use the dev user instead of root when running that container.
The container's working directory is /var/www/app so we advise you to mount your project directory onto this place.
docker-compose.yml
services:
django:
container_name: my-super-django-app
build:
dockerfile: ./docker/django/Dockerfile
context: .
environment:
PYTHONUNBUFFERED: 1
ports:
- "8000:8000"
entrypoint: ./docker/django-entrypoint.sh
volumes:
- ./:/var/www/app
- ./log:/var/log/django/
./docker/django-entrypoint.sh
#!/usr/bin/env bash
poetry install
poetry run python manage.py migrate
poetry run python manage.py loaddata fixtures/groups.yaml
poetry run python manage.py loaddata fixtures/transaction_types.yaml
poetry run python manage.py loaddata fixtures/wallet_types.yaml
poetry run python manage.py collectstatic --noinput
export LOG_HANDLER='file'
poetry run python manage.py runserver 0.0.0.0:8000
./docker/django/Dockerfile
FROM vnvsa/python:3.12
USER root
# Install system deps
RUN apt-get update --yes && \
apt-get install --yes \
unixodbc \
unixodbc-dev \
wget \
cron
# Install python deps
RUN pip install --upgrade pip && \
pip install pyodbc && \
mkdir -p /var/log/django/ && \
chown dev:dev /var/log/django/
USER dev
Run using a compose configuration:
docker compose run --entrypoint="poetry up --latest" django
Update your Dockerfile to install the version of poetry you need.
FROM vnvsa/python:3.12
USER root
RUN pip install poetry==1.8.3 \
&& pip cache purge
USER dev
Pull requests, bug reports, and feature requests are welcome.
MIT License. See the LICENSE file.
Content type
Image
Digest
sha256:21c4a4b4f…
Size
977 MB
Last updated
3 days ago
docker pull vnvsa/slurpy:3.10-bookworm