-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fix/261-dropdown-menu-exhibition
- Loading branch information
Showing
316 changed files
with
8,979 additions
and
4,656 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Use this file to create a .env with filled variables | ||
# Django Variables | ||
DJANGO_DEBUG=True | ||
DEBUG_TOOLBAR=True | ||
DJANGO_SECRET_KEY=change_me | ||
DJANGO_ADMIN_URL=jandig-admin/ | ||
USE_MINIO=True | ||
USE_GUNICORN=True | ||
|
||
# Sentry Variables | ||
ENABLE_SENTRY=False | ||
SENTRY_DSN= | ||
SENTRY_ENVIRONMENT="local" | ||
HEALTH_CHECK_URL=api/v1/status/ | ||
SENTRY_TRACES_SAMPLE_RATE=0.1 | ||
|
||
## Amazon AWS Variables | ||
AWS_ACCESS_KEY_ID=minio | ||
AWS_SECRET_ACCESS_KEY=minio123 | ||
MINIO_ROOT_USER=minio | ||
MINIO_ROOT_PASSWORD=minio123 | ||
AWS_STORAGE_BUCKET_NAME=jandig-cdn | ||
AWS_S3_REGION_NAME=us-east-2 | ||
AWS_STATIC_LOCATION=static | ||
MINIO_S3_ENDPOINT_URL=http://storage:9000 | ||
MINIO_SITE_REGION=us-east-2 | ||
MINIO_USER_ACCESS_KEY=minio-access-key | ||
MINIO_USER_SECRET_KEY=minio-secret-key | ||
|
||
## Postgres variables | ||
POSTGRES_HOST=postgres | ||
POSTGRES_PORT=5432 | ||
POSTGRES_DB=jandig | ||
POSTGRES_USER=jandig | ||
POSTGRES_PASSWORD=secret | ||
|
||
# Email server variables | ||
SMTP_SERVER=mailpit | ||
SMTP_PORT=1025 | ||
SMTP_USE_TLS=False | ||
SMTP_USE_SSL=False | ||
SMTP_USER= | ||
SMTP_PASSWORD= | ||
SMTP_SENDER_MAIL="[email protected]" | ||
|
||
# Recaptcha | ||
RECAPTCHA_ENABLED=False | ||
RECAPTCHA_PROJECT_ID= | ||
RECAPTCHA_GCLOUD_API_KEY= | ||
RECAPTCHA_SITE_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: CI pipeline | ||
|
||
on: push | ||
|
||
jobs: | ||
linter: | ||
name: run / linter | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code from Github | ||
uses: actions/checkout@v3 | ||
- name: Set up Python 3.13 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.13" | ||
- name: Installing flake8 | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 | ||
- name: Run flake8 linter | ||
run: | | ||
flake8 --max-line-length=200 --exclude=*/migrations src/ | ||
build: | ||
name: run / build | ||
runs-on: ubuntu-latest | ||
needs: linter | ||
steps: | ||
- name: Check out code from Github | ||
uses: actions/checkout@v3 | ||
- name: Build image | ||
run: | | ||
# docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASS | ||
docker build . -t jandigarte/django:$GITHUB_SHA | ||
docker save -o docker_image_$GITHUB_SHA jandigarte/django:$GITHUB_SHA | ||
- name: Caching image | ||
uses: actions/cache@v3 | ||
with: | ||
key: jandigarte | ||
path: docker_image_${{ github.sha }} | ||
|
||
migrations: | ||
name: test / migrations | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Check out code from Github | ||
uses: actions/checkout@v3 | ||
- name: Restoring cached image | ||
uses: actions/cache@v3 | ||
with: | ||
key: jandigarte | ||
path: docker_image_${{ github.sha }} | ||
- name: Running container | ||
env: | ||
IMAGE_NAME: jandigarte/django:${{ github.sha }} | ||
run: | | ||
cp .envs/.example .envs/.env | ||
docker load -i docker_image_$GITHUB_SHA | ||
docker compose -f docker-compose.ci.yml -p jandigarte_$GITHUB_SHA up --no-build -d | ||
- name: Test migrations | ||
run: | | ||
docker exec jandigarte_${{ github.sha }}_django_1 sh -c "\ | ||
poetry run src/manage.py makemigrations --check --dry-run" | ||
test: | ||
name: test / unity | ||
runs-on: ubuntu-latest | ||
needs: build | ||
steps: | ||
- name: Check out code from Github | ||
uses: actions/checkout@v3 | ||
- name: Restoring cached image | ||
uses: actions/cache@v3 | ||
with: | ||
key: jandigarte | ||
path: docker_image_${{ github.sha }} | ||
- name: Running container | ||
env: | ||
IMAGE_NAME: jandigarte/django:${{ github.sha }} | ||
run: | | ||
cp .envs/.example .envs/.env | ||
docker load -i docker_image_$GITHUB_SHA | ||
docker compose -f docker-compose.ci.yml -p jandigarte_$GITHUB_SHA up --no-build -d | ||
- name: Running users tests | ||
run: | | ||
docker exec jandigarte_${{ github.sha }}_django_1 sh -c "\ | ||
poetry run src/manage.py test" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Dependencies pipeline | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'pyproject.toml' | ||
|
||
jobs: | ||
dependencies: | ||
name: test / dependencies | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code from Github | ||
uses: actions/checkout@v3 | ||
- name: Check diff | ||
id: diff_lock | ||
run: | | ||
echo "::set-output name=dependencies::$(git diff --name-only | grep poetry.lock -c)" | ||
- name: Check poetry lock | ||
if: ${{ steps.diff_lock.outputs.dependencies == 0 }} | ||
run: exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Docker pipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
# TODO: Change environment and login envs | ||
jobs: | ||
django: | ||
name: push / django | ||
environment: testes | ||
runs-on: ubuntu-latest | ||
needs: dependencies | ||
steps: | ||
- name: Check out code from Github | ||
uses: actions/checkout@v3 | ||
- name: Build django image | ||
run: | | ||
docker build . -t jandigarte/django:latest | ||
- name: Push django image | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_HUB_USER }} -p ${{ secrets.DOCKER_HUB_PASS }} | ||
docker push jandigarte/django:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"python.testing.pytestArgs": [ | ||
"src", | ||
"--ds=config.test_settings", | ||
], | ||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
FROM python:3.13.0-slim-bookworm | ||
|
||
ENV PATH="$PATH:/home/jandig/.local/bin:/jandig/.venv/bin" \ | ||
TINI_VERSION=v0.19.0 \ | ||
# poetry: | ||
POETRY_NO_INTERACTION=1 \ | ||
POETRY_VIRTUALENVS_CREATE=true \ | ||
POETRY_VIRTUALENVS_IN_PROJECT=true \ | ||
POETRY_VIRTUALENVS_OPTIONS_ALWAYS_COPY=true \ | ||
POETRY_VIRTUALENV_PATH="/jandig/.venv" \ | ||
POETRY_CACHE_DIR='/home/jandig/cache/pypoetry' \ | ||
POETRY_VERSION=1.8.4 | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
gettext \ | ||
docutils-common \ | ||
curl \ | ||
wget | ||
|
||
RUN dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \ | ||
&& wget "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${dpkgArch}" -O /usr/local/bin/tini \ | ||
&& chmod +x /usr/local/bin/tini && tini --version | ||
|
||
|
||
RUN mkdir -p /jandig/src /jandig/locale /jandig/docs /jandig/.venv /jandig/static /jandig/build /home/jandig/cache/pypoetry | ||
|
||
WORKDIR /jandig | ||
|
||
COPY ./pyproject.toml /jandig/pyproject.toml | ||
COPY ./poetry.lock /jandig/poetry.lock | ||
|
||
COPY ./src/ /jandig/src/ | ||
COPY ./docs/ /jandig/docs/ | ||
COPY ./locale/ /jandig/locale/ | ||
COPY ./tasks.py /jandig/tasks.py | ||
COPY ./run.sh /jandig/run.sh | ||
COPY ./etc/ /jandig/etc/ | ||
|
||
|
||
# Create group and user | ||
RUN groupadd -g 1000 jandig && useradd -u 1000 -g 1000 -r -m -d /home/jandig jandig | ||
|
||
# Change ownership of the directories to the new user and group | ||
RUN chown -R jandig:jandig /jandig /home/jandig | ||
RUN chmod 2775 /jandig /home/jandig | ||
|
||
# Switch to the new user | ||
USER jandig | ||
|
||
# Installing `poetry` package manager: | ||
# https://github.com/python-poetry/poetry | ||
RUN curl -sSL https://install.python-poetry.org | python3 - | ||
|
||
RUN find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf | ||
|
||
ENTRYPOINT ["tini", "--"] | ||
|
||
CMD [ "/jandig/run.sh" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,33 @@ | ||
BACKUP_DIR = backup_$(shell date +'%d_%m_%Y-%H_%M_%S') | ||
PASSWORD = | ||
ROOT = | ||
IP = | ||
DESTINATION = | ||
DOMAIN = staging.jandig.app | ||
CERTPATH = /etc/letsencrypt/live/$(DOMAIN) | ||
EMAIL = [email protected] | ||
backup: | ||
#sudo docker-compose -f docker/docker-compose.deploy.yml stop | ||
mkdir $(BACKUP_DIR) | ||
|
||
#sudo cp -r /var/lib/docker/volumes/ $(BACKUP_DIR)/volumes | ||
sudo cp -r ./docker/media/ $(BACKUP_DIR)/media | ||
|
||
sudo chmod 755 $(BACKUP_DIR) | ||
zip -r $(BACKUP_DIR).zip $(BACKUP_DIR) | ||
|
||
sudo cp -r $(BACKUP_DIR).zip ./backups | ||
sudo rm -rf ./$(BACKUP_DIR).zip | ||
sudo rm -rf $(BACKUP_DIR) | ||
#sudo docker-compose -f docker/docker-compose.deploy.yml up | ||
|
||
|
||
|
||
|
||
sshpass -p $(PASSWORD) scp ./backups/backup_$(shell date +'%d_%m_%Y-%H_%M_%S').zip $(ROOT)@$(IP):$(DESTINATION) | ||
echo 'Send via scp' | ||
fake-cert: | ||
mkdir -p $(CERTPATH) | ||
curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot-nginx/certbot_nginx/_internal/tls_configs/options-ssl-nginx.conf > "$(CERTPATH)/../../options-ssl-nginx.conf" | ||
|
||
curl -s https://raw.githubusercontent.com/certbot/certbot/master/certbot/certbot/ssl-dhparams.pem > "$(CERTPATH)/../../ssl-dhparams.pem" | ||
openssl req -x509 -nodes -newkey rsa:1024 -days 1 -keyout '$(CERTPATH)/privkey.pem' -out '$(CERTPATH)/fullchain.pem' -subj '/CN=localhost' | ||
|
||
cert: | ||
rm -Rf /etc/letsencrypt/live/$(DOMAIN) | ||
sudo rm -Rf /etc/letsencrypt/archive/$(DOMAIN) | ||
sudo rm -Rf /etc/letsencrypt/renewal/$(DOMAIN).conf | ||
certbot certonly --webroot -w /var/www/certbot --staging --email $(EMAIL) -d $(DOMAIN) --rsa-key-size 4096 --agree-tos --force-renewal | ||
RUNNING_CONTAINER := $(shell docker compose ps --services --filter "status=running" | grep django ) | ||
|
||
test: | ||
@if [[ -n "${RUNNING_CONTAINER}" ]]; then \ | ||
docker compose exec django poetry run pytest src/core src/users; \ | ||
else \ | ||
docker compose run --rm django poetry run pytest src/core src/users;\ | ||
fi | ||
|
||
test-ui: | ||
docker compose up -d | ||
poetry run pytest src/tests | ||
|
||
lint: | ||
poetry run black --line-length=200 src | ||
poetry run isort src | ||
flake8: | ||
poetry run flake8 --max-line-length=200 --exclude=*/migrations src | ||
|
||
migrations: | ||
poetry run python src/manage.py makemigrations | ||
|
||
migrate: | ||
poetry run python src/manage.py migrate | ||
|
||
gen: | ||
poetry run playwright codegen -b chromium --target python-pytest localhost:8000 | ||
|
||
translate_es: | ||
poetry run inv i18n -l es_ES | ||
|
||
translate_pt: | ||
poetry run inv i18n -l pt_BR |
Oops, something went wrong.