initial commit

This commit is contained in:
Herculino Trotta
2024-09-26 11:00:40 -03:00
parent 830e821a17
commit 50b0c6ce01
138 changed files with 13566 additions and 46 deletions

View File

@@ -0,0 +1,8 @@
#!/bin/bash
set -o errexit
set -o nounset
rm -f './celerybeat.pid'
exec watchfiles --filter python celery.__main__.main --args '-A WYGIWYH.celery_app beat -l INFO'

View File

@@ -0,0 +1,9 @@
#!/bin/bash
set -o errexit
set -o nounset
exec watchfiles --filter python celery.__main__.main \
--args \
"-A WYGIWYH.celery_app -b \"${CELERY_BROKER_URL}\" flower
--basic_auth=\"${CELERY_FLOWER_USER}:${CELERY_FLOWER_PASSWORD}\""

View File

@@ -0,0 +1,7 @@
#!/bin/bash
set -o errexit
set -o nounset
exec watchfiles --filter python celery.__main__.main --args '-A WYGIWYH.celery_app worker -l INFO'

View File

@@ -0,0 +1,63 @@
# pull official base image
FROM python:3.11.8-slim-buster AS python
LABEL authors="Herculino de Miranda Trotta"
FROM docker.io/python AS python-build-stage
RUN apt update && apt install --no-install-recommends -y \
# dependencies for building Python packages \
build-essential \
# psycopg2 dependencies \
gettext \
libpq-dev
# Requirements are installed here to ensure they will be cached.
COPY ../requirements.txt .
# Create Python Dependency and Sub-Dependency Wheels.
RUN pip wheel --wheel-dir /usr/src/app/wheels \
-r requirements.txt
#FROM node:alpine AS webpack_build
#
#WORKDIR /usr/src/frontend
#
#COPY ../frontend .
#COPY ../app/templates /usr/src/app/templates
#RUN npm install
#RUN npm run build
FROM docker.io/python AS python-run-stage
#COPY --from=webpack_build /usr/src/frontend/build /usr/src/frontend/build
# set work directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
COPY --from=python-build-stage /usr/src/app/wheels /wheels/
RUN apt update && apt install --no-install-recommends -y gettext
RUN pip install --upgrade pip
RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \
&& rm -rf /wheels/
COPY ./docker/dev/django/start /start
RUN sed -i 's/\r$//g' /start
RUN chmod +x /start
COPY ./docker/dev/celery/worker/start /start-celeryworker
RUN sed -i 's/\r$//g' /start-celeryworker
RUN chmod +x /start-celeryworker
COPY ./docker/dev/celery/beat/start /start-celerybeat
RUN sed -i 's/\r$//g' /start-celerybeat
RUN chmod +x /start-celerybeat
COPY ./docker/dev/celery/flower/start /start-flower
RUN sed -i 's/\r$//g' /start-flower
RUN chmod +x /start-flower
# copy project
COPY ./app .

10
docker/dev/django/start Normal file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
python manage.py migrate
python manage.py loaddata ./fixtures/*.json
#python manage.py compilemessages
exec python manage.py runserver 0.0.0.0:8000

View File

@@ -0,0 +1,9 @@
FROM docker.io/node:18-bookworm-slim
WORKDIR /usr/src/frontend
COPY ./frontend/package.json .
RUN npm install --verbose && npm cache clean --force
ENV PATH ./node_modules/.bin/:$PATH

View File

@@ -0,0 +1,8 @@
#!/bin/bash
set -o errexit
set -o nounset
rm -f './celerybeat.pid'
exec watchfiles --filter python celery.__main__.main --args '-A WYGIWYH.celery_app beat -l INFO'

View File

@@ -0,0 +1,9 @@
#!/bin/bash
set -o errexit
set -o nounset
exec watchfiles --filter python celery.__main__.main \
--args \
"-A WYGIWYH.celery_app -b \"${CELERY_BROKER_URL}\" flower
--basic_auth=\"${CELERY_FLOWER_USER}:${CELERY_FLOWER_PASSWORD}\""

View File

@@ -0,0 +1,7 @@
#!/bin/bash
set -o errexit
set -o nounset
exec watchfiles --filter python celery.__main__.main --args '-A WYGIWYH.celery_app worker -l INFO'

View File

@@ -0,0 +1,77 @@
# pull official base image
FROM python:3.11.8-slim-buster AS python
LABEL authors="Herculino de Miranda Trotta"
FROM docker.io/python AS python-build-stage
RUN apt-get update && apt-get install --no-install-recommends -y \
# dependencies for building Python packages
build-essential \
gettext \
# psycopg2 dependencies
libpq-dev
# Requirements are installed here to ensure they will be cached.
COPY ./requirements.txt .
# Create Python Dependency and Sub-Dependency Wheels.
RUN pip wheel --wheel-dir /usr/src/app/wheels \
-r requirements.txt
FROM node:lts-alpine AS webpack_build
WORKDIR /usr/src/frontend
COPY ./frontend .
COPY ./app/templates /usr/src/app/templates
RUN npm config set registry https://registry.npmmirror.com/
RUN npm install --verbose
RUN npm run build
FROM docker.io/python AS python-run-stage
COPY --from=webpack_build /usr/src/frontend/build /usr/src/frontend/build
# set work directory
WORKDIR /usr/src/app
RUN addgroup --system app \
&& adduser --system --ingroup app app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
COPY --from=python-build-stage /usr/src/app/wheels /wheels/
RUN apt update && apt install --no-install-recommends -y gettext
RUN pip install --upgrade pip
RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \
&& rm -rf /wheels/
COPY --chown=app:app ./docker/prod/django/start /start
RUN sed -i 's/\r$//g' /start
RUN chmod +x /start
COPY --chown=app:app ./docker/prod/celery/worker/start /start-celeryworker
RUN sed -i 's/\r$//g' /start-celeryworker
RUN chmod +x /start-celeryworker
COPY --chown=app:app ./docker/prod/celery/beat/start /start-celerybeat
RUN sed -i 's/\r$//g' /start-celerybeat
RUN chmod +x /start-celerybeat
COPY --chown=app:app ./docker/prod/celery/flower/start /start-flower
RUN sed -i 's/\r$//g' /start-flower
RUN chmod +x /start-flower
# copy project
COPY ./app .
# chown all the files to the app user
RUN chown -R app:app /usr/src/app
RUN chown -R app:app /usr/src/frontend
RUN mkdir /temp
RUN chown -R app:app /temp
# change to the app user
USER app

13
docker/prod/django/start Normal file
View File

@@ -0,0 +1,13 @@
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
python manage.py collectstatic --noinput
python manage.py compilemessages
python manage.py migrate
python manage.py loaddata ./fixtures/*.json
exec gunicorn WYGIWYH.wsgi:application --bind 0.0.0.0:8000 --timeout 600