feat: Add basic structure for live environment

This commit is contained in:
rodia 2025-09-04 12:21:44 -03:00
parent 3cab88fae2
commit 9d480c0dbc
4 changed files with 114 additions and 0 deletions

18
Dockerfile_Live Normal file
View File

@ -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

View File

@ -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

33
compose.live.yml Normal file
View File

@ -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:

View File

@ -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