diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9bccddd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +# Use the existing Odoo image as the base +FROM odoo:latest AS odoo-custom + +# Copy the entrypoint script into the container +COPY entrypoint_odoo.sh /usr/local/bin/entrypoint_odoo.sh + +USER root + +# Make the entrypoint script executable +RUN chmod +x /usr/local/bin/entrypoint_odoo.sh + +# Set the new entrypoint +ENTRYPOINT ["/usr/local/bin/entrypoint_odoo.sh"] diff --git a/__main__.py b/__main__.py index f50d8e7..f591be0 100644 --- a/__main__.py +++ b/__main__.py @@ -58,29 +58,44 @@ for container in containers_data.get("containers", []): # Create the container try: - container_resource = docker.Container( - container_name, - image=container["image"], - envs=[ - f"{key}={value}" for key, value in container.get("envs", {}).items() - ] if "envs" in container else [], - ports=[ - docker.ContainerPortArgs( - internal=port["internal"], - external=port["external"] + i - ) for port in container.get("ports", []) - ] if "ports" in container else [], - volumes=volumes_config, - network_mode=network.name if network else None, - command=container.get("command", []), - ) + if container["name"] == "odoo": # Special configuration for Odoo + container_resource = docker.Container( + container_name, + image="odoo-custom", # Replace with pre-built image name + envs=[f"{key}={value}" for key, value in container.get("envs", {}).items()], + ports=[ + docker.ContainerPortArgs( + internal=port["internal"], + external=port["external"] + i + ) for port in container.get("ports", []) + ] if "ports" in container else [], + volumes=volumes_config, + network_mode=network.name if network else None, + ) + else: + container_resource = docker.Container( + container_name, + image=container["image"], + envs=[ + f"{key}={value}" for key, value in container.get("envs", {}).items() + ] if "envs" in container else [], + ports=[ + docker.ContainerPortArgs( + internal=port["internal"], + external=port["external"] + i + ) for port in container.get("ports", []) + ] if "ports" in container else [], + volumes=volumes_config, + network_mode=network.name if network else None, + command=container.get("command", []), + ) ports = container.get("ports", []) if ports: for port in ports: external_port = port["external"] + i pulumi.export( f"{container_name}_url", - f"http://localhost:{external_port}" + f"http://localhost:{external_port}" ) except Exception as e: pulumi.log.error(f"Failed to create container {container_name}: {e}") diff --git a/config.json b/config.json index 16f9171..329b1e4 100644 --- a/config.json +++ b/config.json @@ -27,8 +27,7 @@ "ODOO_PASSWORD": "admin" }, "ports": [{"internal": 8069, "external": 8069}], - "instances": 3, - "command": ["/bin/bash", "-c", "sleep 10 && odoo -i base"] + "instances": 3 }, { "name": "grafana", diff --git a/entrypoint_backup.sh b/entrypoint_backup.sh new file mode 100644 index 0000000..95c956b --- /dev/null +++ b/entrypoint_backup.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -c + +apk add --no-cache postgresql-client +sleep 5 diff --git a/entrypoint.sh b/entrypoint_odoo.sh similarity index 100% rename from entrypoint.sh rename to entrypoint_odoo.sh