Skip to content

Commit

Permalink
add docker
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Jul 5, 2024
1 parent 6cbefbc commit 825d29e
Show file tree
Hide file tree
Showing 229 changed files with 681 additions and 43,687 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.pyc
.env
db.sqlite3
set_env.sh
fishauctions/customsettings.py
Expand Down
90 changes: 90 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
###########
# BUILDER #
###########

# pull official base image
FROM python:3.11.4-slim-buster as builder

# set work directory
WORKDIR /usr/src/app

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# install system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
pkg-config \
default-libmysqlclient-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN pip install --upgrade pip pip-tools
COPY . /usr/src/app/

# generate an updated requirements.txt file with the latest versions of all packages
#RUN pip-compile requirements.in --upgrade # fixme

# install python dependencies
# COPY ./requirements.txt . # no need to copy this, we just generated it
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt


#########
# FINAL #
#########

# pull official base image
FROM python:3.11.4-slim-buster

# create directory for the app user
RUN mkdir -p /home/app

# create the app user
RUN addgroup --system app && adduser --system --group app

# create the appropriate directories
ENV APP_HOME=/home/app/web
RUN mkdir /home/user
RUN mkdir $APP_HOME
RUN mkdir $APP_HOME/staticfiles
RUN mkdir $APP_HOME/media

WORKDIR $APP_HOME

# install dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
netcat \
build-essential \
pkg-config \
default-libmysqlclient-dev \
cron && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# cron setup
COPY crontab /etc/cron.d/django-cron
RUN chmod 0644 /etc/cron.d/django-cron
RUN crontab /etc/cron.d/django-cron
RUN touch /var/log/cron.log

COPY --from=builder /usr/src/app/wheels /wheels
COPY --from=builder /usr/src/app/requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache /wheels/*
RUN pip install mysql-connector-python

COPY . $APP_HOME

# chown all the files to the app user
RUN chown -R app:app $APP_HOME
RUN chown -R app:app /home/user
RUN chown -R app:app /var/log/
USER app

EXPOSE 8000

ENTRYPOINT ["sh", "./entrypoint.sh"]
9 changes: 5 additions & 4 deletions auctions/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ class Meta:
'lot_submission_end_date', 'sealed_bid','use_categories', 'promote_this_auction', 'max_lots_per_user', 'allow_additional_lots_as_donation',
'email_users_when_invoices_ready', 'pre_register_lot_discount_percent', 'only_approved_sellers',
'invoice_payment_instructions', 'minimum_bid', 'winning_bid_percent_to_club_for_club_members', 'lot_entry_fee_for_club_members', 'require_phone_number',
'reserve_price', 'buy_now', 'tax',
'reserve_price', 'buy_now', 'tax', 'allow_bidding_on_lots',
]
widgets = {
'date_start': DateTimePickerInput(),
Expand All @@ -1204,13 +1204,14 @@ def __init__(self, *args, **kwargs):
#self.fields['notes'].help_text = "Foo"
if self.instance.is_online:
self.fields['lot_submission_end_date'].help_text = "This should be 1-24 hours before the end of your auction"
#self.fields['allow_bidding_on_lots'].help_text = "Leave this checked or people won't be able to bid!"
self.fields['allow_bidding_on_lots'].help_text = "Leave this checked or people won't be able to bid!"
self.fields['allow_bidding_on_lots'].widget=forms.HiddenInput()
#self.fields['pre_register_lot_entry_fee_discount'].widget=forms.HiddenInput()
self.fields['pre_register_lot_discount_percent'].widget=forms.HiddenInput()
#self.fields['set_lot_winners_url'].widget=forms.HiddenInput()
else:
self.fields['unsold_lot_fee'].widget=forms.HiddenInput()
#self.fields['allow_bidding_on_lots'].help_text = "Check to allow people to place bids on this website."
self.fields['allow_bidding_on_lots'].help_text = "Allow people to place bids online. You should probably leave this unchecked."
self.fields['date_end'].help_text = "You should probably leave this blank so that you can manually set winners. This field has been indefinitely set to hidden - see https://github.com/iragm/fishauctions/issues/116"
self.fields['date_end'].widget=forms.HiddenInput()
self.fields['lot_submission_end_date'].help_text = 'This should probably be before bidding starts. Admins (you) can add more lots at any time, this only restricts users.'
Expand Down Expand Up @@ -1283,7 +1284,7 @@ def __init__(self, *args, **kwargs):
Div('max_lots_per_user', css_class='col-md-3',),
Div('allow_additional_lots_as_donation', css_class='col-md-3',),
Div('only_approved_sellers',css_class='col-md-3',),
#Div('allow_bidding_on_lots', css_class='col-md-3',),
Div('allow_bidding_on_lots', css_class='col-md-3',),
css_class='row',
),

Expand Down
85 changes: 0 additions & 85 deletions auctions/management/commands/invoice.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.0.6 on 2024-06-29 22:53

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('auctions', '0135_lot_partial_refund_percent'),
]

operations = [
migrations.AlterField(
model_name='lot',
name='banned',
field=models.BooleanField(blank=True, default=False, help_text="This lot will be hidden from views, and users won't be able to bid on it. Removed lots are not charged in invoices.", verbose_name='Removed'),
),
migrations.AlterField(
model_name='lot',
name='partial_refund_percent',
field=models.IntegerField(blank=True, default=0, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)]),
),
]
13 changes: 8 additions & 5 deletions auctions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3316,7 +3316,9 @@ class LotImage(models.Model):
lot_number = models.ForeignKey(Lot, on_delete=models.CASCADE)
caption = models.CharField(max_length=60, blank=True, null=True)
caption.help_text = "Optional"
image = ThumbnailerImageField(upload_to='images/', blank=False, null=False)
image = ThumbnailerImageField(upload_to='images/', blank=False, null=False,
# see https://github.com/iragm/fishauctions/issues/161
)
image.help_text = "Select an image to upload"
image_source = models.CharField(
max_length=20,
Expand Down Expand Up @@ -3389,17 +3391,18 @@ def on_save_auction(sender, instance, **kwargs):
if instance.is_online:
if instance.lot_submission_end_date > instance.date_end:
instance.lot_submission_end_date = instance.date_end
else:
if instance.lot_submission_end_date > instance.date_start:
instance.lot_submission_end_date = instance.date_start
#else:
#if instance.lot_submission_end_date > instance.date_start:
# instance.lot_submission_end_date = instance.date_start
if instance.lot_submission_start_date > instance.date_start:
instance.lot_submission_start_date = instance.date_start
# I don't see a problem submitting lots after the auction has started,
# or any need to restrict when people add lots to an in-person auction
# So I am not putting any new validation checks here
# OK, the above comment was not correct, this caused confusion. A couple checks have been added.
# Admins can always override those, and they seem to be adding most of the lots for in person stuff anyway.

# OK, third time's the charm, leave the lines above commented out

# if this is an existing auction
if instance.pk:
#print('updating date end on lots because this is an existing auction')
Expand Down
Binary file removed auctions/static (copy)/android-chrome-192x192.png
Binary file not shown.
Binary file removed auctions/static (copy)/android-chrome-512x512.png
Binary file not shown.
Binary file removed auctions/static (copy)/apple-touch-icon.png
Binary file not shown.
Binary file removed auctions/static (copy)/cracked_tank.jpg
Binary file not shown.
51 changes: 0 additions & 51 deletions auctions/static (copy)/css/auction_site.css

This file was deleted.

12 changes: 0 additions & 12 deletions auctions/static (copy)/css/bootstrap.min.css

This file was deleted.

12 changes: 0 additions & 12 deletions auctions/static (copy)/css/c.min.css

This file was deleted.

12 changes: 0 additions & 12 deletions auctions/static (copy)/css/light.min.css

This file was deleted.

Loading

0 comments on commit 825d29e

Please sign in to comment.