feat: Add deploy system
This commit is contained in:
22
.env_example
22
.env_example
@@ -1,5 +1,6 @@
|
|||||||
# TRYTOND operation mode
|
# TRYTOND operation mode
|
||||||
DEVELOP=False
|
DEVELOP=False
|
||||||
|
WORKER=True
|
||||||
|
|
||||||
# Develop mode
|
# Develop mode
|
||||||
PUDB_PORT=8025
|
PUDB_PORT=8025
|
||||||
@@ -8,8 +9,29 @@ PUDB_PORT=8025
|
|||||||
TRYTOND_VERSION=7.6
|
TRYTOND_VERSION=7.6
|
||||||
TRYTOND_PORT_LIVE=8090
|
TRYTOND_PORT_LIVE=8090
|
||||||
TRYTON_ADMIN_EMAIL=admin@admin.co
|
TRYTON_ADMIN_EMAIL=admin@admin.co
|
||||||
|
TRYTONPASSFILE=/etc/trytond_admin_pass.conf
|
||||||
|
|
||||||
DB_HOSTNAME=db
|
DB_HOSTNAME=db
|
||||||
POSTGRES_DB=tryton
|
POSTGRES_DB=tryton
|
||||||
POSTGRES_USER=tryton
|
POSTGRES_USER=tryton
|
||||||
POSTGRES_PASSWORD=SUp3r-pass*DB
|
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=$
|
||||||
|
|||||||
80
Dockerfile_Deploy
Normal file
80
Dockerfile_Deploy
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
# version Trytond server example 5.0
|
||||||
|
ARG TRYTOND_VERSION
|
||||||
|
|
||||||
|
FROM node as builder-node
|
||||||
|
|
||||||
|
ARG TRYTOND_VERSION
|
||||||
|
ARG TRYTONPASSFILE
|
||||||
|
|
||||||
|
ENV SERIES=${TRYTOND_VERSION}
|
||||||
|
|
||||||
|
RUN npm install -g bower
|
||||||
|
RUN curl https://downloads.tryton.org/${SERIES}/tryton-sao-last.tgz | tar zxf - -C /
|
||||||
|
COPY naliia_sao_custom/sao.less /package/src/sao.less
|
||||||
|
RUN cd /package && rm -rf dist && npm install --legacy-peer-deps && npx grunt && bower install --allow-root
|
||||||
|
|
||||||
|
|
||||||
|
FROM tryton/tryton:$TRYTOND_VERSION
|
||||||
|
|
||||||
|
# label custom
|
||||||
|
LABEL org.label-schema.version="$TRYTOND_VERSION"
|
||||||
|
|
||||||
|
ARG TRYTOND_VERSION
|
||||||
|
ARG DEVELOP
|
||||||
|
ARG WORKER
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends \
|
||||||
|
git \
|
||||||
|
python3-click \
|
||||||
|
uwsgi \
|
||||||
|
uwsgi-plugin-python3 \
|
||||||
|
libreoffice
|
||||||
|
|
||||||
|
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 modules /app/modules
|
||||||
|
|
||||||
|
COPY 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
|
||||||
|
|
||||||
|
COPY --from=builder-node /package /var/lib/trytond/www
|
||||||
|
COPY naliia_sao_custom/ /var/lib/trytond/www/
|
||||||
|
|
||||||
|
ARG TRYTONPASSFILE
|
||||||
|
|
||||||
|
ENV TRYTONPASSFILE=/etc/trytond_admin_pass.conf
|
||||||
|
|
||||||
|
RUN touch /etc/trytond_populate.conf \
|
||||||
|
&& touch $TRYTONPASSFILE \
|
||||||
|
&& chown -R trytond:trytond /etc/trytond* \
|
||||||
|
&& rm -rf /var/log/trytond \
|
||||||
|
&& mkdir /var/log/trytond \
|
||||||
|
&& chown -R trytond:trytond /var/log/trytond \
|
||||||
|
&& rm -rf /mnt/attachment \
|
||||||
|
&& mkdir /mnt/attachment \
|
||||||
|
&& chown -R trytond:trytond /mnt/attachment
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
USER trytond
|
||||||
|
|
||||||
|
CMD ["/bin/bash", "/opt/start.sh"]
|
||||||
401715
common_password.txt
Normal file
401715
common_password.txt
Normal file
File diff suppressed because one or more lines are too long
80
compose.deploy.yaml
Normal file
80
compose.deploy.yaml
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
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:
|
||||||
25
gunicorn.conf.py
Normal file
25
gunicorn.conf.py
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
wsgi_app = 'trytond.application:app'
|
||||||
|
bind = '0.0.0.0:8000'
|
||||||
|
# Number of worker processes
|
||||||
|
workers = (8 * os.cpu_count()) + 1
|
||||||
|
|
||||||
|
# Worker class
|
||||||
|
worker_class = "sync" # or "gevent" for I/O-bound tasks
|
||||||
|
|
||||||
|
# Timeout for requests
|
||||||
|
timeout= 500
|
||||||
|
|
||||||
|
# Preload application
|
||||||
|
preload_app = True
|
||||||
|
|
||||||
|
# Keep-alive
|
||||||
|
keepalive = 5
|
||||||
|
|
||||||
|
raw_env = [
|
||||||
|
'TRYTOND_CONFIG=%s' % os.environ.get('TRYTOND_CONFIG', ''),
|
||||||
|
'TRYTOND_DATABASE_URI=%s' % os.environ.get('TRYTOND_DATABASE_URI', ''),
|
||||||
|
'PYTHONOPTIMIZE=%s' % os.environ.get('PYTHONOPTIMIZE'),
|
||||||
|
]
|
||||||
|
|
||||||
40
install_modules.sh
Executable file
40
install_modules.sh
Executable file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
set -e # Exit on error
|
||||||
|
|
||||||
|
echo "Files in /app directory:"
|
||||||
|
ls -la /app/
|
||||||
|
|
||||||
|
if [ -d "/app/modules" ] && [ "$(ls -A /app/modules)" ]; then
|
||||||
|
module_names=()
|
||||||
|
for module in /app/modules/*/; do
|
||||||
|
echo "Processing module: $module"
|
||||||
|
|
||||||
|
pushd "$module" > /dev/null
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
pip3 install . --break-system-packages
|
||||||
|
|
||||||
|
# Extract module name
|
||||||
|
trytond_modules_path=$(pip3 show trytond | grep Location | sed -nr 's/Location: +//gp')/trytond/modules
|
||||||
|
module_name=$(cat "setup.py" | grep -A 1 "\[trytond.modules\]" | sed 1d | cut -d '=' -f 1 | tr -d ' \n')
|
||||||
|
|
||||||
|
# Add to array
|
||||||
|
module_names+=("$module_name")
|
||||||
|
|
||||||
|
# Validate path
|
||||||
|
if [ ! -d "$trytond_modules_path" ]; then
|
||||||
|
echo "ERROR: Failed to locate trytond modules path" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create symlink (fix: use direct path, not $SRC)
|
||||||
|
ln -sf "$module" "$trytond_modules_path/$module_name"
|
||||||
|
|
||||||
|
popd > /dev/null
|
||||||
|
done
|
||||||
|
|
||||||
|
# Create colon-separated list
|
||||||
|
module_names=$(IFS=:; echo "${module_names[*]}")
|
||||||
|
echo "Installed modules: $module_names"
|
||||||
|
fi
|
||||||
19
nginx.conf
Normal file
19
nginx.conf
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,6 @@ honcho==2.0.0
|
|||||||
pudb==2025.1
|
pudb==2025.1
|
||||||
urwid==3.0.2
|
urwid==3.0.2
|
||||||
freezegun==1.5.1
|
freezegun==1.5.1
|
||||||
psycopg2==2.9.10
|
psycopg2-binary==2.9.11
|
||||||
pycountry==24.6.1
|
pycountry==24.6.1
|
||||||
|
|
||||||
|
|||||||
26
start.sh
Normal file
26
start.sh
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
if [ -s /etc/trytond_populate.conf ]; then
|
||||||
|
if [ "$DEVELOP" == "True" ]; then
|
||||||
|
if [ "$WORKER" == "True" ]; then
|
||||||
|
trytond -c /etc/trytond.conf --dev --logconf /etc/trytond_logging.conf
|
||||||
|
# trytond-cron -c /etc/trytond.conf --dev --logconf /etc/trytond_cron_logging.conf &
|
||||||
|
# trytond-worker -c /etc/trytond.conf -d miac --dev --logconf /etc/trytond_worker_logging.conf
|
||||||
|
else
|
||||||
|
trytond -c /etc/trytond.conf --dev --logconf /etc/trytond_logging.conf
|
||||||
|
# trytond-cron -c /etc/trytond.conf --dev --logconf /etc/trytond_cron_logging.conf
|
||||||
|
fi
|
||||||
|
elif [ "$WORKER" == "True" ]; then
|
||||||
|
# trytond-cron -c /etc/trytond.conf --dev --logconf /etc/trytond_cron_logging.conf &
|
||||||
|
# trytond-worker -c /etc/trytond.conf -d miac --logconf /etc/trytond_worker_logging.conf &
|
||||||
|
gunicorn --config=/etc/gunicorn.conf.py
|
||||||
|
else
|
||||||
|
gunicorn --config=/etc/gunicorn.conf.py
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
sleep $SLEEP_TRYTOND_ADMIN && echo $TRYTONADMINPASS > $TRYTONPASSFILE
|
||||||
|
|
||||||
|
trytond-admin -c /etc/trytond.conf -d $POSTGRES_DB --all --email $EMAIL -vv
|
||||||
|
|
||||||
|
echo "1" > /etc/trytond_populate.conf && /bin/bash /opt/start.sh
|
||||||
|
fi
|
||||||
11
trytond.conf
Normal file
11
trytond.conf
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[web]
|
||||||
|
listen=0.0.0.0:8000
|
||||||
|
root=/var/lib/trytond/www
|
||||||
|
|
||||||
|
[database]
|
||||||
|
list=True
|
||||||
|
path=/mnt/attachment
|
||||||
|
lenguage=es
|
||||||
|
|
||||||
|
[password]
|
||||||
|
forbidden=/etc/common_password.txt
|
||||||
26
trytond_cron_logging.conf
Normal file
26
trytond_cron_logging.conf
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
[formatters]
|
||||||
|
keys=simple
|
||||||
|
|
||||||
|
[handlers]
|
||||||
|
keys=rotate,console
|
||||||
|
|
||||||
|
[loggers]
|
||||||
|
keys=root
|
||||||
|
|
||||||
|
[formatter_simple]
|
||||||
|
format=[%(asctime)s] %(levelname)s:%(name)s:%(message)s
|
||||||
|
datefmt=%a %b %d %H:%M:%S %Y
|
||||||
|
|
||||||
|
[handler_rotate]
|
||||||
|
class=handlers.TimedRotatingFileHandler
|
||||||
|
args=('/var/log/trytond/trytond_cron.log', 'D', 1, 30)
|
||||||
|
formatter=simple
|
||||||
|
|
||||||
|
[handler_console]
|
||||||
|
class=StreamHandler
|
||||||
|
formatter=simple
|
||||||
|
args=(sys.stdout,)
|
||||||
|
|
||||||
|
[logger_root]
|
||||||
|
level=INFO
|
||||||
|
handlers=rotate,console
|
||||||
26
trytond_logging.conf
Normal file
26
trytond_logging.conf
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
[formatters]
|
||||||
|
keys=simple
|
||||||
|
|
||||||
|
[handlers]
|
||||||
|
keys=rotate,console
|
||||||
|
|
||||||
|
[loggers]
|
||||||
|
keys=root
|
||||||
|
|
||||||
|
[formatter_simple]
|
||||||
|
format=[%(asctime)s] %(levelname)s:%(name)s:%(message)s
|
||||||
|
datefmt=%a %b %d %H:%M:%S %Y
|
||||||
|
|
||||||
|
[handler_rotate]
|
||||||
|
class=handlers.TimedRotatingFileHandler
|
||||||
|
args=('/var/log/trytond/trytond.log', 'D', 1, 30)
|
||||||
|
formatter=simple
|
||||||
|
|
||||||
|
[handler_console]
|
||||||
|
class=StreamHandler
|
||||||
|
formatter=simple
|
||||||
|
args=(sys.stdout,)
|
||||||
|
|
||||||
|
[logger_root]
|
||||||
|
level=INFO
|
||||||
|
handlers=rotate,console
|
||||||
14
trytond_worker.conf
Normal file
14
trytond_worker.conf
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[web]
|
||||||
|
listen=0.0.0.0:8000
|
||||||
|
root=/var/lib/trytond/www
|
||||||
|
|
||||||
|
[database]
|
||||||
|
list=True
|
||||||
|
path=/mnt/attachment
|
||||||
|
lenguage=es
|
||||||
|
|
||||||
|
[password]
|
||||||
|
forbidden=/etc/common_password.txt
|
||||||
|
|
||||||
|
[queue]
|
||||||
|
worker = True
|
||||||
26
trytond_worker_logging.conf
Normal file
26
trytond_worker_logging.conf
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
[formatters]
|
||||||
|
keys=simple
|
||||||
|
|
||||||
|
[handlers]
|
||||||
|
keys=rotate,console
|
||||||
|
|
||||||
|
[loggers]
|
||||||
|
keys=root
|
||||||
|
|
||||||
|
[formatter_simple]
|
||||||
|
format=[%(asctime)s] %(levelname)s:%(name)s:%(message)s
|
||||||
|
datefmt=%a %b %d %H:%M:%S %Y
|
||||||
|
|
||||||
|
[handler_rotate]
|
||||||
|
class=handlers.TimedRotatingFileHandler
|
||||||
|
args=('/var/log/trytond/trytond_worker.log', 'D', 1, 30)
|
||||||
|
formatter=simple
|
||||||
|
|
||||||
|
[handler_console]
|
||||||
|
class=StreamHandler
|
||||||
|
formatter=simple
|
||||||
|
args=(sys.stdout,)
|
||||||
|
|
||||||
|
[logger_root]
|
||||||
|
level=INFO
|
||||||
|
handlers=rotate,console
|
||||||
Reference in New Issue
Block a user