From 9d480c0dbc0f0d0b4bff0b1ebb91eb2844bf9c4f Mon Sep 17 00:00:00 2001 From: rodia Date: Thu, 4 Sep 2025 12:21:44 -0300 Subject: [PATCH] feat: Add basic structure for live environment --- Dockerfile_Live | 18 ++++++++++++++++ Rakefile | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ compose.live.yml | 33 ++++++++++++++++++++++++++++ requirements.txt | 7 ++++++ 4 files changed, 114 insertions(+) create mode 100644 Dockerfile_Live create mode 100644 compose.live.yml diff --git a/Dockerfile_Live b/Dockerfile_Live new file mode 100644 index 0000000..7ca6bd2 --- /dev/null +++ b/Dockerfile_Live @@ -0,0 +1,18 @@ +# TOMADO DE: https://hg.tryton.org/tryton-docker/file/tip/6.6/Dockerfile +FROM node as builder-node + +ARG TRYTOND_VERSION + +ENV SERIES=${TRYTOND_VERSION} +RUN npm install -g bower +RUN curl https://downloads.tryton.org/${SERIES}/tryton-sao-last.tgz | tar zxf - -C / +RUN cd /package && bower install --allow-root + +FROM python:3.11-bullseye + +# trytond DB_CACHE requiere commandos `pg_dump` y `pg_restore` +RUN apt-get update && apt-get install -y postgresql-client + +# TOMADO DE: https://hg.tryton.org/tryton-docker/file/tip/6.6/Dockerfile +COPY --from=builder-node /package /var/lib/trytond/www + diff --git a/Rakefile b/Rakefile index e5b0251..0ea4d6a 100644 --- a/Rakefile +++ b/Rakefile @@ -40,6 +40,62 @@ task :down do compose('down', '-vv') end +desc 'entorno vivo' +namespace :live do + + desc 'iniciar entorno' + task :up do + compose('up', '--build', '-d', compose: 'compose.live.yml') + end + + desc 'monitorear salida' + task :tail do + compose('logs', '-f', 'live', compose: 'compose.live.yml') + end + + desc 'detener entorno' + task :down do + compose('down', compose: 'compose.live.yml') + end + + desc 'eliminar entorno' + task :del do + compose('down', '-v', '--rmi', 'all', compose: 'compose.live.yml') + end + + desc 'reiniciar entorno' + task :restart do + compose('restart', compose: 'compose.live.yml') + end + + desc 'terminal' + task :sh do + compose('exec', 'live', 'bash') + end + + desc 'monitorear salida' + task :tail_end do + compose('logs', '-f', '-n 50', 'live.dev', compose: 'compose.live.yml') + end + + desc 'populate data' + task :populate, [:database] do |_, args| + if args.database + compose('stop', "live.dev", compose: "compose.yml") + compose('exec', '-it', '--user', 'postgres', 'db.dev', "bash -c 'dropdb -U tryton #{args.database}'") + compose('exec', '-it', '--user', 'postgres', 'db.dev', "bash -c 'createdb -U tryton #{args.database}'") + compose('restart', "live.dev", compose: "compose.yml") + + sleep(30) + # compose('exec', '--user', 'root', 'live.dev', "trytond-admin -d #{args.database} -m --all -vv --act", compose: 'compose.yml') + compose('exec', 'live.dev', "bash -c 'python3 demo/__main__.py -c .dev/trytond.cfg -d #{args.database}'") + compose('restart', 'live.dev', compose: "compose.yml") + else + puts "Falta el nomnbre de la base de datos" + end + end +end + def compose(*arg, compose: DOCKER_COMPOSE) sh "docker-compose -f #{compose} #{arg.join(' ')}" end diff --git a/compose.live.yml b/compose.live.yml new file mode 100644 index 0000000..5094430 --- /dev/null +++ b/compose.live.yml @@ -0,0 +1,33 @@ +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 .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: + - "${TRYTON_PORT_LIVE:-18020}:8000" + - "${PUDB_PORT_LIVE:-8020}:8020" + working_dir: /app + env_file: + - .env +volumes: + app: + attachments: diff --git a/requirements.txt b/requirements.txt index a613053..b39ed54 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,10 @@ qrcode==6.1 pydot==3.0.0 tqdm==4.67.1 +inotify==0.2.10 +honcho==2.0.0 +pudb==2025.1 +urwid==3.0.2 +freezegun==1.5.1 +psycopg2==2.9.10 +