Compare commits

...

8 Commits

Author SHA1 Message Date
d854c2813e fix: replace .env to .env.development 2026-06-19 12:32:16 -05:00
5ac4ef2029 feat: update submodules 2026-06-19 12:14:36 -05:00
d0309fdfc1 chore: Add Develop to environment variables for test 2026-06-19 12:11:29 -05:00
f4f9ee4d22 submodules: update version 2026-06-18 22:31:29 -05:00
24d44e0b4a fix: Test Environment 2026-06-18 22:30:15 -05:00
af0b47e2d1 chore: Update dependencies 2026-06-18 18:46:24 -05:00
b32114f883 refactor: System Deploy 2026-06-18 18:17:39 -05:00
ad8334d11c refactor: Deploy System 2026-06-18 17:43:49 -05:00
29 changed files with 310 additions and 206 deletions

View File

@@ -6,4 +6,3 @@ honcho==2.0.0
pudb==2025.1
urwid==3.0.2
freezegun==1.5.1
psycopg2==2.9.10

35
.env.development.example Normal file
View File

@@ -0,0 +1,35 @@
# version Trytond server example 6.0
TRYTOND_VERSION=7.6
TRYTON_ADMIN_PASS=admin
TRYTON_ADMIN_EMAIL=admin@gmail.co
TRYTONADMINPASS=admin
TRYTONPASSFILE=/etc/trytond_admin_pass.conf
SLEEP_TRYTOND_ADMIN=5
# TRYTOND operation mode
TRYTON_PORT_LIVE=18021
PUDB_PORT_LIVE=8085
PUDB_PORT=8095
WORKER=True
# Facho
FACHO=True
FACHO_BRANCH=MigrationPython312Test
# If the module repository is private
GITEA_USER=USER
GITEA_PASSWORD=PASSWORD
GITEA_ACCESS_TOKEN=TOKEN
GITEA_DOMAIN=gitea.domain.org
# Database configuration
DB_HOSTNAME=db
DB_PASSWORD=SUp3r-pass*DB
POSTGRES_DB=tryton
POSTGRES_USER=postgres
POSTGRES_PASSWORD=SUp3r-pass*DB

51
.env.production.example Normal file
View File

@@ -0,0 +1,51 @@
# version Trytond server example 6.0
TRYTOND_VERSION=7.6
TRYTON_ADMIN_PASS=admin
TRYTON_ADMIN_EMAIL=admin@gmail.co
TRYTONADMINPASS=admin
TRYTONPASSFILE=/etc/trytond_admin_pass.conf
SLEEP_TRYTOND_ADMIN=5
# TRYTOND operation mode
TRYTON_PORT=8000
DEVELOP=False
WORKER=True
# Facho
FACHO=True
FACHO_BRANCH=MigrationPython312Test
# if the module repository is private
GITEA_USER=user
GITEA_PASSWORD=password
GITEA_ACCESS_TOKEN=TOKEN
GITEA_DOMAIN=gitea.domain.org
# Database configuration
DB_HOSTNAME=db
DB_PASSWORD=SUp3r-pass*DB
POSTGRES_DB=tryton
POSTGRES_USER=postgres
POSTGRES_PASSWORD=SUp3r-pass*DB
# SMTP This value is True or False
SMTP=False
SMTP_TYPE=smtps+ssl
SMTP_USER=email@example.com
SMTP_PASSWORD=PASSWORD
SMTP_DOMAIN=mail.example.org
SMTP_PORT=465
SMTP_FROM="NAME_FROM <email@example.com>"
SMTP_EMAIL=email@example.org
# NGINX
SERVER_NAME=localhost.example
NGINX_PORT=10000
VARIABLE=$

View File

@@ -1,38 +0,0 @@
# TRYTOND operation mode
DEVELOP=False
WORKER=True
# Develop mode
PUDB_PORT=8025
# TRYTOND information
TRYTOND_VERSION=7.6
TRYTOND_PORT_LIVE=8090
TRYTON_ADMIN_EMAIL=admin@admin.co
TRYTON_ADMIN_PASSWORD=s0p0rt3f1n4l*
TRYTONPASSFILE=/etc/trytond_admin_pass.conf
DB_HOSTNAME=db
POSTGRES_DB=tryton
POSTGRES_USER=tryton
POSTGRES_PASSWORD=SUp3r-pass*DB
# Email user admin
EMAIL=domain@domain.com
SLEEP_TRYTOND_ADMIN=15
# SMTP
SMTP="True"
SMTP_TYPE="smtps+ssl"
SMTP_USER="user"
SMTP_PASSWORD="passsword"
SMTP_DOMAIN="domain.com"
SMTP_PORT="465"
SMTP_FROM="Company CO"
SMTP_EMAIL="domain@domain.com"
# NGINX
SERVER_NAME=tryton.domain.com
NGINX_PORT=10000
VARIABLE=$

2
.gitignore vendored
View File

@@ -111,6 +111,8 @@ celerybeat.pid
# Environments
.env
.env.development
.env.production
.venv
env/
venv/

View File

@@ -1,5 +1,5 @@
# TOMADO DE: https://hg.tryton.org/tryton-docker/file/tip/6.6/Dockerfile
FROM node as builder-node
FROM node AS builder-node
ARG TRYTOND_VERSION

View File

@@ -20,7 +20,6 @@ FROM tryton/tryton:$TRYTOND_VERSION
LABEL org.label-schema.version="$TRYTOND_VERSION"
ARG TRYTOND_VERSION
ARG DEVELOP
ARG WORKER
USER root
@@ -38,20 +37,19 @@ RUN echo "Install modules non official"
COPY trytond.conf /etc/trytond.conf
COPY trytond_worker.conf /etc/trytond_worker.conf
COPY gunicorn.conf.py /etc/gunicorn.conf.py
COPY requirements.txt /opt
RUN pip install --break-system-packages -r /opt/requirements.txt
COPY start.sh /opt
COPY trytond_logging.conf /etc/trytond_logging.conf
COPY trytond_cron_logging.conf /etc/trytond_cron_logging.conf
COPY trytond_worker_logging.conf /etc/trytond_worker_logging.conf
COPY common_password.txt /etc/common_password.txt
COPY start.sh /opt
COPY requirements.txt /opt
RUN pip install --break-system-packages -r /opt/requirements.txt
COPY modules /app/modules
COPY install_modules.sh /app/install_modules.sh
COPY ./prod/install_modules.sh /app/install_modules.sh
RUN chmod +x /app/install_modules.sh && /bin/bash /app/install_modules.sh
RUN rm -rf /var/lib/trytond/www

View File

@@ -1,7 +1,14 @@
require 'yaml'
require 'digest'
DOCKER_COMPOSE='compose.test.yml'
DOCKER_COMPOSE_TEST='docker-compose.test.yaml'
ENV_FILE_DEV='.env.development'
DOCKER_COMPOSE_LIVE='docker-compose.live.yaml'
ENV_FILE_LIVE='.env.development'
DOCKER_COMPOSE_DEPLOY='docker-compose.prod.yaml'
ENV_FILE_DEPLOY='.env.production'
desc 'iniciar entorno'
task :up do
@@ -21,7 +28,6 @@ end
desc 'iterar'
task :tdd, [:name] do |_, args|
refresh_cache
test_dir = ''
if args.name
@@ -30,9 +36,8 @@ task :tdd, [:name] do |_, args|
compose('exec', 'test.dev', "bash -c 'cd #{test_dir}/tests && python3 -m unittest'")
else
compose('exec', 'test.dev', "bash -c 'cd modules && flake8 *'")
compose('exec', 'test.dev', "bash -c 'python -m unittest discover -s modules'")
compose('exec', 'test.dev', "bash -c 'python3 -m unittest discover -s modules'")
end
end
desc 'detener entorno'
@@ -45,32 +50,32 @@ namespace :live do
desc 'iniciar entorno'
task :up do
compose('up', '--build', '-d', compose: 'compose.live.yml')
compose('up', '--build', '-d', env_file: ENV_FILE_LIVE, compose: DOCKER_COMPOSE_LIVE)
end
desc 'monitorear salida'
task :tail do
compose('logs', '-f', 'live', '-n', '50', compose: 'compose.live.yml')
compose('logs', '-f', 'live', '-n', '50', env_file: ENV_FILE_LIVE, compose: DOCKER_COMPOSE_LIVE)
end
desc 'detener entorno'
task :down do
compose('down', compose: 'compose.live.yml')
compose('down', env_file: ENV_FILE_LIVE, compose: DOCKER_COMPOSE_LIVE)
end
desc 'eliminar entorno'
task :del do
compose('down', '-v', '--rmi', 'all', compose: 'compose.live.yml')
compose('down', '-v', '--rmi', 'all', env_file: ENV_FILE_LIVE, compose: DOCKER_COMPOSE_LIVE)
end
desc 'detener entorno'
task :stop do
compose('stop', compose: 'compose.live.yml')
compose('stop', env_file: ENV_FILE_LIVE, compose: DOCKER_COMPOSE_LIVE)
end
desc 'reiniciar entorno'
task :restart do
compose('restart', compose: 'compose.live.yml')
compose('restart', env_file: ENV_FILE_LIVE, compose: DOCKER_COMPOSE_LIVE)
end
desc 'terminal'
@@ -80,25 +85,85 @@ namespace :live do
desc 'monitorear salida'
task :tail_end do
compose('logs', '-f', '-n 50', 'live', compose: 'compose.live.yml')
compose('logs', '-f', '-n 50', 'live', env_file: ENV_FILE_LIVE, compose: DOCKER_COMPOSE_LIVE)
end
desc 'populate data'
task :populate, [:database] do |_, args|
if args.database
compose('stop', "live", compose: "compose.live.yml")
compose('stop', "live", env_file: ENV_FILE_DEV, compose: DOCKER_COMPOSE_LIVE)
compose('exec', '-it', '--user', 'postgres', 'db', "bash -c 'dropdb -U tryton #{args.database}'")
compose('exec', '-it', '--user', 'postgres', 'db', "bash -c 'createdb -U tryton #{args.database}'")
compose('restart', "live", compose: "compose.live.yml")
compose('restart', "live", env_file: ENV_FILE_DEV, compose: DOCKER_COMPOSE_LIVE)
sleep(40)
compose('exec', 'live', "bash -c 'python3 demo/populate_scripts/__main__.py -c .dev/trytond.cfg -d #{args.database}'")
compose('restart', 'live', compose: "compose.live.yml")
compose('restart', 'live', env_file: ENV_FILE_DEV, compose: DOCKER_COMPOSE_LIVE)
else
puts "Falta el nombre de la base de datos"
end
end
end
desc 'produccion'
namespace :deploy do
desc 'iniciar entorno'
task :up do
compose('up', '--build', '-d', env_file: ENV_FILE_DEPLOY, compose: DOCKER_COMPOSE_DEPLOY)
end
desc 'monitorear salida'
task :tail do
compose('logs', env_file: ENV_FILE_DEPLOY, compose: DOCKER_COMPOSE_DEPLOY)
end
desc 'detener entorno'
task :down do
compose('down', env_file: ENV_FILE_DEPLOY, compose: DOCKER_COMPOSE_DEPLOY)
end
desc 'eliminar entorno'
task :del do
compose('down', '-v', '--rmi', 'all', env_file: ENV_FILE_DEPLOY ,compose: DOCKER_COMPOSE_DEPLOY)
end
desc 'reiniciar entorno'
task :restart do
compose('restart', env_file: ENV_FILE_DEPLOY, compose: DOCKER_COMPOSE_DEPLOY)
end
desc 'terminal-tryton'
task :sh_tryton do
compose('exec', '--user', 'root', 'tryton', '/entrypoint.sh', 'bash', compose: DOCKER_COMPOSE_DEPLOY)
end
desc 'terminal-worker'
task :sh_worker do
compose('exec', '--user', 'root', 'tryton_worker', '/entrypoint.sh', 'bash', compose: DOCKER_COMPOSE_DEPLOY)
end
desc 'terminal-cron'
task :sh_cron do
compose('exec', '--user', 'root', 'tryton_cron', '/entrypoint.sh', 'bash', compose: DOCKER_COMPOSE_DEPLOY)
end
desc 'terminal-db'
task :sh_db do
compose('exec', '--user', 'postgres', 'db', 'bash', compose: DOCKER_COMOPSE_DEPLOY)
end
desc 'terminal-nginx'
task :sh_nginx do
compose('exec', 'nginx', 'bash', compose: DOCKER_COMOPSE_DEPLOY)
end
desc 'top'
task :top do
compose('top', compose: DOCKER_COMOPSE_DEPLOY)
end
end
desc 'Git - Submodules'
namespace :git do
@@ -124,8 +189,8 @@ namespace :git do
end
end
def compose(*arg, compose: DOCKER_COMPOSE)
sh "docker compose -f #{compose} #{arg.join(' ')}"
def compose(*arg, env_file: ENV_FILE_DEV, compose: DOCKER_COMPOSE_TEST)
sh "docker compose --env-file #{env_file} -f #{compose} #{arg.join(' ')}"
end
def refresh_cache

View File

@@ -1,80 +0,0 @@
services:
db:
image: postgres
hostname:
${DB_HOSTNAME}
volumes:
- postgres:/var/lib/postgresql
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
tryton:
build:
context: ./
dockerfile: Dockerfile_Deploy
args:
TRYTOND_VERSION: ${TRYTOND_VERSION}
EMAIL: admin@admin.org
WORKER: True
image: tryton/${POSTGRES_DB}:${TRYTOND_VERSION}
healthcheck:
test: curl --fail localhost:8000 || exit 1
interval: 30s
retries: 5
start_period: 30s
timeout: 20s
ports:
- "${TRYTON_PORT:-8000}:8000"
volumes:
- .:/app
- var:/var
- attachment:/mnt/attachment
environment:
- TRYTOND_DATABASE_URI=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DB_HOSTNAME}:5432/
depends_on:
- db
env_file:
- .env
working_dir: /app
nginx:
image: nginx:1.23.3
restart: unless-stopped
volumes:
- ./nginx.conf:/etc/nginx/conf.d/nginx.conf.template
ports:
- "${NGINX_PORT:-10000}:${NGINX_PORT:-10000}"
env_file:
- .env
depends_on:
- tryton
command: /bin/bash -c "envsubst < /etc/nginx/conf.d/nginx.conf.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
tryton_worker:
image: tryton/${POSTGRES_DB}:${TRYTOND_VERSION}
depends_on:
tryton:
condition: service_healthy
entrypoint: [ "bash", "-c", "/entrypoint.sh trytond-worker -c /etc/trytond_worker.conf -d ${POSTGRES_DB} --logconf /etc/trytond_worker_logging.conf"]
volumes:
- .:/app
environment:
- TRYTOND_DATABASE_URI=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DB_HOSTNAME}:5432/
env_file:
- .env
working_dir: /app
tryton_cron:
image: tryton/${POSTGRES_DB}:${TRYTOND_VERSION}
depends_on:
tryton:
condition: service_healthy
entrypoint: [ "bash", "-c", "/entrypoint.sh trytond-cron -c /etc/trytond.conf -d ${POSTGRES_DB} --logconf /etc/trytond_cron_logging.conf"]
volumes:
- .:/app
environment:
- TRYTOND_DATABASE_URI=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DB_HOSTNAME}:5432/
env_file:
- .env
working_dir: /app
volumes:
var:
postgres:
attachment:

View File

@@ -8,7 +8,7 @@ services:
live:
build:
context: .
dockerfile: Dockerfile_Live
dockerfile: Dockerfile_live
args:
TRYTOND_VERSION: ${TRYTOND_VERSION}
TRYTON_ADMIN_PASSWORD: ${TRYTON_ADMIN_PASSWORD:-admin}
@@ -28,7 +28,7 @@ services:
- "${PUDB_PORT_LIVE:-8020}:8020"
working_dir: /app
env_file:
- .env
- .env.development
volumes:
app:
attachments:

102
docker-compose.prod.yaml Normal file
View File

@@ -0,0 +1,102 @@
services:
db:
image: postgres
hostname: ${DB_HOSTNAME}
volumes:
- postgres:/var/lib/postgresql
environment:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
tryton:
build:
context: ./
dockerfile: Dockerfile_prod
args:
TRYTOND_VERSION: ${TRYTOND_VERSION}
GITEA_USER: ${GITEA_USER}
GITEA_PASSWORD: ${GITEA_PASSWORD}
GITEA_DOMAIN: ${GITEA_DOMAIN}
WORKER: ${WORKER}
TRYTONPASSFILE: ${TRYTONPASSFILE}
TRYTON_ADMIN_EMAIL: ${TRYTON_ADMIN_EMAIL}
SMTP: ${SMTP}
SMTP_TYPE: ${SMTP_TYPE}
SMTP_USER: ${SMTP_USER}
SMTP_PASSWORD: ${SMTP_PASSWORD}
SMTP_DOMAIN: ${SMTP_DOMAIN}
SMTP_PORT: ${SMTP_PORT}
SMTP_FROM: ${SMTP_FROM}
SMTP_EMAIL: ${SMTP_EMAIL}
image: tryton/${POSTGRES_DB}:${TRYTOND_VERSION}
healthcheck:
test: curl --fail localhost:8000 || exit 1
interval: 30s
retries: 5
start_period: 30s
timeout: 20s
ports:
- "${TRYTON_PORT:-8000}:8000"
volumes:
- .:/app
- var:/var
- attachment:/mnt/attachment
environment:
- TRYTOND_DATABASE_URI=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DB_HOSTNAME}:5432/
depends_on:
- db
env_file:
- .env.production
working_dir: /app
nginx:
image: nginx:1.23.3
restart: unless-stopped
volumes:
- ./prod/nginx.conf:/etc/nginx/conf.d/nginx.conf.template
ports:
- "${NGINX_PORT:-10000}:${NGINX_PORT:-10000}"
env_file:
- .env.production
depends_on:
- tryton
command: /bin/bash -c "envsubst < /etc/nginx/conf.d/nginx.conf.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'"
tryton_worker:
image: tryton/${POSTGRES_DB}:${TRYTOND_VERSION}
depends_on:
tryton:
condition: service_healthy
entrypoint:
[
"bash",
"-c",
"/entrypoint.sh trytond-worker -c /etc/trytond_worker.conf -d ${POSTGRES_DB} --logconf /etc/trytond_worker_logging.conf",
]
volumes:
- .:/app
environment:
- TRYTOND_DATABASE_URI=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DB_HOSTNAME}:5432/
env_file:
- .env.production
working_dir: /app
tryton_cron:
image: tryton/${POSTGRES_DB}:${TRYTOND_VERSION}
depends_on:
tryton:
condition: service_healthy
entrypoint:
[
"bash",
"-c",
"/entrypoint.sh trytond-cron -c /etc/trytond.conf -d ${POSTGRES_DB} --logconf /etc/trytond_cron_logging.conf",
]
volumes:
- .:/app
environment:
- TRYTOND_DATABASE_URI=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DB_HOSTNAME}:5432/
env_file:
- .env.production
working_dir: /app
volumes:
app:
var:
postgres:
attachment:

View File

@@ -2,7 +2,7 @@ services:
test.dev:
build:
context: .
dockerfile: Dockerfile_Test
dockerfile: Dockerfile_test
args:
TRYTOND_VERSION: ${TRYTOND_VERSION}
environment:
@@ -10,6 +10,7 @@ services:
DB_CACHE: /tmp
DB_NAME: ":memory:"
TRYTOND_DATABASE_URI: sqlite://
DEVELOP: "True"
command: sleep 10h
volumes:
- .:/app
@@ -17,4 +18,4 @@ services:
- "${PUDB_PORT:-8025}:8025"
working_dir: /app
env_file:
- .env
- .env.development

View File

@@ -1,33 +0,0 @@
services:
db:
image: postgres:12
environment:
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
live:
build:
context: .
dockerfile: Dockerfile_Live
args:
TRYTOND_VERSION: ${TRYTOND_VERSION}
depends_on:
- db
command: bash /app/.dev/run.sh
environment:
- DB_NAME=${POSTGRES_DB}
- SRC=/app
- TRYTOND_DATABASE_URI=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${DB_HOSTNAME}:5432/
volumes:
- ./:/app
- ./attachments:/attachments
- ./.dev/pudb.cfg:/root/.config/pudb/pudb.cfg
ports:
- "${TRYTOND_PORT_LIVE:-18020}:8000"
- "${PUDB_PORT_LIVE:-8020}:8020"
working_dir: /app
env_file:
- .env
volumes:
app:
attachments:

View File

@@ -1,19 +0,0 @@
server {
server_name ${SERVER_NAME};
listen ${NGINX_PORT};
client_max_body_size 8M;
sendfile on;
send_timeout 500s;
location / {
proxy_pass http://tryton:8000/; # "trytond" is the service name of another Docker container on port 8000
proxy_read_timeout 500;
proxy_connect_timeout 500;
proxy_send_timeout 500;
proxy_set_header Host ${VARIABLE}host;
proxy_set_header X-Real-IP ${VARIABLE}remote_addr;
proxy_set_header X-Forwarded-For ${VARIABLE}proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host ${VARIABLE}server_name;
}
}

21
prod/nginx.conf Normal file
View File

@@ -0,0 +1,21 @@
server {
server_name ${SERVER_NAME};
listen ${NGINX_PORT};
client_max_body_size 50M;
sendfile on;
send_timeout 500s;
location / {
proxy_pass http://tryton:8000/; # "trytond" is the service name of another Docker container on port 8000
proxy_read_timeout 500;
proxy_connect_timeout 500;
proxy_send_timeout 500;
proxy_set_header Host ${VARIABLE}host;
proxy_set_header X-Real-IP ${VARIABLE}remote_addr;
proxy_set_header X-Forwarded-For ${VARIABLE}proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host ${VARIABLE}server_name;
proxy_set_header X-Forwarded-Proto ${VARIABLE}scheme;
}
}

View File

@@ -11,4 +11,4 @@ urwid==3.0.2
freezegun==1.5.1
psycopg2-binary==2.9.11
pycountry==24.6.1
pytz==2026.2