diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..c1c60577 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +FROM node:14 as vsf-pre + +WORKDIR /app + +COPY . / + +RUN apt-get install -y --no-install-recommends git \ + && yarn install \ + --prefer-offline \ + --frozen-lockfile \ + --non-interactive \ + --production=false + +RUN yarn build + +RUN rm -rf node_modules && \ + NODE_ENV=development yarn install \ + --prefer-offline \ + --pure-lockfile \ + --non-interactive \ + --production=false + +FROM node:14 as vsf2 + +WORKDIR /app + +COPY --from=vsf-pre /app . + +ENV HOST 0.0.0.0 + + +CMD [ "yarn", "start" ] diff --git a/README.md b/README.md index 3bbcb05c..c674ae5d 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ REDIS_PASSWORD= or use environment variables -``` bash +```bash export BASE_URL= export REDIS_HOST= export REDIS_PORT= @@ -42,6 +42,16 @@ yarn dev yarn build ``` +or use docker-compose + +```bash +docker-compose up --build -d +# you might need to +docker-compose restart odoo nginx +``` + + + Want to contribute? Ping us on `odoo` channel on [our Discord](https://discord.vuestorefront.io) or email us at info (at) odoogap.com! ## Resources diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..f7af1f95 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,117 @@ +version: "3.7" + + +services: + + redis: + container_name: redis + image: library/redis:5.0-alpine + restart: unless-stopped + networks: + - net1 + volumes: + - redis_data:/data + + nginx: + env_file: .env + image: nginx:latest + container_name: nginx + restart: unless-stopped + depends_on: + - odoo + ports: + - ${TEST_VSF_DOCKER_PORT}:${TEST_VSF_DOCKER_PORT} + - ${TEST_ODOO_DOCKER_PORT}:${TEST_ODOO_DOCKER_PORT} + volumes: + - ./docker/nginx/templates:/etc/nginx/templates + - web_root:/var/www/html + networks: + - net1 + + db: + env_file: .env + image: postgres:12 + container_name: db + restart: unless-stopped + networks: + - net1 + volumes: + - db_home:/var/lib/postgresql/data + environment: + - POSTGRES_USER=odoo + - POSTGRES_PASSWORD=odoo + - POSTGRES_DB=v14_odoo + + odoo_init: + env_file: .env + build: + context: ./docker/14.0 + dockerfile: Dockerfile + container_name: odoo_ini + working_dir: "/mnt/extra-addons" + command: > + bash -c "if [ ! -d "/mnt/extra-addons/graphql_vuestorefront" ]; then git clone --branch 14.0 https://github.com/odoogap/vuestorefront.git . + && git submodule update --init --recursive + && /entrypoint.sh odoo -d v14_odoo -i base --max-cron-threads 0 --no-http --stop-after-init -i graphql_vuestorefront + && /entrypoint.sh odoo shell -d v14_odoo --max-cron-threads 0 --no-http < /start_script.py ; fi" + image: odoogap + restart: "no" + volumes: + - odoo_home:/var/lib/odoo + - odoo_extra:/mnt/extra-addons + - ./docker/14.0/odoo.conf:/etc/odoo/odoo.conf + - ./docker/14.0/start_script.py:/start_script.py + depends_on: + - db + networks: + - net1 + + odoo: + env_file: .env + build: + context: ./docker/14.0 + dockerfile: Dockerfile + container_name: odoo + image: odoogap + restart: unless-stopped + volumes: + - odoo_home:/var/lib/odoo + - odoo_extra:/mnt/extra-addons + - ./docker/14.0/odoo.conf:/etc/odoo/odoo.conf + depends_on: + - db + networks: + - net1 + + vsf: + env_file: .env + environment: + BASE_URL: http://localhost:8069/ + BACKEND_BASE_URL: http://odoo:8069/ + REDIS_HOST: redis + REDIS_PORT: 6379 + container_name: vsf + image: vsf2 + restart: unless-stopped + depends_on: + - redis + - odoo + networks: + - net1 + + +volumes: + db_home: + external: false + odoo_home: + external: false + odoo_extra: + external: False + web_root: + external: false + redis_data: + external: false + +networks: + net1: + name: net1 diff --git a/docker/14.0/Dockerfile b/docker/14.0/Dockerfile new file mode 100644 index 00000000..09e3756d --- /dev/null +++ b/docker/14.0/Dockerfile @@ -0,0 +1,15 @@ +FROM odoo:14.0 AS odoogap + +USER root + +COPY ./requirements.txt / + +RUN apt-get update \ + && apt-get install -y --no-install-recommends git \ + && python3 -m pip install --no-cache-dir -r requirements.txt \ + && apt-get clean \ + && rm -rf /var/lib/apt/lists/* + +USER odoo + +CMD ["odoo"] \ No newline at end of file diff --git a/docker/14.0/odoo.conf b/docker/14.0/odoo.conf new file mode 100644 index 00000000..dc7a2b79 --- /dev/null +++ b/docker/14.0/odoo.conf @@ -0,0 +1,40 @@ +[options] +addons_path = /mnt/extra-addons +data_dir = /var/lib/odoo +; admin_passwd = admin +; csv_internal_sep = , +; db_maxconn = 64 +db_name = v14_odoo +db_user = odoo +db_password = odoo +db_host = db +; db_template = template1 +dbfilter = ^v14_odoo$ +; debug_mode = False +; email_from = False +; limit_memory_hard = 2684354560 +; limit_memory_soft = 2147483648 +; limit_request = 8192 +; limit_time_cpu = 60 +; limit_time_real = 120 +; list_db = True +; log_db = False +; log_handler = [':INFO'] +; log_level = info +; logfile = None +; longpolling_port = 8072 +; max_cron_threads = 2 +; osv_memory_age_limit = 1.0 +; osv_memory_count_limit = False +; smtp_password = False +; smtp_port = 25 +; smtp_server = localhost +; smtp_ssl = False +; smtp_user = False +workers = 3 +; xmlrpc = True +; xmlrpc_interface = +; xmlrpc_port = 8069 +; xmlrpcs = True +; xmlrpcs_interface = +; xmlrpcs_port = 8071 diff --git a/docker/14.0/requirements.txt b/docker/14.0/requirements.txt new file mode 100644 index 00000000..3a838995 --- /dev/null +++ b/docker/14.0/requirements.txt @@ -0,0 +1,3 @@ +redis==4.0.2 +graphene==3.0 +graphql-server==3.0.0b4 \ No newline at end of file diff --git a/docker/14.0/start_script.py b/docker/14.0/start_script.py new file mode 100644 index 00000000..8579048b --- /dev/null +++ b/docker/14.0/start_script.py @@ -0,0 +1,4 @@ +#!/bin/python +env['ir.config_parameter'].set_param('web.base.url', 'http://localhost:8069') +env['ir.config_parameter'].set_param('web.base.url.freeze', 'True') +env.cr.commit() \ No newline at end of file diff --git a/docker/nginx/templates/default.conf.template b/docker/nginx/templates/default.conf.template new file mode 100644 index 00000000..6587c5a3 --- /dev/null +++ b/docker/nginx/templates/default.conf.template @@ -0,0 +1,89 @@ +upstream up-vsf { + least_conn; + server vsf:3000; +} +upstream up-odoo { + least_conn; + server odoo:8069; +} +upstream up-long { + least_conn; + server odoo:8072; +} + +# Vuestorefront2 Server +server { + listen ${TEST_VSF_DOCKER_PORT}; + + proxy_read_timeout 720s; + proxy_connect_timeout 720s; + proxy_send_timeout 720s; + + proxy_buffers 16 64k; + proxy_buffer_size 128k; + client_max_body_size 10M; + + # Redirect requests to vsf1 backend server + location / { + proxy_set_header X-Forwarded-Port ${TEST_VSF_DOCKER_PORT}; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-Host $server_name:${TEST_VSF_DOCKER_PORT}; + proxy_set_header X-Nginx-Proxy true; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + + proxy_pass http://up-vsf; + proxy_redirect off; + proxy_read_timeout 240s; + } + + # Common gzip + gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript; + gzip on; + +} + +# Odoo Server +server { + listen ${TEST_ODOO_DOCKER_PORT}; + + proxy_read_timeout 720s; + proxy_connect_timeout 720s; + proxy_send_timeout 720s; + + proxy_buffers 16 64k; + proxy_buffer_size 128k; + client_max_body_size 10M; + + proxy_http_version 1.1; + proxy_set_header X-Forwarded-Host $server_name:${TEST_ODOO_DOCKER_PORT}; + proxy_set_header X-Forwarded-Port ${TEST_ODOO_DOCKER_PORT}; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Real-IP $remote_addr; + + location ~* ^/([^/]+/static/|web/(css|js)/|web/image|web/content|website/image/) { + proxy_cache_valid 200 60m; + proxy_buffering on; + expires 30d; + proxy_pass http://up-odoo; + } + + location /longpolling { + proxy_pass http://up-long; + } + + # Redirect requests to odoo backend server + location / { + proxy_redirect off; + proxy_pass http://up-odoo; + } + + # Common gzip + gzip_types text/css text/less text/plain text/xml application/xml application/json application/javascript; + gzip on; + +} diff --git a/package.json b/package.json index 6dbdbd73..1f770f31 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,8 @@ "cookie-universal-nuxt": "^2.1.3", "core-js": "^2.6.5", "nuxt": "2.15.6", + "@nuxt/image": "^0.6.1", + "@nuxt/types": "latest", "nuxt-i18n": "^6.5.0", "nuxt-precompress": "^0.5.9", "redis-tag-cache": "^1.2.1", @@ -40,8 +42,6 @@ "@nuxtjs/tailwindcss": "^4.1.3" }, "devDependencies": { - "@nuxt/image": "^0.6.1", - "@nuxt/types": "latest", "@nuxt/typescript-build": "latest", "@vue/test-utils": "^1.0.0-beta.27", "autoprefixer": "^10.2.6",