diff --git a/.env.example b/.env.example index 0d81849..0de35b9 100644 --- a/.env.example +++ b/.env.example @@ -120,7 +120,7 @@ USE_S3=false USE_SENTRY=false # Which services are going to be brought up -COMPOSE_PROFILES=base +COMPOSE_PROFILES=base,cache,storage,ssl,admin # Service profiles ODOO_PROFILES="base" @@ -320,6 +320,9 @@ CORS_ALLOWED_DOMAIN=${CORS_ALLOWED_DOMAIN} #----------------------# # ACME Companion # #----------------------# +# For prod use: https://acme-v02.api.letsencrypt.org/directory +ACME_CA_URI=https://acme-staging-v02.api.letsencrypt.org/directory +CERTS_UPDATE_INTERVAL=3600 DEFAULT_EMAIL=${SUPPORT_EMAIL} #-------------# diff --git a/docker-compose.override.local.yml b/docker-compose.override.local.yml index 8a9c1a6..b5363f4 100644 --- a/docker-compose.override.local.yml +++ b/docker-compose.override.local.yml @@ -19,3 +19,4 @@ services: restart: 'no' ports: - 80:80 + - 443:443 diff --git a/docker-compose.override.production.yml b/docker-compose.override.production.yml index f7e4055..bf55c5e 100644 --- a/docker-compose.override.production.yml +++ b/docker-compose.override.production.yml @@ -1,21 +1,5 @@ services: - odoo: - restart: unless-stopped - ports: - - 127.0.0.1:8069:8069 - - 127.0.0.1:8071:8071 - - 127.0.0.1:8072:8072 - - postgres: - restart: unless-stopped - ports: - - 127.0.0.1:5432:5432 - - nginx-proxy: - restart: unless-stopped - ports: - - 80:80 - - 443:443 + volumes: acme: diff --git a/docker-compose.yml b/docker-compose.yml index 35f717c..f27093c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,8 +14,9 @@ services: - ENTERPRISE_ADDONS - THIRD_PARTY_ADDONS - LOG_PATH - depends_on: - - postgres + - USE_REDIS + - USE_S3 + - USE_SENTRY tty: true volumes: - odoo-data:${DATA_DIR} @@ -161,6 +162,8 @@ services: - acme:${NGINX_ACME} - ${DOCKER_SOCK}:${DOCKER_SOCK}:ro environment: + - ACME_CA_URI + - CERTS_UPDATE_INTERVAL - DEFAULT_EMAIL networks: - internal diff --git a/odoo/Dockerfile b/odoo/Dockerfile index 7f465b4..ebeaa6e 100644 --- a/odoo/Dockerfile +++ b/odoo/Dockerfile @@ -16,6 +16,9 @@ ARG GITHUB_ACCESS_TOKEN ARG ENTERPRISE_ADDONS ARG THIRD_PARTY_ADDONS ARG ODOO_RC +ARG USE_REDIS +ARG USE_S3 +ARG USE_SENTRY ENV ODOO_TAG=${ODOO_TAG} \ LOG_PATH=${LOG_PATH} \ @@ -23,7 +26,10 @@ ENV ODOO_TAG=${ODOO_TAG} \ GITHUB_ACCESS_TOKEN=${GITHUB_ACCESS_TOKEN} \ ENTERPRISE_ADDONS=${ENTERPRISE_ADDONS} \ THIRD_PARTY_ADDONS=${THIRD_PARTY_ADDONS} \ - ODOO_RC=${ODOO_RC} + ODOO_RC=${ODOO_RC} \ + USE_REDIS=${USE_REDIS} \ + USE_S3=${USE_S3} \ + USE_SENTRY=${USE_SENTRY} #------------------------# # APT Dependencies # diff --git a/odoo/entrypoint.sh b/odoo/entrypoint.sh index 39b0753..33fa16e 100755 --- a/odoo/entrypoint.sh +++ b/odoo/entrypoint.sh @@ -25,14 +25,14 @@ case "$1" in if [ ${APP_ENV} = 'fresh' ] || [ ${APP_ENV} = 'restore' ]; then # Ideal for a fresh install or restore a production database. - echo odoo --config ${ODOO_RC} --database= --init= --update= --load=${SERVER_WIDE_MODULES} --log-level=${LOG_LEVEL} --load-language= --workers=0 --limit-time-cpu=3600 --limit-time-real=7200 + echo odoo --config ${ODOO_RC} --database= --init= --update= --load=${LOAD} --log-level=${LOG_LEVEL} --load-language= --workers=0 --limit-time-cpu=3600 --limit-time-real=7200 exec odoo --config ${ODOO_RC} --database= --init= --update= --load-language= --workers=0 --limit-time-cpu=3600 --limit-time-real=7200 fi if [ ${APP_ENV} = 'local' ] ; then # Listens to all .env variables mapped into odoo.conf file. - echo odoo --config ${ODOO_RC} + echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=${UPDATE} --load=${LOAD} --workers=${WORKERS} --log-level=${LOG_LEVEL} --dev=${DEV_MODE} exec odoo --config ${ODOO_RC} fi @@ -46,21 +46,21 @@ case "$1" in if [ ${APP_ENV} = 'testing' ] ; then # Initializies a fresh 'test_*' database, installs the addons to test, and runs tests you specify in the test tags. - echo odoo --config ${ODOO_RC} --database=test_${DB_NAME} --test-enable --test-tags ${TEST_TAGS} --init=${ADDONS_TO_TEST} --update=${ADDONS_TO_TEST} --load=${SERVER_WIDE_MODULES} --log-level=${LOG_LEVEL} --without-demo= --workers=0 --dev= --stop-after-init + echo odoo --config ${ODOO_RC} --database=test_${DB_NAME} --test-enable --test-tags ${TEST_TAGS} --init=${ADDONS_TO_TEST} --update=${ADDONS_TO_TEST} --load=${LOAD} --log-level=${LOG_LEVEL} --without-demo= --workers=0 --dev= --stop-after-init exec odoo --config ${ODOO_RC} --database=test_${DB_NAME} --test-enable --test-tags ${TEST_TAGS} --init=${ADDONS_TO_TEST} --update=${ADDONS_TO_TEST} --without-demo= --workers=0 --dev= --stop-after-init fi if [ ${APP_ENV} = 'staging' ] ; then # Automagically upgrade all addons and install new ones. Ideal for deployment process. - echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=all --load=${SERVER_WIDE_MODULES} --log-level=${LOG_LEVEL} --load-language=${LOAD_LANGUAGE} --limit-time-cpu=3600 --limit-time-real=7200 --dev= + echo odoo --config ${ODOO_RC} --database=${DB_NAME} --init=${INIT} --update=all --load=${LOAD} --log-level=${LOG_LEVEL} --load-language=${LOAD_LANGUAGE} --limit-time-cpu=3600 --limit-time-real=7200 --dev= exec odoo --config ${ODOO_RC} --update=all --without-demo=all --workers=0 --limit-time-cpu=3600 --limit-time-real=7200 --dev= fi if [ ${APP_ENV} = 'production' ] ; then # Bring up Odoo ready for production. - echo odoo --config ${ODOO_RC} --database= --init= --update= --load=${SERVER_WIDE_MODULES} --workers=${WORKERS} --log-level=${LOG_LEVEL} --load-language= --without-demo=all --dev= + echo odoo --config ${ODOO_RC} --database= --init= --update= --load=${LOAD} --workers=${WORKERS} --log-level=${LOG_LEVEL} --load-language= --without-demo=all --dev= exec odoo --config ${ODOO_RC} --database= --init= --update= --load-language= --without-demo=all --dev= fi diff --git a/odoo/odoorc.sh b/odoo/odoorc.sh index 51a2ed4..dafb911 100755 --- a/odoo/odoorc.sh +++ b/odoo/odoorc.sh @@ -20,6 +20,23 @@ while IFS='=' read -r key value || [[ -n $key ]]; do export "$key=$value" done < .env +# Check the USE_REDIS variable to decide whether to copy Redis directories +if [[ $USE_REDIS == "true" ]]; then + LOAD+=",session_redis" +fi + +# Check the USE_S3 variable to decide whether to copy S3 directories +if [[ $USE_S3 == "true" ]]; then + LOAD+=",base_attachment_object_storage,attachment_s3" +fi + +# Check if the repository directory exists and Sentry is to be used +if [[ $USE_SENTRY == "true" ]]; then + LOAD+=",sentry" +fi + +echo "Loading addons: $LOAD" + # Copy the example conf to the destination to start replacing the variables cp "$TEMPLATE_CONF" "$ODOO_RC" diff --git a/odoo/third-party-addons.sh b/odoo/third-party-addons.sh index 3873793..c562ec4 100755 --- a/odoo/third-party-addons.sh +++ b/odoo/third-party-addons.sh @@ -2,24 +2,21 @@ set -e -# Check if the repository directory exists and either Redis or S3 is to be used -if [[ ! -d "odoo-cloud-platform" && ( $USE_REDIS -eq 1 || $USE_S3 -eq 1 ) ]]; then - git clone https://github.com/odoocker/odoo-cloud-platform.git --depth 1 --branch ${ODOO_TAG} --single-branch --no-tags; -fi +# Always use base_attachment_object_storage +git clone https://github.com/odoocker/odoo-cloud-platform.git --depth 1 --branch $ODOO_TAG --single-branch --no-tags; +cp -r odoo-cloud-platform/base_attachment_object_storage $THIRD_PARTY_ADDONS/base_attachment_object_storage -# Check the USE_REDIS variable to decide whether to copy Redis directories -if [[ $USE_REDIS -eq 1 ]]; then - cp -r odoo-cloud-platform/session_redis ${THIRD_PARTY_ADDONS}/session_redis +if [[ $USE_REDIS == "true" ]]; then + cp -r odoo-cloud-platform/session_redis $THIRD_PARTY_ADDONS/session_redis fi # Check the USE_S3 variable to decide whether to copy S3 directories -if [[ $USE_S3 -eq 1 ]]; then - 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 +if [[ $USE_S3 == "true" ]]; then + cp -r odoo-cloud-platform/attachment_s3 $THIRD_PARTY_ADDONS/attachment_s3 fi # Check if the repository directory exists and Sentry is to be used -if [[ ! -d "server-tools" && $USE_SENTRY -eq 1 ]]; then - git clone https://github.com/odoocker/server-tools.git --depth 1 --branch ${ODOO_TAG} --single-branch --no-tags; - cp -r server-tools/sentry ${THIRD_PARTY_ADDONS}/sentry +if [[ $USE_SENTRY == "true" ]]; then + git clone https://github.com/odoocker/server-tools.git --depth 1 --branch $ODOO_TAG --single-branch --no-tags; + cp -r server-tools/sentry $THIRD_PARTY_ADDONS/sentry fi