Skip to content

Commit

Permalink
imp: added docker-compose file
Browse files Browse the repository at this point in the history
  • Loading branch information
dduarte-odoogap committed Feb 6, 2022
1 parent 9195926 commit f18ad8a
Show file tree
Hide file tree
Showing 9 changed files with 313 additions and 3 deletions.
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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" ]
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ REDIS_PASSWORD=<redis_password>

or use environment variables

``` bash
```bash
export BASE_URL=<base_url>
export REDIS_HOST=<redis_host>
export REDIS_PORT=<redis_port>
Expand All @@ -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
Expand Down
117 changes: 117 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions docker/14.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
40 changes: 40 additions & 0 deletions docker/14.0/odoo.conf
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions docker/14.0/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
redis==4.0.2
graphene==3.0
graphql-server==3.0.0b4
4 changes: 4 additions & 0 deletions docker/14.0/start_script.py
Original file line number Diff line number Diff line change
@@ -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()
89 changes: 89 additions & 0 deletions docker/nginx/templates/default.conf.template
Original file line number Diff line number Diff line change
@@ -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;

}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit f18ad8a

Please sign in to comment.