Skip to content

Commit

Permalink
Corrige problema de empacotamento do plonegovbr.intranet
Browse files Browse the repository at this point in the history
  • Loading branch information
ericof committed Jul 10, 2024
1 parent 835427c commit c471e0b
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 19 deletions.
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ GIT_FOLDER=$(CURRENT_DIR)/.git

PROJECT_NAME=portalbrasil-intranet
STACK_NAME=intranet-demo-plone-org-br
STACK_FILE=docker-compose-dev.yml

VOLTO_VERSION = $(shell cat frontend/mrs.developer.json | python -c "import sys, json; print(json.load(sys.stdin)['core']['tag'])")
PLONE_VERSION=$(shell cat backend/version.txt)
Expand Down Expand Up @@ -131,28 +132,28 @@ build-images: ## Build docker images
.PHONY: stack-start
stack-start: ## Local Stack: Start Services
@echo "Start local Docker stack"
VOLTO_VERSION=$(VOLTO_VERSION) PLONE_VERSION=$(PLONE_VERSION) docker compose -f docker-compose.yml up -d --build
VOLTO_VERSION=$(VOLTO_VERSION) PLONE_VERSION=$(PLONE_VERSION) docker compose -f $(STACK_FILE) up -d --build
@echo "Now visit: http://portalbrasil-intranet.localhost"

.PHONY: start-stack
stack-create-site: ## Local Stack: Create a new site
@echo "Create a new site in the local Docker stack"
@docker compose -f docker-compose.yml exec backend ./docker-entrypoint.sh create-site
@docker compose -f $(STACK_FILE) exec backend ./docker-entrypoint.sh create-site

.PHONY: start-ps
stack-status: ## Local Stack: Check Status
@echo "Check the status of the local Docker stack"
@docker compose -f docker-compose.yml ps
@docker compose -f $(STACK_FILE) ps

.PHONY: stack-stop
stack-stop: ## Local Stack: Stop Services
@echo "Stop local Docker stack"
@docker compose -f docker-compose.yml stop
@docker compose -f $(STACK_FILE) stop

.PHONY: stack-rm
stack-rm: ## Local Stack: Remove Services and Volumes
@echo "Remove local Docker stack"
@docker compose -f docker-compose.yml down
@docker compose -f $(STACK_FILE) down
@echo "Remove local volume data"
@docker volume rm $(PROJECT_NAME)_vol-site-data

Expand Down
7 changes: 4 additions & 3 deletions backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ COPY . src
# Install local requirements and pre-compile mo files
RUN <<EOT
set -e
bin/pip install mxdev uv
bin/pip install mxdev uv hatch
cd /app/src
../bin/hatch build
../bin/mxdev -c mx.ini
../bin/uv pip install -r requirements-mxdev.txt
../bin/uv pip install dist/*.whl -c constraints-mxdev.txt
../bin/python /compile_mo.py
cd /app
rm -Rf src/
rm -Rf /app/src
EOT

FROM plone/server-prod-config:${PLONE_VERSION}
Expand Down
3 changes: 0 additions & 3 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ exclude = [
"/.github",
]

[tool.hatch.build.targets.wheel]
only-packages = true

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
Expand Down
Empty file.
113 changes: 113 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
name: portalbrasil-intranet-dev

services:
traefik:
image: traefik:v2.10

ports:
- 80:80

labels:
- traefik.enable=true
- traefik.constraint-label=public
- traefik.http.routers.traefik-public-http.rule=Host(`traefik.portalbrasil-intranet.localhost`)
- traefik.http.routers.traefik-public-http.entrypoints=http
- traefik.http.routers.traefik-public-http.service=api@internal
- traefik.http.services.traefik-public.loadbalancer.server.port=8000

# GENERIC MIDDLEWARES
- traefik.http.middlewares.gzip.compress=true
- traefik.http.middlewares.gzip.compress.excludedcontenttypes=image/png, image/jpeg, font/woff2

volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro

command:
- --providers.docker
- --providers.docker.constraints=Label(`traefik.constraint-label`, `public`)
- --providers.docker.exposedbydefault=false
- --entrypoints.http.address=:80
- --accesslog
- --log
- --api
frontend:
build:
context: ./frontend
args:
- VOLTO_VERSION=${VOLTO_VERSION}
environment:
RAZZLE_INTERNAL_API_PATH: http://backend:8080/Plone
depends_on:
- backend
labels:
- traefik.enable=true
- traefik.constraint-label=public
# Service
- traefik.http.services.svc-frontend.loadbalancer.server.port=3000
# Routers
## /
- traefik.http.routers.rt-frontend.rule=Host(`portalbrasil-intranet.localhost`)
- traefik.http.routers.rt-frontend.entrypoints=http
- traefik.http.routers.rt-frontend.service=svc-frontend
- traefik.http.routers.rt-frontend.middlewares=gzip

backend:
build:
context: ./backend
args:
- PLONE_VERSION=${PLONE_VERSION}
environment:
RELSTORAGE_DSN: "dbname='${DB_NAME:-plone}' user='${DB_NAME:-plone}' host='${DB_HOST:-db}' password='${DB_PASSWORD:-HxfQYJgHCtjM}' port='${DB_PORT:-5432}'"
ZOPE_FORM_MEMORY_LIMIT: 250MB
HONEYPOT_FIELD: your_email
depends_on:
- db
labels:
- traefik.enable=true
- traefik.constraint-label=public
# Services
- traefik.http.services.svc-backend.loadbalancer.server.port=8080

# Middlewares
## VHM rewrite /++api++/
- "traefik.http.middlewares.mw-backend-vhm-api.replacepathregex.regex=^/\\+\\+api\\+\\+($$|/.*)"
- "traefik.http.middlewares.mw-backend-vhm-api.replacepathregex.replacement=/VirtualHostBase/http/portalbrasil-intranet.localhost/Plone/++api++/VirtualHostRoot$$1"

## VHM rewrite /ClassicUI/
- "traefik.http.middlewares.mw-backend-vhm-classic.replacepathregex.regex=^/ClassicUI($$|/.*)"
- "traefik.http.middlewares.mw-backend-vhm-classic.replacepathregex.replacement=/VirtualHostBase/http/portalbrasil-intranet.localhost/Plone/VirtualHostRoot/_vh_ClassicUI$$1"

## Basic Authentication
### Note: all dollar signs in the hash need to be doubled for escaping.
### To create user:password pair, it's possible to use this command:
### echo $(htpasswd -nb user password) | sed -e s/\\$/\\$\\$/g
### Defaults to admin:admin
- traefik.http.middlewares.mw-backend-auth.basicauth.users=admin:$$apr1$$uZPT5Fgu$$AmlIdamxT5ipBvPlsdfD70
# Routers
- traefik.http.routers.rt-backend-api.rule=Host(`portalbrasil-intranet.localhost`) && (PathPrefix(`/++api++`))
- traefik.http.routers.rt-backend-api.entrypoints=http
- traefik.http.routers.rt-backend-api.service=svc-backend
- traefik.http.routers.rt-backend-api.middlewares=gzip,mw-backend-vhm-api
## /ClassicUI
- traefik.http.routers.rt-backend-classic.rule=Host(`portalbrasil-intranet.localhost`) && PathPrefix(`/ClassicUI`)
- traefik.http.routers.rt-backend-classic.entrypoints=http
- traefik.http.routers.rt-backend-classic.service=svc-backend
- traefik.http.routers.rt-backend-classic.middlewares=gzip,mw-backend-auth,mw-backend-vhm-classic
## admin
- traefik.http.routers.rt-backend-classic.rule=Host(`admin.portalbrasil-intranet.localhost`)
- traefik.http.routers.rt-backend-classic.entrypoints=http
- traefik.http.routers.rt-backend-classic.service=svc-backend
- traefik.http.routers.rt-backend-classic.middlewares=gzip,mw-backend-auth

db:
image: postgres:14
environment:
POSTGRES_USER: plone
POSTGRES_PASSWORD: HxfQYJgHCtjM
POSTGRES_DB: plone
volumes:
- vol-site-data:/var/lib/postgresql/data

volumes:
vol-site-data: {}
12 changes: 4 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ services:
- --log
- --api
frontend:
build:
context: ./frontend
args:
- VOLTO_VERSION=${VOLTO_VERSION}
image: ghcr.io/plonegovbr/portalbrasil-intranet-frontend:latest
platform: linux/amd64
environment:
RAZZLE_INTERNAL_API_PATH: http://backend:8080/Plone
depends_on:
Expand All @@ -53,10 +51,8 @@ services:
- traefik.http.routers.rt-frontend.middlewares=gzip

backend:
build:
context: ./backend
args:
- PLONE_VERSION=${PLONE_VERSION}
image: ghcr.io/plonegovbr/portalbrasil-intranet-backend:latest
platform: linux/amd64
environment:
RELSTORAGE_DSN: "dbname='${DB_NAME:-plone}' user='${DB_NAME:-plone}' host='${DB_HOST:-db}' password='${DB_PASSWORD:-HxfQYJgHCtjM}' port='${DB_PORT:-5432}'"
ZOPE_FORM_MEMORY_LIMIT: 250MB
Expand Down

0 comments on commit c471e0b

Please sign in to comment.