Skip to content

Commit

Permalink
Merge branch 'develop' into fix/261-dropdown-menu-exhibition
Browse files Browse the repository at this point in the history
  • Loading branch information
pablodiegoss committed Jan 7, 2025
2 parents 36053f1 + 859cff2 commit c0acbe6
Show file tree
Hide file tree
Showing 316 changed files with 8,979 additions and 4,656 deletions.
50 changes: 50 additions & 0 deletions .envs/.example
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=
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Repository Policy
All contributions to ARte must be tracked by an issue and at least one pull request. To start working on an issue you must fork ARte repository, create or pick an issue. Also check that there is no issue that already adheres to what you intend to post. To create your branch, follow the pattern: `feature/issueID-issue-title`. When you have did your first commit on your fork you have to create a pull request to ARte devel branch so we can see your work in progress. The pull request name must follow this pattern: `{STATE} {ISSUE NUMBER} - {ISSUE NAME}`. Where {STATE} is the state of the pull request, all pull requests must be created with [WIP] tag and when you think you resolved the issue change to [REVIEW]. Example of pull request name: [WIP] 435 - Refactor create method.
All contributions to ARte must be tracked by an issue and at least one pull request. To start working on an issue you must fork ARte repository and create or pick an issue. You should also check that there are no issues that already adheres to what you intend to post. To create your branch, follow the pattern: `feature/issueID-issue-title`. When you have done your first commit on your fork you have to create a pull request to ARte devel branch so we can see your work in progress. The pull request name must follow this pattern: `{STATE} {ISSUE NUMBER} - {ISSUE NAME}`, where {STATE} is the state of the pull request. All pull requests must be created with [WIP] tag, and when you think you resolved the issue, change to [REVIEW]. Example of pull request name: [WIP] 435 - Refactor create method.

## Coding Style
Make sure you are following our code style when submiting a pull request, following the style you make the process of reviewing your pull request better.
Expand Down
88 changes: 88 additions & 0 deletions .github/workflows/ci.yml
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"
21 changes: 21 additions & 0 deletions .github/workflows/dependencies.yml
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
24 changes: 24 additions & 0 deletions .github/workflows/push.yml
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
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
src/ARte/config/__pycache__/
*.pyc

##vscode
\.vscode/

##sqlite
*.sqlite3

build/
static/
media/
src/data/certbot/
docker/node_modules/
node_modules/
Expand All @@ -25,4 +24,4 @@ docker/media/
*.mo
*.po~

src/.envs/.env
*/**/.env
6 changes: 3 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ stages:
- docker:dind
script:
- docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASS
- docker build . -f docker/Dockerfile -t jandigarte/django:$DOCKER_TAG --cache-from jandigarte/django:$DOCKER_TAG
- docker build . -t jandigarte/django:$DOCKER_TAG --cache-from jandigarte/django:$DOCKER_TAG
- docker push jandigarte/django:$DOCKER_TAG
tags:
- docker
- gitlab-org-docker

build develop:
extends: .build
Expand All @@ -32,7 +32,7 @@ build tag:
environment: production
script:
- docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASS
- "docker build . -f docker/Dockerfile
- "docker build .
-t jandigarte/django:$CI_COMMIT_TAG
-t jandigarte/django:$DOCKER_TAG
-t jandigarte/django:latest"
Expand Down
2 changes: 2 additions & 0 deletions .venv/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
8 changes: 8 additions & 0 deletions .vscode/settings.json
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
}
60 changes: 60 additions & 0 deletions Dockerfile
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" ]
73 changes: 33 additions & 40 deletions Makefile
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
Loading

0 comments on commit c0acbe6

Please sign in to comment.