-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JM's suggested tweaks based on rfds upgrade #26
base: master
Are you sure you want to change the base?
Changes from all commits
af6eded
85a95dd
d6a135e
7d35c58
f165ecf
dfcffbe
a39a5c4
7ee6689
b2444e3
37bc343
6f26d0c
3876fdd
36698c2
541e50f
3812b4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
# Reset a local development environment | ||
|
||
set -e | ||
|
||
if [[ -z "$PROJECT_DIR" ]]; then | ||
>&2 echo "ERROR: Missing environment variable: PROJECT_DIR" | ||
exit 1 | ||
fi | ||
|
||
rm -rf "$DIR/var" | ||
|
||
find . -name "*.md5" -delete |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,9 @@ | |
|
||
from django.utils.six import text_type | ||
|
||
# Store DOTENV from environment as a setting | ||
DOTENV = os.environ.get('DOTENV', 'dotenv-not-set') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my commit message around that. It's very useful, and I'm stick of having to look up |
||
|
||
# Get project directory from environment. This MUST already be defined. | ||
# Copied from __init__.py I'm not sure why it's needed here as well | ||
PROJECT_DIR = os.environ['PROJECT_DIR'].rstrip('/') | ||
|
@@ -136,6 +139,9 @@ | |
MEDIA_ROOT = os.path.join(VAR_DIR, 'media_root') | ||
MEDIA_URL = '/media/' | ||
|
||
# Prefix for admin URL paths, see `ixc_django_docker.urls` | ||
ADMIN_URL = '/admin/' | ||
|
||
# | ||
# HTTPS | ||
# | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ project_settings_local.py | |
src/ | ||
static_root/ | ||
var/ | ||
venv | ||
venv/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was intentional. The virtualenv is stored in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, if it's only there for you @mrmachine better to remove it |
||
|
||
# Docker ignores. | ||
*.secret |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,7 @@ | |
export DOTENV='develop' | ||
export TRANSCRYPT_PASSWORD='' # Get from 1Password | ||
# export WITHOUT_COVERAGE=1 | ||
|
||
# Safely send real emails; Bandit prevents sending to arbitrary addresses | ||
export BANDIT_EMAIL='[email protected]' | ||
export BANDIT_WHITELIST='interaction.net.au,[email protected]' | ||
Comment on lines
+6
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment these out by default? Won't work without SMTP credentials either, which are usually not set in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mrmachine I really want to ensure we have a safe email setup by default. You are right that these settings are pointless without corresponding SMTP settings, but as soon as anyone adds SMPT settings the email hijacking will apply and prevent unintended emails. If they're commented out, there's even less chance anyone will ever apply these butt-saving settings. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,48 +10,59 @@ steps: | |
type: build | ||
image_name: interaction/project_template | ||
|
||
run_tests: | ||
type: composition | ||
composition: | ||
version: '2' | ||
# Run tests and push built image in parallel | ||
in_parallel: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Name this step There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤷 If you want, I don't care about the name |
||
type: parallel | ||
steps: | ||
|
||
services: | ||
django: | ||
depends_on: | ||
# - elasticsearch | ||
- postgres | ||
- redis | ||
environment: | ||
DOTENV: test | ||
# ELASTICSEARCH_ADDRESS: elasticsearch:9200 | ||
PGHOST: postgres | ||
PGUSER: postgres | ||
REDIS_ADDRESS: redis:6379 | ||
image: '${{build_image}}' | ||
# Push UNTESTED image to improve caching (not to be used directly) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add "and speed up the pipeline". That's the second and equally (or possibly even more) impactful optimisation (affects every build, not only future builds that can use build cache). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The pipeline speed-up is a side-effect of running that push in parallel, so I don't think that point belongs in the comment above just the push step |
||
push_untested_image: | ||
candidate: '${{build_image}}' | ||
type: push | ||
tag: 'untested-${{CF_REVISION}}' | ||
|
||
# elasticsearch: | ||
# image: interaction/elasticsearch-icu:7-alpine | ||
run_tests: | ||
type: composition | ||
composition: | ||
version: '2' | ||
|
||
postgres: | ||
environment: | ||
POSTGRES_HOST_AUTH_METHOD: trust | ||
image: postgres:12.2-alpine | ||
services: | ||
django: | ||
depends_on: | ||
# - elasticsearch | ||
- postgres | ||
- redis | ||
environment: | ||
DOTENV: test | ||
# ELASTICSEARCH_ADDRESS: elasticsearch:9200 | ||
PGHOST: postgres | ||
PGUSER: postgres | ||
REDIS_ADDRESS: redis:6379 | ||
image: '${{build_image}}' | ||
|
||
redis: | ||
image: redis:6-alpine | ||
# elasticsearch: | ||
# image: interaction/elasticsearch-icu:7-alpine | ||
|
||
volumes: | ||
# elasticsearch-data: | ||
postgres-data: | ||
redis-data: | ||
postgres: | ||
environment: | ||
POSTGRES_HOST_AUTH_METHOD: trust | ||
image: postgres:12.2-alpine | ||
|
||
composition_candidates: | ||
django: | ||
command: runtests.sh --failfast . | ||
when: | ||
condition: | ||
all: | ||
skip_tests_variable: lower('${{CF_SKIP_TESTS}}') != 'true' | ||
redis: | ||
image: redis:6-alpine | ||
|
||
volumes: | ||
# elasticsearch-data: | ||
postgres-data: | ||
redis-data: | ||
|
||
composition_candidates: | ||
django: | ||
command: runtests.sh --failfast . | ||
when: | ||
condition: | ||
all: | ||
skip_tests_variable: lower('${{CF_SKIP_TESTS}}') != 'true' | ||
|
||
push_images: | ||
candidate: '${{build_image}}' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,33 @@ | ||
# -e ..[celery,celery4,celery-email,compressor,datadog,debug-toolbar,email-bandit,extensions,logentries,master-password,newrelic,nose,post-office,postgres,pydevd,sentry,storages,whitenoise] | ||
-e git+https://github.com/ixc/ixc-django-docker.git@master#egg=ixc-django-docker[celery,celery4,celery-email,compressor,datadog,debug-toolbar,email-bandit,extensions,logentries,master-password,newrelic,nose,post-office,postgres,pydevd,sentry,storages,whitenoise] | ||
|
||
|
||
############################################################################## | ||
# Django<1.11 compatibility recommendations | ||
|
||
# -e git+https://github.com/ixc/ixc-whitenoise.git@9812e7b3caa62a438c9332653c2b297856d6f104#egg=ixc-whitenoise # Compatibilty with older Django | ||
# celery<4.3 # Version 4.3 requires Django>=1.11 | ||
# django-appconf<1.0.4 # Version 1.0.4 should work with Django 1.8 but doesn't | ||
# django-celery-beat<1.6 # Version 1.6 requires Django>=1.11.17 | ||
# django-celery-email<3 # Version 3.0.0 requires Django>1 | ||
# django-celery-results<1.1 # Version 1.1 requires celery>=4.3 | ||
# django-compressor<2.2 # Version 2.3 requires Django>1.11, but 2.2 doesn't work | ||
# django-debug-toolbar<1.10 # Version 1.10 requires Django>=1.11 | ||
# django-extensions<2.1.1 # Version 2.1.1 requires Django>=1.11 | ||
# django-ipware<3 # Version 3 requires Python>=3.5 | ||
# django-post-office<3.3 # Version 3.3.0 requires Django>=1.11 | ||
# django-redis<4.9 # Version 4.9.0 requires Django>=1.11 | ||
# django-storages<1.6.6 # Version 1.6.6 requires Django>=1.11 | ||
# django-timezone-field<3.1 # Version 3.1 requires Django>=1.11 | ||
# jsonfield<2.1 # Version 2.1 requires Django>=1.11 | ||
|
||
############################################################################## | ||
|
||
|
||
############################################################################## | ||
# Use Thumbor for thumbnails (latest versions of IC forks of Thumbor libs) | ||
|
||
# -e git+https://github.com/ixc/django-thumbor.git@481cf39536b384369b2bc31da2af2bee34a4c617#egg=django-thumbor | ||
# -e git+https://github.com/ixc/libthumbor.git@d5f44bbd6cd7c19f61f47d941213d1de52209521#egg=libthumbor | ||
|
||
############################################################################## | ||
Comment on lines
+5
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we put these in an SOT post and link to it from a comment, with links to different Django versions? Might be more generally discoverable there and useful to anyone upgrading deps, not necessarily as a whole stack/ixc-django-docker upgrade. And I don't think this is relevant to anyone making a new project with the project template (probably using latest versions). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rather not move them. Here they are present exactly where they can be easily enabled for anyone upgrading old sites (which in theory we are doing?) and version controlled. I'm not going to remember to return to SOT every time I find a tweak to settings like this, whereas I might remember to upstream them to the ixc-django-docker. I'm in favour of linking from a SOT post to this listing. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,6 +93,7 @@ | |
'storages': [ | ||
'boto3', | ||
'django-storages', | ||
'requests', | ||
], | ||
'whitenoise': [ | ||
'ixc-whitenoise', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be
$PROJECT_DIR
?Also, this can only run from within an active project shell where the virtualenv has been configured. But it will completely delete the virtualenv. You'll need to exit the shell and re-run
./go.sh
again to recreate it, steps that I don't think we can automate. For a full reset, there are also other directories that could be removed.bower_components
,node_modules
,static_root
(which includes compiled/compressed assets as well as collected files). Also the database.That's why I never created a reset script. Too many variables. I figured people can just reset just what they need to reset when they need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also already do
SETUP_POSTGRES_FORCE=1 setup-postgres.sh
(drop/recreate db frominitial_data.sql
dump or creds inSRC_*
env vars) andSETUP_FORCE=1 setup.sh
(remove*.md5
files first).node_modules
dir is also already removed when reinstalling. Nothing to deletevar
, though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrmachine Maybe the nuke commands could be printed somewhere obvious when the
./go.sh
script runs? So they are available for copy-and-paste, but don't try to automate more than we reasonable can?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An alternate approach:
./go.sh --clean
: https://github.com/ixc/rfds/commit/df08700e5d4a5a079522f99d1d37fd04002a233c