Skip to content

Commit f58207a

Browse files
Merge pull request #8 from samuelveigarangel/issue-2
Cria toda estrutura inicial do projeto
2 parents 8eb0b60 + 4d76038 commit f58207a

File tree

111 files changed

+5364
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+5364
-0
lines changed

.dockerignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Django project
2+
/media/
3+
/static/
4+
*.sqlite3
5+
6+
# Python and others
7+
__pycache__
8+
*.pyc
9+
.DS_Store
10+
*.swp
11+
/venv/
12+
/tmp/
13+
/.vagrant/
14+
/Vagrantfile.local
15+
node_modules/
16+
/npm-debug.log
17+
/.idea/
18+
.vscode
19+
coverage
20+
.python-version
21+
22+
# Distribution / packaging
23+
.Python
24+
env/
25+
build/
26+
develop-eggs/
27+
dist/
28+
downloads/
29+
eggs/
30+
.eggs/
31+
lib/
32+
lib64/
33+
parts/
34+
sdist/
35+
var/
36+
wheels/
37+
*.egg-info/
38+
.installed.cfg
39+
*.egg

.envs/.local/.django

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# General
2+
# ------------------------------------------------------------------------------
3+
USE_DOCKER=yes
4+
IPYTHONDIR=/app/.ipython
5+
# Redis
6+
# ------------------------------------------------------------------------------
7+
REDIS_URL=redis://redis:6379/0
8+
9+
# Celery
10+
# ------------------------------------------------------------------------------
11+
12+
# Flower
13+
CELERY_FLOWER_USER=PhFRdLexbrsBvrrbSXxjcMMOcVOavCrZ
14+
CELERY_FLOWER_PASSWORD=QgScyefPrYhHgO6onW61u0nazc5xdBuP4sM7jMRrBBFuA2RjsFhZLp7xbVYZbrwR
15+
16+
17+
# Timeout fetch_data
18+
# ------------------------------------------------------------------------------
19+
FETCH_DATA_TIMEOUT=2

.envs/.local/.postgres

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# PostgreSQL
2+
# ------------------------------------------------------------------------------
3+
POSTGRES_HOST=postgres
4+
POSTGRES_PORT=5432
5+
POSTGRES_DB=scielo_core
6+
POSTGRES_USER=GVRFlLmcCNfGLhsFvSnCioYOPJPYpyfj
7+
POSTGRES_PASSWORD=BQ4hSUL4rdj5WZLdR8ilDLRQMvCtzo0caMaXDO0olGsmycQjlcZlTVK9DepZR8kk

.envs/.production/.django

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# General
2+
# ------------------------------------------------------------------------------
3+
USE_DOCKER=True
4+
IPYTHONDIR=/app/.ipython
5+
# Redis
6+
# ------------------------------------------------------------------------------
7+
REDIS_URL=redis://redis:6379/0
8+
9+
# Celery
10+
# ------------------------------------------------------------------------------
11+
12+
# Flower
13+
CELERY_FLOWER_USER=PhFRdLexbrsBvrrbSXxjcMMOcVOavCrZ
14+
CELERY_FLOWER_PASSWORD=QgScyefPrYhHgO6onW61u0nazc5xdBuP4sM7jMRrBBFuA2RjsFhZLp7xbVYZbrwR
15+
16+
# Django
17+
# ------------------------------------------------------------------------------
18+
DJANGO_SETTINGS_MODULE=config.settings.production
19+
DJANGO_SECRET_KEY=FMiraeekXCSl3zHfg7D4oHx7ufT46HRnwnsawKgTCC53BYajVkVzb8HhOvBOHakR"
20+
DJANGO_ADMIN_URL=django-admin/
21+
DJANGO_ALLOWED_HOSTS=*
22+
23+
# Sentry
24+
# ------------------------------------------------------------------------------
25+
SENTRY_DSN=

.envs/.production/.postgres

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# PostgreSQL
2+
# ------------------------------------------------------------------------------
3+
POSTGRES_HOST=postgres
4+
POSTGRES_PORT=5432
5+
POSTGRES_DB=core
6+
POSTGRES_USER=GVRFlLmcCNfGLhsFvSnCioYOPJPYpyfj
7+
POSTGRES_PASSWORD=BQ4hSUL4rdj5WZLdR8ilDLRQMvCtzo0caMaXDO0olGsmycQjlcZlTVK9DepZR8kk

Dockerfile

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Use an official Python runtime based on Debian 12 "bookworm" as a parent image.
2+
FROM python:3.12-slim-bookworm
3+
4+
# Add user that will be used in the container.
5+
RUN useradd wagtail
6+
7+
# Port used by this container to serve HTTP.
8+
EXPOSE 8000
9+
10+
# Set environment variables.
11+
# 1. Force Python stdout and stderr streams to be unbuffered.
12+
# 2. Set PORT variable that is used by Gunicorn. This should match "EXPOSE"
13+
# command.
14+
ENV PYTHONUNBUFFERED=1 \
15+
PORT=8000
16+
17+
# Install system packages required by Wagtail and Django.
18+
RUN apt-get update --yes --quiet && apt-get install --yes --quiet --no-install-recommends \
19+
build-essential \
20+
libpq-dev \
21+
libmariadb-dev \
22+
libjpeg62-turbo-dev \
23+
zlib1g-dev \
24+
libwebp-dev \
25+
&& rm -rf /var/lib/apt/lists/*
26+
27+
# Install the application server.
28+
RUN pip install "gunicorn==20.0.4"
29+
30+
# Install the project requirements.
31+
COPY requirements.txt /
32+
RUN pip install -r /requirements.txt
33+
34+
# Use /app folder as a directory where the source code is stored.
35+
WORKDIR /app
36+
37+
# Set this directory to be owned by the "wagtail" user. This Wagtail project
38+
# uses SQLite, the folder needs to be owned by the user that
39+
# will be writing to the database file.
40+
RUN chown wagtail:wagtail /app
41+
42+
# Copy the source code of the project into the container.
43+
COPY --chown=wagtail:wagtail . .
44+
45+
# Use user "wagtail" to run the build commands below and the server itself.
46+
USER wagtail
47+
48+
# Collect static files.
49+
RUN python manage.py collectstatic --noinput --clear
50+
51+
# Runtime command that executes when "docker run" is called, it does the
52+
# following:
53+
# 1. Migrate the database.
54+
# 2. Start the application server.
55+
# WARNING:
56+
# Migrating database at the same time as starting the server IS NOT THE BEST
57+
# PRACTICE. The database should be migrated manually or using the release
58+
# phase facilities of your hosting platform. This is used only so the
59+
# Wagtail instance can be started with a simple "docker run" command.
60+
CMD set -xe; python manage.py migrate --noinput; gunicorn markapi.wsgi:application

compose/local/django/Dockerfile

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
ARG PYTHON_VERSION=3.11-bullseye
2+
3+
# define an alias for the specfic python version used in this file.
4+
FROM python:${PYTHON_VERSION} AS python
5+
6+
# Python build stage
7+
FROM python AS python-build-stage
8+
9+
ARG BUILD_ENVIRONMENT=local
10+
11+
# Install apt packages
12+
RUN apt-get update && apt-get install --no-install-recommends -y \
13+
# dependencies for building Python packages
14+
build-essential \
15+
git \
16+
# psycopg2 dependencies
17+
libpq-dev
18+
19+
# Requirements are installed here to ensure they will be cached.
20+
COPY ./requirements .
21+
22+
# Update pip
23+
RUN python -m pip install --upgrade pip
24+
25+
# Create Python Dependency and Sub-Dependency Wheels.
26+
RUN pip wheel --wheel-dir /usr/src/app/wheels \
27+
-r ${BUILD_ENVIRONMENT}.txt
28+
29+
30+
# Python 'run' stage
31+
FROM python AS python-run-stage
32+
33+
ARG BUILD_ENVIRONMENT=local
34+
ARG APP_HOME=/app
35+
36+
ENV PYTHONUNBUFFERED 1
37+
ENV PYTHONDONTWRITEBYTECODE 1
38+
ENV BUILD_ENV ${BUILD_ENVIRONMENT}
39+
40+
WORKDIR ${APP_HOME}
41+
42+
# Install required system dependencies
43+
RUN apt-get update && apt-get install --no-install-recommends -y \
44+
# psycopg2 dependencies
45+
libpq-dev \
46+
# Translations dependencies
47+
gettext \
48+
# cleaning up unused files
49+
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
50+
&& rm -rf /var/lib/apt/lists/*
51+
52+
# All absolute dir copies ignore workdir instruction. All relative dir copies are wrt to the workdir instruction
53+
# copy python dependency wheels from python-build-stage
54+
COPY --from=python-build-stage /usr/src/app/wheels /wheels/
55+
56+
# use wheels to install python dependencies
57+
RUN pip install --no-cache-dir --no-index --find-links=/wheels/ /wheels/* \
58+
&& rm -rf /wheels/
59+
60+
COPY ./compose/production/django/entrypoint /entrypoint
61+
RUN sed -i 's/\r$//g' /entrypoint
62+
RUN chmod +x /entrypoint
63+
64+
COPY ./compose/local/django/start /start
65+
RUN sed -i 's/\r$//g' /start
66+
RUN chmod +x /start
67+
68+
69+
COPY ./compose/local/django/celery/worker/start /start-celeryworker
70+
RUN sed -i 's/\r$//g' /start-celeryworker
71+
RUN chmod +x /start-celeryworker
72+
73+
COPY ./compose/local/django/celery/beat/start /start-celerybeat
74+
RUN sed -i 's/\r$//g' /start-celerybeat
75+
RUN chmod +x /start-celerybeat
76+
77+
COPY ./compose/local/django/celery/flower/start /start-flower
78+
RUN sed -i 's/\r$//g' /start-flower
79+
RUN chmod +x /start-flower
80+
81+
82+
# copy application code to WORKDIR
83+
COPY . ${APP_HOME}
84+
85+
ENTRYPOINT ["/entrypoint"]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set -o nounset
5+
6+
7+
rm -f './celerybeat.pid'
8+
celery -A config.celery_app beat -l INFO
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set -o nounset
5+
6+
7+
celery \
8+
-A config.celery_app \
9+
-b "${CELERY_BROKER_URL}" \
10+
flower \
11+
--basic_auth="${CELERY_FLOWER_USER}:${CELERY_FLOWER_PASSWORD}"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
set -o nounset
5+
6+
7+
watchgod celery.__main__.main --args -A config.celery_app worker -l INFO

0 commit comments

Comments
 (0)