-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f848295
commit 2cb1321
Showing
11 changed files
with
147 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"python.formatting.provider": "black" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,26 @@ | ||
FROM python:3.8 | ||
ENV PYTHONUNBUFFERED 1 | ||
FROM library/python:3.8-slim-buster | ||
|
||
# Allows docker to cache installed dependencies between builds | ||
COPY ./requirements.txt requirements.txt | ||
RUN pip install -r requirements.txt | ||
RUN apt-get update \ | ||
# dependencies for building Python packages | ||
&& apt-get install -y build-essential \ | ||
# psycopg2 dependencies | ||
&& apt-get install -y libpq-dev \ | ||
# Translations dependencies | ||
&& apt-get install -y gettext \ | ||
&& apt-get install -y libcairo2 libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info \ | ||
# cleaning up unused files | ||
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Adds our application code to the image | ||
COPY . code | ||
WORKDIR code | ||
RUN mkdir -p /usr/src/app | ||
WORKDIR /usr/src/app | ||
|
||
EXPOSE 8000 | ||
COPY ./requirements.txt /requirements.txt | ||
RUN pip install --no-cache-dir -r /requirements.txt \ | ||
&& rm -rf /requirements.txt | ||
|
||
# Run the production server | ||
CMD newrelic-admin run-program gunicorn --bind 0.0.0.0:$PORT --access-logfile - project.wsgi:application | ||
COPY . /usr/src/app | ||
|
||
EXPOSE 80 | ||
|
||
CMD ["sh", "./run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from django.contrib.auth.hashers import make_password | ||
from django.contrib.auth.base_user import BaseUserManager | ||
|
||
|
||
class CustomUserManager(BaseUserManager): | ||
""" | ||
Custom user model managers where email is the unique identifiers | ||
for authentication instead of username | ||
""" | ||
|
||
def create_user(self, email, password, **extra_fields): | ||
if not email: | ||
raise ValueError("The email must be set") | ||
email = self.normalize_email(email) | ||
user = self.model(email=email, **extra_fields) | ||
user.username = email | ||
user.set_password(password) | ||
user.save() | ||
return user | ||
|
||
def create_superuser(self, email, password, **extra_fields): | ||
""" | ||
Create and save a Superuser with the given email and password. | ||
""" | ||
extra_fields.setdefault("is_staff", True) | ||
extra_fields.setdefault("is_superuser", True) | ||
extra_fields.setdefault("is_active", True) | ||
|
||
if extra_fields.get("is_staff") is not True: | ||
raise ValueError("Superuser must have is_staff=True") | ||
if extra_fields.get("is_superuser") is not True: | ||
raise ValueError("Superuser must have is_superuser=True.") | ||
return self.create_user(email, password, **extra_fields) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
python manage.py migrate | ||
python manage.py collectstatic --no-input | ||
python manage.py createsuperuser --no-input | ||
gunicorn project.wsgi --bind=0.0.0.0:$PORT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from storages.backends.s3boto3 import S3Boto3Storage | ||
|
||
|
||
class StaticStorage(S3Boto3Storage): | ||
location = 'static' | ||
default_acl = 'public-read' | ||
|
||
|
||
class PublicMediaStorage(S3Boto3Storage): | ||
location = 'media' | ||
default_acl = 'public-read' | ||
file_overwrite = False |