diff --git a/Dockerfile b/Dockerfile index 53d4cd5..e12cef6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,24 @@ -FROM python:2-onbuild +FROM python:2.7-alpine + +RUN apk add --no-cache make + +ADD requirements.txt /app/requirements.txt +RUN pip --disable-pip-version-check install -r /app/requirements.txt ARG DJANGO_VERSION +RUN pip --disable-pip-version-check install django==$DJANGO_VERSION -RUN pip install django==$DJANGO_VERSION +ADD . /app +WORKDIR /app +ENV PYTHONPATH /app + +RUN make resetdb +RUN echo "from django.contrib.auth import get_user_model; \ + User = get_user_model(); \ + User.objects.create_superuser('admin', 'admin@example.com', 'admin')" | \ + python example_project/manage.py shell ENV PORT 8000 EXPOSE 8000 -ENV PYTHONPATH /usr/src/app - CMD python example_project/manage.py runserver 0.0.0.0:$PORT diff --git a/Makefile b/Makefile index 70aac5c..a45cd4b 100644 --- a/Makefile +++ b/Makefile @@ -36,13 +36,13 @@ coverage: ## Run and then display coverage report resetdb: ## Delete and then recreate the dev sqlite database python $(MANAGE) reset_db --router=default --noinput - python $(MANAGE) syncdb --noinput - python $(MANAGE) migrate --noinput + -python $(MANAGE) syncdb --noinput + -python $(MANAGE) migrate --noinput python $(MANAGE) loaddata sample_data .PHONY: build build: ## Build a full set of Docker images -build: build/1.9 build/1.8.7 build/1.7.11 build/1.6.11 build/1.5.12 +build: build/1.9.2 build/1.8.9 build/1.7.11 build/1.6.11 build/1.5.12 build/%: docker build --build-arg DJANGO_VERSION=$* \ @@ -51,10 +51,17 @@ build/%: run: run/1.9 run/%: - docker run --rm -p 8000:8000 --sig-proxy=false $(IMAGE):$* + docker run --rm -p 8000:8000 -it $(IMAGE):$* + +docker/publish: ## Publish Docker images to the hub + docker push $(IMAGE):1.9 + docker push $(IMAGE):1.8 + docker push $(IMAGE):1.7 + docker push $(IMAGE):1.6 + docker push $(IMAGE):1.5 test/%: - docker run --rm -p 8000:8000 --sig-proxy=false $(IMAGE):$* make test + docker run --rm -p 8000:8000 -t $(IMAGE):$* make test bash: docker run --rm -it $(IMAGE):1.9 /bin/bash diff --git a/README.rst b/README.rst index 7767e08..ff7ed15 100644 --- a/README.rst +++ b/README.rst @@ -172,6 +172,16 @@ Limitations planned for the future. +Demo Admin & Docker images +-------------------------- + +You can try the demo admin against several versions of Django with these Docker +images: https://hub.docker.com/r/crccheck/django-object-actions/ + +This runs the example Django project in ``./example_project`` based on the +"polls" tutorial. ``admin.py`` demos what you can do with this app. + + Development ----------- diff --git a/example_project/polls/migrations/0001_initial.py b/example_project/polls/migrations/0001_initial.py new file mode 100644 index 0000000..178f701 --- /dev/null +++ b/example_project/polls/migrations/0001_initial.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.2 on 2016-02-25 17:25 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import django_extensions.db.fields + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Choice', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('choice_text', models.CharField(max_length=200)), + ('votes', models.IntegerField()), + ], + ), + migrations.CreateModel( + name='Comment', + fields=[ + ('uuid', django_extensions.db.fields.UUIDField(blank=True, editable=False, primary_key=True, serialize=False)), + ('comment', models.TextField(blank=True, null=True)), + ], + ), + migrations.CreateModel( + name='Poll', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('question', models.CharField(max_length=200)), + ('pub_date', models.DateTimeField(verbose_name=b'date published')), + ], + ), + migrations.AddField( + model_name='choice', + name='poll', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='polls.Poll'), + ), + ] diff --git a/example_project/polls/migrations/__init__.py b/example_project/polls/migrations/__init__.py new file mode 100644 index 0000000..e69de29