Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] Run all projects within the same network #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
data/custom/repositories/*
data/custom/*
data/default

docker-compose.override.yml
48 changes: 30 additions & 18 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
version: "3.5"
services:

db:
container_name: db-${ODOO_VERSION}
image: postgres:15
environment:
- POSTGRES_USER=odoo
- POSTGRES_PASSWORD=odoo
- POSTGRES_DB=postgres
- PGDATA=/var/lib/postgresql/data/pgdata
command:
- -p 54${ODOO_VERSION}
volumes:
- pg_data:/var/lib/postgresql/data/pgdata
networks:
adhoc:
ipv4_address: 172.40.${ODOO_VERSION}.110

aeroo:
image: adhoc/aeroo-docs
restart: unless-stopped
networks:
adhoc:

mailhog:
image: mailhog/mailhog:latest
restart: always
Expand All @@ -24,20 +30,23 @@ services:
- 8025:8025
networks:
adhoc:

dns:
image: cytopia/bind:alpine-0.30
environment:
DNS_A: "*.odoo.localhost=172.20.${ODOO_VERSION}.1"
DNS_A: "*.localhost=172.40.0.1"
DNS_FORWARDER: 127.0.0.11
networks:
adhoc:
ipv4_address: 172.20.${ODOO_VERSION}.10
ipv4_address: 172.40.${ODOO_VERSION}.10

odoo:
# user: root
# build:
# context: ./data
# dockerfile: Dockerfile
image: $ODOO_IMAGE:$ODOO_MINOR
container_name: odoo-${ODOO_VERSION}
depends_on:
- db
- dns
Expand All @@ -48,15 +57,18 @@ services:
- odoo_data:/home/odoo/data
labels:
- traefik.enable=true
- traefik.frontend.port=8069
- traefik.frontend.rule=HostRegexp:$DOMAIN,{subdomain:[a-z0-9-_]+}.$DOMAIN
# - traefik.frontend.priority=10
# - traefik.longpolling.port=8072
# - traefik.longpolling.frontend.rule=HostRegexp:$DOMAIN,{subdomain:[a-z0-9-_]+}.$DOMAIN;PathPrefix:/longpolling/
- traefik.backend.loadbalancer.stickiness=true
- traefik.backend.loadbalancer.method=drr
# traefik.frontend.redirect.regex: $strTraefikRedirectRegex
# traefik.frontend.redirect.replacement: $strTraefikRedirectReplacement
- traefik.docker.network=adhoc
- traefik.http.services.odoo-${ODOO_VERSION}.loadbalancer.server.port=8069
- traefik.http.routers.odoo-${ODOO_VERSION}.service=odoo-${ODOO_VERSION}
- traefik.http.routers.odoo-${ODOO_VERSION}.entrypoints=web
- traefik.http.routers.odoo-${ODOO_VERSION}.rule=Host(`$DOMAIN`) || HostRegexp(`{subdomain:[a-z0-9-_]+}.$DOMAIN`)
# solo activar si se va a trabajar con workers (workers != 0)
# longpolling / websocket
# - traefik.http.services.long-${ODOO_VERSION}.loadbalancer.server.port=8072
# - traefik.http.routers.long-${ODOO_VERSION}.rule=Host(`$DOMAIN`) || HostRegexp(`{subdomain:[a-z0-9-_]+}.$DOMAIN`) && (PathPrefix(`/longpolling`) || PathPrefix(`/websocket`))
# - traefik.http.routers.long-${ODOO_VERSION}.entrypoints=web
# - traefik.http.routers.long-${ODOO_VERSION}.service=long-${ODOO_VERSION}

environment:
CUSTOM_CONFIG: |-
[options]
Expand All @@ -66,6 +78,8 @@ services:
#!/bin/bash
# pip install --user --no-cache-dir -e /home/odoo/custom/odoo
# pip install --user --no-cache-dir pyopenssl
PGHOST: db-${ODOO_VERSION}
PGPORT: 54${ODOO_VERSION}
SMTP_SERVER: mailhog
SMTP_PORT: 1025
DBFILTER: ${DBFILTER}
Expand All @@ -84,9 +98,10 @@ services:
ODOO_UPGRADE_PATH: ${ODOO_UPGRADE_PATH}
IGNORE_SRC_REPOSITORIES: ${IGNORE_SRC_REPOSITORIES}
dns:
- 172.20.${ODOO_VERSION}.10
- 172.40.${ODOO_VERSION}.10
networks:
adhoc:
ipv4_address: 172.40.${ODOO_VERSION}.100

volumes:
pg_data:
Expand All @@ -95,8 +110,5 @@ volumes:

networks:
adhoc:
external: false
name: adhoc-${ODOO_VERSION}
ipam:
config:
- subnet: 172.20.${ODOO_VERSION}.0/24
name: adhoc
external: true
13 changes: 11 additions & 2 deletions scripts/initial_setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
#!/bin/bash
docker-compose -p traefik -f traefik.yml up -d

# Create adhoc network if it doesn't exist
if ! docker network inspect adhoc > /dev/null 2>&1; then
docker network create --subnet=172.40.0.0/16 adhoc
fi

# Start traefik
docker compose -p traefik -f traefik.yml up -d

# Link volumes
DIR="$(cd "$(dirname "$0")" && pwd)"
$DIR/link_volumes.sh
$DIR/link_volumes.sh
51 changes: 31 additions & 20 deletions traefik.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
version: '2.1'
services:
traefik:
image: traefik:v1.7.33-alpine
command:
- --api
- --docker
- --docker.domain=localhost
- --docker.exposedbydefault=false
# ports:
# - 80:80
# - 8080:8080
labels:
- traefik.enable=true
- traefik.port=8080
- traefik.frontend.rule=Host:traefik.localhost
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
restart: unless-stopped
# para que funcione la solución *.localhost
network_mode: "host"

traefik:
image: traefik:v2.10.1
container_name: traefik
command:
- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.tcp.address=:5432"
ports:
- "80:80"
- "443:443"
- "8080:8080"
labels:
- traefik.enable=true
- traefik.port=8080
- traefik.frontend.rule=Host:traefik.localhost
- traefik.http.routers.myservice.rule=Host(`traefik.localhost`)
- traefik.http.services.myservice.loadbalancer.server.port=8080
networks:
- adhoc
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
restart: unless-stopped

networks:
adhoc:
name: adhoc
external: true