Skip to content

Commit

Permalink
more docker env updates
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Jul 7, 2024
1 parent 52131fa commit 38f95d7
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 21 deletions.
20 changes: 20 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
DEBUG='False'
SECRET_KEY='secret'
DATABASE_PASSWORD='secret'
DATABASE_ROOT_PASSWORD="secret"
EMAIL_USE_TLS='True'
EMAIL_HOST='smtp.gmail.com'
EMAIL_PORT='587'
EMAIL_HOST_USER='[email protected]'
EMAIL_HOST_PASSWORD='your gmail app password, not your gmail password'
DEFAULT_FROM_EMAIL="Notifications <[email protected]>"
SITE_DOMAIN="example.com"
GOOGLE_MEASUREMENT_ID="G-abcde"
GOOGLE_TAG_ID="GTM-abcde"
GOOGLE_MAPS_API_KEY='secret'
ADMIN_EMAIL='[email protected]'
REDIS_PASSWORD='secret'
GOOGLE_ADSENSE_ID='ca-pub-abcde'
RECAPTCHA_PUBLIC_KEY='secret'
RECAPTCHA_PRIVATE_KEY='secret'
GOOGLE_OAUTH_LINK="secret.apps.googleusercontent.com"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ db.sqlite3
set_env.sh
fishauctions/customsettings.py
media/
auctions/templates/ads.txt
auctions/templates/ads.txt
swag/
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ RUN apt-get update && \
# cron setup
COPY crontab /etc/cron.d/django-cron
RUN chmod 0644 /etc/cron.d/django-cron
RUN chmod gu+rw /var/run
RUN chmod gu+s /usr/sbin/cron
RUN crontab /etc/cron.d/django-cron
RUN touch /var/log/cron.log

Expand Down
8 changes: 0 additions & 8 deletions auctions/management/commands/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@ def compare_model_instances(instance1, instance2):
class Command(BaseCommand):
help = 'Just a scratchpad to do things'
def handle(self, *args, **options):
prefsA = UserLabelPrefs.objects.get(user__username='L_Scottgoldie')
prefsB = UserLabelPrefs.objects.get(user__pk=1)
diffs = compare_model_instances(prefsA, prefsB)
for field, (value1, value2) in diffs.items():
print(f"Field '{field}' differs: {value1} != {value2}")



# campaigns = AuctionCampaign.objects.all()
# for campaign in campaigns:
# campaign.update
Expand Down
22 changes: 11 additions & 11 deletions crontab
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# m h dom mon dow command
# Set lots as ended and declare a winner
* * * * * cd /home/user/python/auction_site_2022/ && /home/user/python/auction_site_2022/bin/python /home/user/python/auction_site_2022/fishauctions/manage.py endauctions >> /var/log/cron.log 2>&1
* * * * * /home/app/web/task.sh endauctions

# Send reminder emails about watched items
*/15 * * * * cd /home/user/python/auction_site_2022/ && /home/user/python/auction_site_2022/bin/python /home/user/python/auction_site_2022/fishauctions/manage.py sendnotifications >> /var/log/cron.log 2>&1
*/15 * * * * /home/app/web/task.sh sendnotifications

# welcome and print erminder emails
*/15 * * * * cd /home/user/python/auction_site_2022/ && /home/user/python/auction_site_2022/bin/python /home/user/python/auction_site_2022/fishauctions/manage.py auctiontos_notifications >> /var/log/cron.log 2>&1
*/15 * * * * /home/app/web/task.sh auctiontos_notifications

# Email users about invoices
*/15 * * * * cd /home/user/python/auction_site_2022/ && /home/user/python/auction_site_2022/bin/python /home/user/python/auction_site_2022/fishauctions/manage.py email_invoice >> /var/log/cron.log 2>&1
*/15 * * * * /home/app/web/task.sh email_invoice

# Update leaderboard
* 23 * * * cd /home/user/python/auction_site_2022/ && /home/user/python/auction_site_2022/bin/python /home/user/python/auction_site_2022/fishauctions/manage.py update_breederboard >> /var/log/cron.log 2>&1
* 23 * * * /home/app/web/task.sh update_breederboard

# send email
* * * * * cd /home/user/python/auction_site_2022/ && /home/user/python/auction_site_2022/bin/python /home/user/python/auction_site_2022/fishauctions/manage.py send_queued_mail >> /var/log/cron.log 2>&1
* * * * * /home/app/web/task.sh send_queued_mail

# send auction emails
*/4 * * * * cd /home/user/python/auction_site_2022/ && /home/user/python/auction_site_2022/bin/python /home/user/python/auction_site_2022/fishauctions/manage.py auction_emails >> /var/log/cron.log 2>&1
*/4 * * * * /home/app/web/task.sh auction_emails

# send notifications about unread chats
0 10 * * * cd /home/user/python/auction_site_2022/ && /home/user/python/auction_site_2022/bin/python /home/user/python/auction_site_2022/fishauctions/manage.py email_unseen_chats >> /var/log/cron.log 2>&1
0 10 * * * /home/app/web/task.sh email_unseen_chats

# weekly promo email sent on Wednesday
30 9 * * 3 cd /home/user/python/auction_site_2022/ && /home/user/python/auction_site_2022/bin/python /home/user/python/auction_site_2022/fishauctions/manage.py weekly_promo >> /var/log/cron.log 2>&1
30 9 * * 3 /home/app/web/task.sh weekly_promo

# set user locations
0 0 * * * cd /home/user/python/auction_site_2022/ && /home/user/python/auction_site_2022/bin/python /home/user/python/auction_site_2022/fishauctions/manage.py set_user_location >> /var/log/cron.log 2>&1
0 0 * * * /home/app/web/task.sh set_user_location

# check for duplicate page views
*/15 * * * * cd /home/user/python/auction_site_2022/ && /home/user/python/auction_site_2022/bin/python /home/user/python/auction_site_2022/fishauctions/manage.py remove_duplicate_views >> /var/log/cron.log 2>&1
*/15 * * * * /home/app/web/task.sh remove_duplicate_views
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ python manage.py migrate --no-input
python manage.py collectstatic --no-input

if [ "${DEBUG}" = "False" ]; then
echo Starting fishauctions in productions mode
echo Starting fishauctions in production mode
cron -f & # run cron in the foreground, but & allows the script to continue
exec gunicorn fishauctions.asgi:application -k uvicorn.workers.UvicornWorker -w 8 -b 0.0.0.0:8000
else
Expand Down
14 changes: 14 additions & 0 deletions task.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

if [ $# -eq 0 ]; then
echo "No argument provided, specify which script to run" >> /var/log/cron.log 2>&1
exit 1
fi

if [ -f /home/app/web/.env ]; then
export $(grep -v '^#' /home/app/web/.env | xargs)
else
echo "No .env file found, env will not be set" >> /var/log/cron.log 2>&1
fi

/usr/local/bin/python /home/app/web/manage.py $1 >> /var/log/cron.log 2>&1

0 comments on commit 38f95d7

Please sign in to comment.