[REF] Remove bind fucking mounts (postgres) replaced by nice volumes
This commit is contained in:
parent
7fca87bae7
commit
424131e9b2
|
|
@ -68,10 +68,6 @@ def main(ctx, env_folder, filestore_folder, log_level):
|
|||
# Define all the folder required by the tools
|
||||
env_folder_path = Path(env_folder)
|
||||
src_folder_path = env_folder_path / Path("./src/")
|
||||
# Note: postgres folder should be a subfolder, because
|
||||
# the parent folder will contain a .gitignore file
|
||||
# that the postgres docker image doesn't like
|
||||
postgres_folder_path = env_folder_path / Path("./postgres_data/data")
|
||||
script_folder_path = env_folder_path / Path("./scripts/")
|
||||
log_folder_path = env_folder_path / Path("./log/")
|
||||
if not filestore_folder:
|
||||
|
|
@ -95,7 +91,6 @@ def main(ctx, env_folder, filestore_folder, log_level):
|
|||
# Add all global values in the context
|
||||
ctx.obj["env_folder_path"] = env_folder_path
|
||||
ctx.obj["src_folder_path"] = src_folder_path
|
||||
ctx.obj["postgres_folder_path"] = postgres_folder_path
|
||||
ctx.obj["script_folder_path"] = script_folder_path
|
||||
ctx.obj["log_folder_path"] = log_folder_path
|
||||
ctx.obj["log_prefix"] = log_prefix
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ def init(
|
|||
float(initial_version), float(final_version)
|
||||
)
|
||||
|
||||
# 2. Compute Migration Steps
|
||||
# Compute Migration Steps
|
||||
|
||||
# Create initial first step
|
||||
steps = [
|
||||
|
|
@ -106,26 +106,15 @@ def init(
|
|||
}
|
||||
)
|
||||
|
||||
# 3. ensure src folder exists
|
||||
# Ensure src folder exists
|
||||
ensure_folder_exists(ctx.obj["src_folder_path"])
|
||||
|
||||
# 4. ensure filestore folder exists
|
||||
# Ensure filestore folder exists
|
||||
ensure_folder_exists(
|
||||
ctx.obj["filestore_folder_path"], git_ignore_content=True
|
||||
)
|
||||
|
||||
# 5. ensure postgres data folder exists
|
||||
ensure_folder_exists(
|
||||
ctx.obj["postgres_folder_path"].parent,
|
||||
mode="777",
|
||||
git_ignore_content=True,
|
||||
)
|
||||
ensure_folder_exists(
|
||||
ctx.obj["postgres_folder_path"],
|
||||
mode="777",
|
||||
)
|
||||
|
||||
# 6. ensure main configuration file exists
|
||||
# Znsure main configuration file exists
|
||||
ensure_file_exists_from_template(
|
||||
ctx.obj["config_file_path"],
|
||||
"config.yml.j2",
|
||||
|
|
@ -134,7 +123,7 @@ def init(
|
|||
odoo_versions=odoo_versions,
|
||||
)
|
||||
|
||||
# 7. Ensure module list file exists
|
||||
# Ensure module list file exists
|
||||
ensure_file_exists_from_template(
|
||||
ctx.obj["module_file_path"],
|
||||
"modules.csv.j2",
|
||||
|
|
@ -143,7 +132,7 @@ def init(
|
|||
odoo_versions=odoo_versions,
|
||||
)
|
||||
|
||||
# 8. Create one folder per version and add files
|
||||
# Create one folder per version and add files
|
||||
for odoo_version in odoo_versions:
|
||||
# Create main path for each version
|
||||
path_version = get_odoo_env_path(ctx, odoo_version)
|
||||
|
|
@ -196,7 +185,7 @@ def init(
|
|||
path_version / Path("src"), git_ignore_content=True
|
||||
)
|
||||
|
||||
# 9. Create one folder per step and add files
|
||||
# Create one folder per step and add files
|
||||
ensure_folder_exists(ctx.obj["script_folder_path"])
|
||||
|
||||
for step in steps:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
project_name: {{ project_name }}
|
||||
|
||||
postgres_image_name: postgres:13
|
||||
postgres_container_name: {{project_name}}-db
|
||||
postgres_container_name: {{project_name}}-container-postgres
|
||||
postgres_volume_name: {{project_name}}-volume-postgres
|
||||
|
||||
odoo_host_xmlrpc_port: 9069
|
||||
odoo_default_country_code: FR
|
||||
|
|
|
|||
|
|
@ -1,13 +1,10 @@
|
|||
{%- for python_librairy in python_libraries -%}
|
||||
{{ python_librairy }}
|
||||
{% endfor %}
|
||||
{%- endfor -%}
|
||||
|
||||
# Mandatory library used in all odoo-openupgrade-wizard
|
||||
openupgradelib
|
||||
|
||||
# # Library used to run 'post-migration.py' scripts
|
||||
# click-odoo
|
||||
|
||||
# Library used to run generate-module-analysis command
|
||||
# dependencies of the module OCA/server-tools 'upgrade_analysis'
|
||||
odoorpc
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import os
|
|||
import time
|
||||
from pathlib import Path
|
||||
|
||||
import docker
|
||||
from loguru import logger
|
||||
|
||||
from odoo_openupgrade_wizard.tools.tools_docker import (
|
||||
|
|
@ -15,6 +16,9 @@ def get_postgres_container(ctx):
|
|||
client = get_docker_client()
|
||||
image_name = ctx.obj["config"]["postgres_image_name"]
|
||||
container_name = ctx.obj["config"]["postgres_container_name"]
|
||||
volume_name = ctx.obj["config"]["postgres_volume_name"]
|
||||
|
||||
# Check if container exists
|
||||
containers = client.containers.list(
|
||||
all=True, filters={"name": container_name}
|
||||
)
|
||||
|
|
@ -29,6 +33,14 @@ def get_postgres_container(ctx):
|
|||
else:
|
||||
return container
|
||||
|
||||
# Check if volume exists
|
||||
try:
|
||||
client.volumes.get(volume_name)
|
||||
logger.debug("Recovering existing postgres volume: %s" % volume_name)
|
||||
except docker.errors.NotFound:
|
||||
logger.info("Creating Postgres volume: %s" % volume_name)
|
||||
client.volumes.create(volume_name)
|
||||
|
||||
logger.info("Launching Postgres Container. (Image %s)" % image_name)
|
||||
container = run_container(
|
||||
image_name,
|
||||
|
|
@ -41,9 +53,7 @@ def get_postgres_container(ctx):
|
|||
},
|
||||
volumes={
|
||||
ctx.obj["env_folder_path"].absolute(): "/env/",
|
||||
ctx.obj[
|
||||
"postgres_folder_path"
|
||||
].absolute(): "/var/lib/postgresql/data/pgdata/",
|
||||
volume_name: "/var/lib/postgresql/data/pgdata/",
|
||||
},
|
||||
detach=True,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -58,7 +58,4 @@ def build_ctx_from_config_file() -> dict:
|
|||
|
||||
ctx.obj["env_folder_path"] = env_folder_path
|
||||
ctx.obj["src_folder_path"] = env_folder_path / Path("src")
|
||||
ctx.obj["postgres_folder_path"] = env_folder_path / Path(
|
||||
"postgres_data/data"
|
||||
)
|
||||
return ctx
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
project_name: test-cli
|
||||
|
||||
postgres_image_name: postgres:13
|
||||
postgres_container_name: test-cli-db
|
||||
postgres_container_name: test-cli-container-postgres
|
||||
postgres_volume_name: test-cli-volume-postgres
|
||||
|
||||
odoo_host_xmlrpc_port: 9069
|
||||
odoo_default_country_code: FR
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user