diff --git a/.env.example b/.env.example
index 78b2152..698aaee 100644
--- a/.env.example
+++ b/.env.example
@@ -5,7 +5,7 @@
APP_ENV=local
INIT=
UPDATE=
-LOAD=base,web,session_redis
+LOAD=base,web,session_redis,attachment_s3
WORKERS=2
DEV_MODE=reload,xml
DOMAIN=erp.odoocker.test
@@ -69,6 +69,18 @@ REDIS_PREFIX=odoo
REDIS_EXPIRATION=604800
REDIS_EXPIRATION_ANONYMOUS=10800
+# Filesystem
+MINIO_VIRTUAL_HOST=s3.j8c.test
+MINIO_CONSOLE_PORT=9000
+MINIO_VIRTUAL_PORT=9001
+DISABLE_S3_STORAGE=0
+
+AWS_ACCESS_KEY_ID=myaccesskey
+AWS_SECRET_ACCESS_KEY=mysecretkey
+AWS_REGION=
+AWS_HOST=http://s3:${MINIO_CONSOLE_PORT}
+AWS_BUCKETNAME=${DB_NAME}
+
# PgAdmin
PGADMIN_DOMAIN=pgadmin.odoocker.test
PGADMING_DB_NAME=pgadmin
@@ -265,6 +277,21 @@ ODOO_SESSION_REDIS_PREFIX=${REDIS_PREFIX}
ODOO_SESSION_REDIS_EXPIRATION=${REDIS_EXPIRATION}
ODOO_SESSION_REDIS_EXPIRATION_ANONYMOUS=${REDIS_EXPIRATION_ANONYMOUS}
+#----------#
+# S3 #
+#----------#
+AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
+AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
+AWS_REGION=${AWS_REGION}
+AWS_HOST=${AWS_HOST}
+AWS_BUCKETNAME=${AWS_BUCKETNAME}
+
+DISABLE_ATTACHMENT_STORAGE=${DISABLE_S3_STORAGE}
+MINIO_ROOT_USER=${AWS_ACCESS_KEY_ID}
+MINIO_ROOT_PASSWORD=${AWS_SECRET_ACCESS_KEY}
+MINIO_VIRTUAL_HOST=${MINIO_VIRTUAL_HOST}
+MINIO_BROWSER_REDIRECT_URL=${MINIO_VIRTUAL_HOST}
+
#-------------#
# PgAdmin #
#-------------#
diff --git a/docker-compose.yml b/docker-compose.yml
index cda6f9d..61f82e9 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -63,6 +63,23 @@ services:
volumes:
- redis-data:/var/lib/keydb
+ s3:
+ image: minio/minio:latest
+ environment:
+ - MINIO_ROOT_USER
+ - MINIO_ROOT_PASSWORD
+ - VIRTUAL_HOST=${MINIO_VIRTUAL_HOST}
+ - VIRTUAL_PORT=${MINIO_VIRTUAL_PORT}
+ - MINIO_BROWSER_REDIRECT_URL
+ command: server /data --console-address ":9001"
+ volumes:
+ - s3_data:/data
+ ports:
+ - 9000:9000
+ - 9001:9001
+ networks:
+ - internal
+
nginx:
image: nginx:${NGINX_TAG}
depends_on:
@@ -105,6 +122,7 @@ volumes:
odoo-data:
pg-data:
redis-data:
+ s3_data:
certs:
vhost:
html:
diff --git a/odoo/Dockerfile b/odoo/Dockerfile
index 225809e..9111d0c 100644
--- a/odoo/Dockerfile
+++ b/odoo/Dockerfile
@@ -44,6 +44,18 @@ RUN apt-get update && apt-get install -y \
# Clean up the apt cache to reduce the image size
&& rm -rf /var/lib/apt/lists/*
+#---------------------#
+# PIP Dependecies #
+#---------------------#
+# Upgrade pip
+RUN pip3 install --upgrade pip
+
+# Copy & Install PIP requirements
+COPY --chown=odoo:odoo ./odoo/requirements.txt /tmp/requirements.txt
+
+RUN python3 -m pip install -r /tmp/requirements.txt && \
+ rm /tmp/requirements.txt
+
#-----------------------#
# Odoo Enterprise #
#-----------------------#
@@ -67,18 +79,6 @@ RUN mkdir -p ${THIRD_PARTY_ADDONS} && \
COPY --chown=odoo:odoo ./odoo/third-party-addons.sh /
RUN /third-party-addons.sh && chown odoo:odoo ${THIRD_PARTY_ADDONS}
-#---------------------#
-# PIP Dependecies #
-#---------------------#
-# Upgrade pip
-RUN pip3 install --upgrade pip
-
-# Copy & Install PIP requirements
-COPY --chown=odoo:odoo ./odoo/requirements.txt /tmp/requirements.txt
-
-RUN python3 -m pip install -r /tmp/requirements.txt && \
- rm /tmp/requirements.txt
-
#---------------------#
# Logging #
#---------------------#
diff --git a/odoo/extra-addons/odoocker_base/data/ir_config_parameter.xml b/odoo/extra-addons/odoocker_base/data/ir_config_parameter.xml
index 9e9fb65..5032b76 100644
--- a/odoo/extra-addons/odoocker_base/data/ir_config_parameter.xml
+++ b/odoo/extra-addons/odoocker_base/data/ir_config_parameter.xml
@@ -5,4 +5,10 @@
report.url
http://127.0.0.1:8069
+
+
+
+ ir_attachment.location
+ s3
+
diff --git a/odoo/odoorc.sh b/odoo/odoorc.sh
index db971c8..81a9b07 100755
--- a/odoo/odoorc.sh
+++ b/odoo/odoorc.sh
@@ -109,6 +109,13 @@ defaults=(
[ODOO_SESSION_REDIS_PREFIX]=${ODOO_SESSION_REDIS_PREFIX}
[ODOO_SESSION_REDIS_EXPIRATION]=${ODOO_SESSION_REDIS_EXPIRATION}
[ODOO_SESSION_REDIS_EXPIRATION_ANONYMOUS]=${ODOO_SESSION_REDIS_EXPIRATION_ANONYMOUS}
+
+ [DISABLE_ATTACHMENT_STORAGE]=${DISABLE_ATTACHMENT_STORAGE}
+ [AWS_HOST]=${AWS_HOST}
+ [AWS_REGION]=${AWS_REGION}
+ [AWS_ACCESS_KEY_ID]=${AWS_ACCESS_KEY_ID}
+ [AWS_SECRET_ACCESS_KEY]=${AWS_SECRET_ACCESS_KEY}
+ [AWS_BUCKETNAME]=${AWS_BUCKETNAME}
)
# Define the template
@@ -405,6 +412,24 @@ ODOO_SESSION_REDIS_EXPIRATION = {ODOO_SESSION_REDIS_EXPIRATION}
; -- Time in seconds before expiration of the anonymous sessions (default is 3 hours)
ODOO_SESSION_REDIS_EXPIRATION_ANONYMOUS = {ODOO_SESSION_REDIS_EXPIRATION_ANONYMOUS}
+;----------;
+; S3 ;
+;----------;
+; -- Disable S3 storage
+DISABLE_ATTACHMENT_STORAGE = {DISABLE_ATTACHMENT_STORAGE}
+
+; -- Not required if using AWS S3
+AWS_HOST = {AWS_HOST}
+
+; -- Required if using AWS services
+AWS_REGION = {AWS_REGION}
+
+AWS_ACCESS_KEY_ID = {AWS_ACCESS_KEY_ID}
+AWS_SECRET_ACCESS_KEY = {AWS_SECRET_ACCESS_KEY}
+
+; Optional {db_name} placeholder
+AWS_BUCKETNAME = {AWS_BUCKETNAME}
+
EOF
)
diff --git a/odoo/requirements.txt b/odoo/requirements.txt
index 759b3e9..181b3bb 100644
--- a/odoo/requirements.txt
+++ b/odoo/requirements.txt
@@ -1,3 +1,4 @@
debugpy
websocket-client
redis
+boto3
diff --git a/odoo/third-party-addons.sh b/odoo/third-party-addons.sh
index a5d82d9..4b1d3db 100755
--- a/odoo/third-party-addons.sh
+++ b/odoo/third-party-addons.sh
@@ -1,2 +1,48 @@
-git clone https://github.com/camptocamp/odoo-cloud-platform.git --depth 1 --branch ${ODOO_TAG} --single-branch --no-tags;
-cp -r odoo-cloud-platform/session_redis ${THIRD_PARTY_ADDONS}/session_redis
+# Check if the repository directory exists
+if [ ! -d "odoo-cloud-platform" ]; then
+ git clone https://github.com/camptocamp/odoo-cloud-platform.git --depth 1 --branch ${ODOO_TAG} --single-branch --no-tags;
+ cp -r odoo-cloud-platform/session_redis ${THIRD_PARTY_ADDONS}/session_redis
+ cp -r odoo-cloud-platform/base_attachment_object_storage ${THIRD_PARTY_ADDONS}/base_attachment_object_storage
+ cp -r odoo-cloud-platform/attachment_s3 ${THIRD_PARTY_ADDONS}/attachment_s3
+fi
+
+# Define the path to the manifest file
+manifest_file_path="${THIRD_PARTY_ADDONS}/attachment_s3/__manifest__.py"
+
+# Use Python to modify the manifest file
+python3 -c "
+filename = '${manifest_file_path}'
+
+# Read the file content
+with open(filename, 'r') as file:
+ lines = file.readlines()
+
+# Find the start and end index of the manifest dictionary
+start_index = next(i for i, line in enumerate(lines) if line.strip().startswith('{'))
+end_index = next(i for i, line in enumerate(lines) if line.strip().endswith('}'))
+
+# Construct and evaluate the manifest dictionary
+manifest_dict = eval(''.join(lines[start_index:end_index + 1]))
+
+# Modify the manifest dictionary
+manifest_dict['installable'] = True
+manifest_dict['auto_install'] = True
+
+# Construct the modified manifest string
+modified_manifest_lines = ['{\n']
+for key, value in manifest_dict.items():
+ modified_manifest_lines.append(f' \'{key}\': {repr(value)},\n')
+modified_manifest_lines.append('}\n')
+
+# Replace the manifest dictionary string in the content
+lines[start_index:end_index + 1] = modified_manifest_lines
+
+# Write the modified content back to the file
+with open(filename, 'w') as file:
+ file.writelines(lines)
+"
+
+echo "Modified $manifest_file_path"
+
+# Optional: Cat the file to verify changes
+cat $manifest_file_path
\ No newline at end of file