diff options
author | 2019-04-05 20:59:22 +0100 | |
---|---|---|
committer | 2019-04-05 20:59:22 +0100 | |
commit | d576432e6145df464273f0f22d841cc9f5804b07 (patch) | |
tree | c229454c3b415cdacc950940283c1cdb80007783 | |
parent | pysite -> pydis_site (diff) |
Address review by @jchristgit
l--------- | Dockerfile | 1 | ||||
-rw-r--r-- | Pipfile | 42 | ||||
-rw-r--r-- | Pipfile.lock | 2 | ||||
-rw-r--r-- | azure-pipelines.yml | 15 | ||||
-rw-r--r-- | docker-compose.yml | 8 | ||||
-rw-r--r-- | docker/app/Dockerfile (renamed from docker/app/stretch/3.7/Dockerfile) | 11 | ||||
-rw-r--r-- | docker/app/alpine/3.6/Dockerfile | 33 | ||||
-rw-r--r-- | docker/app/alpine/3.7/Dockerfile | 32 | ||||
-rw-r--r-- | docker/app/stretch/3.6/Dockerfile | 39 | ||||
-rw-r--r-- | docker/pysite.dockerapp | 2 | ||||
-rw-r--r-- | pydis_site/apps/api/migrations/0008_tag_embed_validator.py | 5 | ||||
-rw-r--r-- | pydis_site/apps/api/migrations/0019_deletedmessage.py | 5 | ||||
-rw-r--r-- | pydis_site/apps/api/views.py | 2 | ||||
-rw-r--r-- | pydis_site/apps/api/viewsets.py | 8 |
14 files changed, 46 insertions, 159 deletions
diff --git a/Dockerfile b/Dockerfile deleted file mode 120000 index 9b50dcb7..00000000 --- a/Dockerfile +++ /dev/null @@ -1 +0,0 @@ -docker/app/alpine/3.7/Dockerfile
\ No newline at end of file @@ -4,29 +4,29 @@ url = "https://pypi.org/simple" verify_ssl = true [dev-packages] -flake8 = "*" -flake8-bandit = "*" -flake8-bugbear = "*" -flake8-import-order = "*" -flake8-string-format = "*" -flake8-tidy-imports = "*" -mccabe = "*" -pep8-naming = "*" -coverage = "*" -unittest-xml-reporting = "*" +flake8 = "~=3.7.7" +flake8-bandit = "~=2.1.0" +flake8-bugbear = "~=19.3.0" +flake8-import-order = "~=0.18.1" +flake8-string-format = "~=0.2.3" +flake8-tidy-imports = "~=2.0.0" +mccabe = "~=0.6.1" +pep8-naming = "~=0.8.2" +coverage = "~=4.5.3" +unittest-xml-reporting = "~=2.5.1" [packages] -django = ">=2.2" -django-crispy-forms = "*" -django-environ = "*" -django-filter = "*" -django-hosts = "*" -djangorestframework = "*" -djangorestframework-bulk = "*" -uwsgi = "*" -psycopg2-binary = "*" -django-simple-bulma = "*" -django-crispy-bulma = "*" +django = "~=2.2" +django-crispy-forms = "~=1.7.2" +django-environ = "~=0.4.5" +django-filter = "~=2.1.0" +django-hosts = "~=3.0" +djangorestframework = "~=3.9.2" +djangorestframework-bulk = "~=0.2.1" +uwsgi = "~=2.0.18" +psycopg2-binary = "~=2.8" +django-simple-bulma = ">=1.1.6,<2.0" +django-crispy-bulma = ">=0.1.2,<2.0" [requires] python_version = "3.7" diff --git a/Pipfile.lock b/Pipfile.lock index 9422d7b8..c574a6f1 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "8b0d5f0bcf74d3de74397538e673a96b56935085ed611f8d160213ca3af90109" + "sha256": "e7a956892e9d18b6ac8ab13fe8e139d29196e236fbb194f4cb8b37308ea91c6e" }, "pipfile-spec": 6, "requires": { diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1e6d67f0..78bbffae 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -17,12 +17,7 @@ jobs: - script: docker run -v $(pwd):/app:ro --rm ruby:alpine /bin/ash -c "gem install mdl && cd /app && mdl" displayName: run markdownlint - - script: | - echo 'set -ex' > script.sh - echo 'for dockerfile in docker/**/**/**/Dockerfile; do' >> script.sh - echo ' docker run -i hadolint/hadolint hadolint --ignore DL3008 --ignore DL3018 --ignore DL3019 - < $dockerfile' >> script.sh - echo 'done' >> script.sh - sh script.sh + - script: docker run -i hadolint/hadolint hadolint --ignore DL3008 --ignore DL3018 --ignore DL3019 - < docker/app/Dockerfile displayName: run hadolint - job: lint_python @@ -47,7 +42,7 @@ jobs: architecture: x64 - script: > - python -m pip install $(grep -E '^(coverage|flake8|mccabe|pep8-naming)' pyproject.toml | cut -d' ' -f1) + python -m pip install $(grep -E '^(coverage|flake8|mccabe|pep8-naming)' Pipfile | cut -d' ' -f1) displayName: install lint requirements - script: flake8 @@ -93,7 +88,7 @@ jobs: echo "CREATE DATABASE pysite OWNER pysite;" >> pgscript.sql sudo su postgres -c "psql < pgscript.sql" env: - USER_CREATE_COMMAND: CREATE USER pydis_site WITH PASSWORD 'pydis_site' CREATEDB + USER_CREATE_COMMAND: CREATE USER pysite WITH PASSWORD 'pysite' CREATEDB displayName: set up the database - script: python -m pip install pipenv && python -m pipenv install --dev --system @@ -104,7 +99,7 @@ jobs: coverage run --branch manage.py test --testrunner xmlrunner.extra.djangotestrunner.XMLTestRunner --no-input env: CI: azure - DATABASE_URL: postgres://pydis_site:pydis_site@localhost/pydis_site + DATABASE_URL: postgres://pysite:pysite@localhost/pysite displayName: run tests - script: coverage report @@ -132,7 +127,7 @@ jobs: command: 'login' - script: | - docker build -t pythondiscord/django:latest . + docker build -t pythondiscord/django:latest docker/app/Dockerfile docker push pythondiscord/django:latest displayName: Build and push the image diff --git a/docker-compose.yml b/docker-compose.yml index 8519e763..2d3e8f3b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,14 +20,14 @@ services: postgres: image: postgres:11-alpine environment: - POSTGRES_DB: pydis_site + POSTGRES_DB: pysite POSTGRES_PASSWORD: supersecretpassword - POSTGRES_USER: pydis_site + POSTGRES_USER: pysite web: build: context: . - dockerfile: docker/app/alpine/3.7/Dockerfile + dockerfile: docker/app/Dockerfile command: docker/app/migrate_and_serve.sh ports: - "127.0.0.1:8000:8000" @@ -36,7 +36,7 @@ services: volumes: - .:/app:ro environment: - DATABASE_URL: postgres://pydis_site:supersecretpassword@postgres/pydis_site + DATABASE_URL: postgres://pysite:supersecretpassword@postgres/pysite DEBUG: "true" SECRET_KEY: suitable-for-development-only diff --git a/docker/app/stretch/3.7/Dockerfile b/docker/app/Dockerfile index a1538ddd..93d0c378 100644 --- a/docker/app/stretch/3.7/Dockerfile +++ b/docker/app/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.7-stretch +FROM bitnami/python:3.7-prod STOPSIGNAL SIGQUIT ARG EXTRAS=deploy @@ -22,14 +22,17 @@ RUN apt-get update -y \ WORKDIR /app -COPY Pipfile /app/Pipfile -COPY Pipfile.lock /app/Pipfile.lock +COPY Pipfile Pipfile.lock /app/ + +RUN rm -r /opt/bitnami/python/lib/python3.*/site-packages/setuptools* && \ + pip install --no-cache-dir -U setuptools + RUN python3 -m pip install pipenv \ && python3 -m pipenv install --dev --system --deploy COPY . . -RUN python3 manage.py collectstatic --no-input --clear +RUN SECRET_KEY=placeholder DATABASE_URL=sqlite:// python3 manage.py collectstatic --no-input --clear --verbosity 0 RUN apt-get purge -y \ gcc \ diff --git a/docker/app/alpine/3.6/Dockerfile b/docker/app/alpine/3.6/Dockerfile deleted file mode 100644 index c40b6593..00000000 --- a/docker/app/alpine/3.6/Dockerfile +++ /dev/null @@ -1,33 +0,0 @@ -FROM python:3.6-alpine - -STOPSIGNAL SIGQUIT -ARG EXTRAS=deploy - -RUN adduser \ - -D \ - -H \ - -u 1500 \ - pysite - -RUN apk add --no-cache --virtual build \ - gcc \ - linux-headers \ - musl-dev \ - && \ - apk add --no-cache \ - curl \ - postgresql-dev - -WORKDIR /app - -COPY Pipfile /app/Pipfile -COPY Pipfile.lock /app/Pipfile.lock -RUN python3 -m pip install pipenv \ - && python3 -m pipenv install --dev --system --deploy \ - && apk del --purge build - -COPY . . - -RUN python3 manage.py collectstatic --no-input --clear - -CMD ["uwsgi", "--ini", "docker/app/uwsgi.ini"] diff --git a/docker/app/alpine/3.7/Dockerfile b/docker/app/alpine/3.7/Dockerfile deleted file mode 100644 index 9dfbfe09..00000000 --- a/docker/app/alpine/3.7/Dockerfile +++ /dev/null @@ -1,32 +0,0 @@ -FROM python:3.7-alpine - -STOPSIGNAL SIGQUIT - -RUN adduser \ - -D \ - -H \ - -u 1500 \ - pysite - -RUN apk add --no-cache --update --virtual build \ - gcc \ - linux-headers \ - musl-dev \ - && \ - apk add \ - curl \ - postgresql-dev - -WORKDIR /app - -COPY Pipfile /app/Pipfile -COPY Pipfile.lock /app/Pipfile.lock -RUN python3 -m pip install pipenv \ - && python3 -m pipenv install --dev --system --deploy \ - && apk del --purge build - -COPY . . - -RUN python3 manage.py collectstatic --no-input --clear - -CMD ["uwsgi", "--ini", "docker/app/uwsgi.ini"] diff --git a/docker/app/stretch/3.6/Dockerfile b/docker/app/stretch/3.6/Dockerfile deleted file mode 100644 index 5f97a510..00000000 --- a/docker/app/stretch/3.6/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -FROM python:3.6-stretch - -STOPSIGNAL SIGQUIT -ARG EXTRAS=deploy - -RUN adduser \ - --disabled-login \ - --no-create-home \ - --uid 1500 \ - pysite - -RUN apt-get update -y \ - && \ - apt-get install --no-install-recommends -y \ - gcc \ - libc-dev \ - libpq-dev \ - && \ - apt-get clean \ - && \ - rm -rf /var/lib/apt/lists/* - -WORKDIR /app - -COPY Pipfile /app/Pipfile -COPY Pipfile.lock /app/Pipfile.lock -RUN python3 -m pip install pipenv \ - && python3 -m pipenv install --dev --system --deploy - -COPY . . - -RUN python3 manage.py collectstatic --no-input --clear - -RUN apt-get purge -y \ - gcc \ - libc-dev \ - libpq-dev - -CMD ["uwsgi", "--ini", "docker/app/uwsgi.ini"] diff --git a/docker/pysite.dockerapp b/docker/pysite.dockerapp index 738fcfdd..dc472b2e 100644 --- a/docker/pysite.dockerapp +++ b/docker/pysite.dockerapp @@ -1,5 +1,5 @@ version: 0.3.0 -name: pydis_site +name: pysite description: | Our community website, built on Django and PostgreSQL. namespace: python-discord diff --git a/pydis_site/apps/api/migrations/0008_tag_embed_validator.py b/pydis_site/apps/api/migrations/0008_tag_embed_validator.py index eecc0bc3..ea8f03d2 100644 --- a/pydis_site/apps/api/migrations/0008_tag_embed_validator.py +++ b/pydis_site/apps/api/migrations/0008_tag_embed_validator.py @@ -15,9 +15,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='tag', name='embed', - field=django.contrib.postgres.fields.jsonb.JSONField(help_text='The actual embed shown by this tag.', validators=[ - - - pydis_site.apps.api.validators.validate_tag_embed]), + field=django.contrib.postgres.fields.jsonb.JSONField(help_text='The actual embed shown by this tag.', validators=[pydis_site.apps.api.validators.validate_tag_embed]), ), ] diff --git a/pydis_site/apps/api/migrations/0019_deletedmessage.py b/pydis_site/apps/api/migrations/0019_deletedmessage.py index 7a039675..f451ecf4 100644 --- a/pydis_site/apps/api/migrations/0019_deletedmessage.py +++ b/pydis_site/apps/api/migrations/0019_deletedmessage.py @@ -19,10 +19,7 @@ class Migration(migrations.Migration): ('id', models.BigIntegerField(help_text='The message ID as taken from Discord.', primary_key=True, serialize=False, validators=[django.core.validators.MinValueValidator(limit_value=0, message='Message IDs cannot be negative.')])), ('channel_id', models.BigIntegerField(help_text='The channel ID that this message was sent in, taken from Discord.', validators=[django.core.validators.MinValueValidator(limit_value=0, message='Channel IDs cannot be negative.')])), ('content', models.CharField(help_text='The content of this message, taken from Discord.', max_length=2000)), - ('embeds', django.contrib.postgres.fields.ArrayField(base_field=django.contrib.postgres.fields.jsonb.JSONField(validators=[ - - - pydis_site.apps.api.validators.validate_tag_embed]), help_text='Embeds attached to this message.', size=None)), + ('embeds', django.contrib.postgres.fields.ArrayField(base_field=django.contrib.postgres.fields.jsonb.JSONField(validators=[pydis_site.apps.api.validators.validate_tag_embed]), help_text='Embeds attached to this message.', size=None)), ('author', models.ForeignKey(help_text='The author of this message.', on_delete=django.db.models.deletion.CASCADE, to='api.User')), ('deletion_context', models.ForeignKey(help_text='The deletion context this message is part of.', on_delete=django.db.models.deletion.CASCADE, to='api.MessageDeletionContext')), ], diff --git a/pydis_site/apps/api/views.py b/pydis_site/apps/api/views.py index 3160e8f7..f88e1039 100644 --- a/pydis_site/apps/api/views.py +++ b/pydis_site/apps/api/views.py @@ -131,7 +131,7 @@ class RulesView(APIView): ), ( "We will not help you with anything that might break a law or the " - "terms of service of any other community, pydis_site, service, or " + "terms of service of any other community, pysite, service, or " "otherwise - No piracy, brute-forcing, captcha circumvention, " "sneaker bots, or anything else of that nature." ), diff --git a/pydis_site/apps/api/viewsets.py b/pydis_site/apps/api/viewsets.py index 0471f79d..17024fe8 100644 --- a/pydis_site/apps/api/viewsets.py +++ b/pydis_site/apps/api/viewsets.py @@ -54,7 +54,7 @@ class DeletedMessageViewSet(CreateModelMixin, GenericViewSet): #### Body schema >>> { ... # The member ID of the original actor, if applicable. - ... # If a member ID is given, it must be present on the pydis_site. + ... # If a member ID is given, it must be present on the site. ... 'actor': Optional[int] ... 'creation': datetime, ... 'messages': [ @@ -192,7 +192,7 @@ class InfractionViewSet(CreateModelMixin, RetrieveModelMixin, ListModelMixin, Ge ### POST /bot/infractions Create a new infraction and return the created infraction. Only `actor`, `type`, and `user` are required. - The `actor` and `user` must be users known by the pydis_site. + The `actor` and `user` must be users known by the site. #### Request body >>> { @@ -427,7 +427,7 @@ class ReminderViewSet(CreateModelMixin, ListModelMixin, DestroyModelMixin, Gener class RoleViewSet(ModelViewSet): """ View providing CRUD access to the roles on our server, used - by the bot to keep a mirror of our server's roles on the pydis_site. + by the bot to keep a mirror of our server's roles on the site. ## Routes ### GET /bot/roles @@ -802,7 +802,7 @@ class UserViewSet(BulkCreateModelMixin, ModelViewSet): ### POST /bot/users Adds a single or multiple new users. - The roles attached to the user(s) must be roles known by the pydis_site. + The roles attached to the user(s) must be roles known by the site. #### Request body >>> { |