we are so ready
This commit is contained in:
parent
ef004ded24
commit
39f343d6bc
3
.gitignore
vendored
3
.gitignore
vendored
@ -4,4 +4,5 @@ venv
|
||||
.env
|
||||
*.sqlite3
|
||||
*.db
|
||||
docker-compose.yml
|
||||
docker-compose.yml
|
||||
.data
|
||||
4
app/.dockerignore
Normal file
4
app/.dockerignore
Normal file
@ -0,0 +1,4 @@
|
||||
*.db
|
||||
*.sqlite3
|
||||
reload.bat
|
||||
readme.md
|
||||
@ -1,25 +1,3 @@
|
||||
# https://testdriven.io/blog/dockerizing-django-with-postgres-gunicorn-and-nginx/
|
||||
|
||||
FROM python:3.13.2-slim-bullseye AS builder
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
PIP_NO_CACHE_DIR=1
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y --no-install-recommends gcc && \
|
||||
pip install --upgrade pip && \
|
||||
pip install flake8==6.0.0
|
||||
|
||||
COPY . /usr/src/app/
|
||||
# RUN flake8 --ignore=E501,F401 .
|
||||
|
||||
COPY ./requirements.txt .
|
||||
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/app/wheels -r requirements.txt
|
||||
|
||||
|
||||
FROM python:3.13.2-alpine3.21
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
@ -31,22 +9,22 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
RUN mkdir -p $HOME && \
|
||||
mkdir $APP_HOME && \
|
||||
addgroup --system app && \
|
||||
adduser --system -G app app
|
||||
adduser --system -G app app && \
|
||||
apk update && \
|
||||
apk add --no-cache netcat-openbsd
|
||||
|
||||
WORKDIR $APP_HOME
|
||||
|
||||
RUN apk update && \
|
||||
apk add --no-cache netcat-openbsd
|
||||
COPY --from=builder /usr/src/app/wheels /wheels
|
||||
COPY --from=builder /usr/src/app/requirements.txt .
|
||||
RUN
|
||||
COPY ./requirements.txt $APP_HOME
|
||||
RUN pip install --upgrade pip && \
|
||||
pip install --no-cache /wheels/*
|
||||
pip install -r requirements.txt
|
||||
|
||||
COPY . $APP_HOME
|
||||
RUN sed -i 's/\r$//g' $APP_HOME/entrypoint.sh && \
|
||||
chmod +x $APP_HOME/entrypoint.sh
|
||||
|
||||
RUN chown -R app:app $APP_HOME
|
||||
RUN sed -i 's/\r$//g' $APP_HOME/entrypoint.sh && \
|
||||
chmod +x $APP_HOME/entrypoint.sh && \
|
||||
chown -R app:app $APP_HOME
|
||||
|
||||
USER app
|
||||
|
||||
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
echo "Waiting for postgres..."
|
||||
|
||||
while ! nc -z $SQL_HOST $SQL_PORT; do
|
||||
sleep 0.1
|
||||
done
|
||||
#while ! nc -z $SQL_HOST $SQL_PORT; do
|
||||
# sleep 0.1
|
||||
#done
|
||||
|
||||
echo "PostgreSQL started"
|
||||
|
||||
|
||||
@ -6,4 +6,5 @@ tqdm==4.67.1
|
||||
Pillow==11.*
|
||||
django-resized==1.0.3
|
||||
django-cleanup==9.0.0
|
||||
psycopg2-binary==2.9.10
|
||||
psycopg2-binary==2.9.10
|
||||
gunicorn
|
||||
@ -140,6 +140,7 @@ USE_TZ = True
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/3.2/howto/static-files/
|
||||
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, "static")
|
||||
STATIC_URL = "/static/"
|
||||
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
|
||||
|
||||
@ -25,16 +25,14 @@ class BloonsaUtil:
|
||||
if not request.user.is_authenticated:
|
||||
return
|
||||
if hasattr(request.user, "player"):
|
||||
# TODO Optimize this by only doing it on register
|
||||
if not hasattr(request.user.player, "bloonsa_config"):
|
||||
bloonsa_config = Config(player=request.user.player)
|
||||
bloonsa_config.save()
|
||||
return request.user.player
|
||||
ip = self.get_ip(request=request)
|
||||
player = Player(user=request.user,
|
||||
creation_ip=ip,
|
||||
latest_ip=ip)
|
||||
player.save()
|
||||
bloonsa_config = Config(player=player)
|
||||
bloonsa_config.save()
|
||||
return player
|
||||
|
||||
# Update activity timestamp and IP
|
||||
|
||||
@ -10,7 +10,7 @@ services:
|
||||
- -c
|
||||
- |
|
||||
python manage.py collectstatic --noinput
|
||||
gunicorn --chdir /app --bind :80 --workers 3 Settings.wsgi:application
|
||||
gunicorn --chdir /app --bind :80 --workers 3 settings.wsgi:application
|
||||
environment:
|
||||
- DJANGO_SECRET_KEY
|
||||
- DJANGO_ALLOWED_HOSTS
|
||||
@ -18,6 +18,8 @@ services:
|
||||
networks:
|
||||
- nginx_private
|
||||
- bloonsworld
|
||||
depends_on:
|
||||
- bloonsworld-db
|
||||
restart: unless-stopped
|
||||
|
||||
bloonsworld-db:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user