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

Criação da imagem Docker ghcr.io/plonegovbr/portal #1

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
106 changes: 106 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Roda testes e gera imagem

on:
push:
workflow_dispatch:

env:
node-version: 18.x
VOLTO_VERSION: "17.0.0-alpha.16"
YARN_CACHE_FOLDER: "/home/runner/.cache/.yarn"
IMAGE_NAME: ghcr.io/plonegovbr/portal

jobs:

code-analysis:
runs-on: ubuntu-latest
steps:
- name: Checkout codebase
uses: actions/checkout@v3

- name: Update Global Yarn
run: |
corepack enable
corepack prepare yarn@stable --activate

- name: Use Node.js ${{ env.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
cache: 'yarn'
cache-dependency-path: 'yarn.lock'

- name: Prettier
id: prettier
run: npx [email protected] --single-quote --check 'src/**/*.{js,jsx,ts,tsx,css,scss}' --config=package.json

- name: Install packages
run: make install-ci

- name: ESLint
id: eslint
if: ${{ success() || failure() }}
run: yarn run lint:ci

- name: Unit Tests
id: unit
if: ${{ success() || failure() }}
run: make test

- name: Report
if: ${{ success() || failure() }}
run: |
echo '# Code Analysis' >> $GITHUB_STEP_SUMMARY
echo '| Test | Status |' >> $GITHUB_STEP_SUMMARY
echo '| --- | --- |' >> $GITHUB_STEP_SUMMARY
echo '| Prettier | ${{ steps.prettier.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
echo '| ESLint | ${{ steps.eslint.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
echo '| i18n | ${{ steps.i18n.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY
echo '| Unit Tests | ${{ steps.unit.conclusion == 'failure' && '❌' || ' ✅' }} |' >> $GITHUB_STEP_SUMMARY

release:
runs-on: ubuntu-latest
needs:
- code-analysis
permissions:
contents: read
packages: write

steps:

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.IMAGE_NAME }}
labels: |
org.label-schema.docker.cmd=docker run -d -p 3000:3000 ${{ env.IMAGE_NAME }}:latest
flavor:
latest=false
tags: |
type=ref,event=branch
type=sha
type=raw,value=latest,enable={{is_default_branch}}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
platforms: linux/amd64,linux/arm64
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: $${{ steps.meta.outputs.labels }}
783 changes: 783 additions & 0 deletions .yarn/releases/yarn-3.2.3.cjs

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# syntax=docker/dockerfile:1
ARG VOLTO_VERSION
FROM plone/frontend-builder:${VOLTO_VERSION} as builder

ARG PB_ADDONS="@plonegovbr/volto-brasil-site,@plonegovbr/volto-brasil-theme"
ARG PB_WORKSPACES="src/addons/volto-brasil-site,src/addons/volto-brasil-theme"
ARG PB_THEME="@kitconcept/volto-light-theme"

COPY ./dockerfiles/helper.py /setupAddon
COPY --chown=node:node ./dockerfiles/mrs.developer.json /app/mrs.developer.json
COPY --chown=node:node ./ /app/src/addons/volto-brasil-site/

RUN <<EOT
set -e
npx -p mrs-developer missdev --config=jsconfig.json --output=addons --fetch-https
/setupAddon
yarn install --network-timeout 1000000
yarn build
rm -rf cache omelette .yarn/cache
EOT

FROM plone/frontend-prod-config:${VOLTO_VERSION}

LABEL maintainer="PloneGov-Br <[email protected]>" \
org.label-schema.name="volto-brasil-site" \
org.label-schema.description="Site do PortalBrasil" \
org.label-schema.vendor="PloneGov-Br"

COPY --from=builder /app/ /app/
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ RESET=`tput sgr0`
YELLOW=`tput setaf 3`

PLONE_VERSION=6
VOLTO_VERSION=17.0.0-alpha.14
VOLTO_VERSION=17.0.0-alpha.16

IMAGE_NAME=ghcr.io/plonegovbr/portal
IMAGE_TAG=latest

ADDON_NAME='@plonegovbr/volto-brasil-site'
ADDON_PATH='volto-brasil-site'
Expand Down Expand Up @@ -127,3 +130,11 @@ status-test-acceptance-server: ## Status of Acceptance Server
.PHONY: debug-frontend
debug-frontend: ## Run bash in the Frontend container
${DOCKER_COMPOSE} run --entrypoint bash addon-dev

.PHONY: install-ci
install-ci: ## Install this package in CI
yarn install

.PHONY: build-image
build-image: ## Build Docker Image
@DOCKER_BUILDKIT=1 docker build . -t $(IMAGE_NAME):$(IMAGE_TAG) -f Dockerfile --build-arg VOLTO_VERSION=$(VOLTO_VERSION)
47 changes: 47 additions & 0 deletions dockerfiles/helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/python3
"""Addon support for Volto."""
from pathlib import Path

import json
import logging
import os


logger = logging.getLogger("Volto Helper")


APP_FOLDER = Path("/app").resolve()
PACKAGE_JSON_PATH = (APP_FOLDER / "package.json").resolve()
JSCONFIG_PATH = (APP_FOLDER / "jsconfig.json").resolve()


ADDONS = os.environ.get("PB_ADDONS", "")
WORKSPACES = os.environ.get("PB_WORKSPACES", "")
THEME = os.environ.get("PB_THEME", "")


def add_packages_to_package_json(config: dict, addons: list, workspaces: list, theme: str) -> dict:
"""Add addons to the main `package.json`."""
addons_ = config.get("addons", [])
workspaces_ = config.get("workspaces", [])
for addon in addons:
addons_.append(addon)
for workspace in workspaces:
workspaces_.append(workspace)
config["addons"] = addons_
config["workspaces"] = workspaces_
config["theme"] = theme
return config


if ADDONS:
logger.info("Processing the ADDONS variable.")
addons = ADDONS.split(",")
workspaces = WORKSPACES.split(",")
package_json = add_packages_to_package_json(
json.load(open(PACKAGE_JSON_PATH)),
addons,
workspaces,
THEME
)
json.dump(package_json, open(PACKAGE_JSON_PATH, "w"), indent=2)
19 changes: 19 additions & 0 deletions dockerfiles/mrs.developer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"volto-light-theme": {
"package": "@kitconcept/volto-light-theme",
"url": "[email protected]:kitconcept/volto-light-theme.git",
"https": "https://github.com/kitconcept/volto-light-theme.git",
"path": "src",
"branch": "main"
},
"volto-brasil-site": {
"local": "addons/volto-brasil-site/src"
},
"volto-brasil-theme": {
"package": "@plonegovbr/volto-brasil-theme",
"url": "[email protected]:plonegovbr/volto-brasil-theme.git",
"https": "https://github.com/plonegovbr/volto-brasil-theme.git",
"path": "src",
"branch": "main"
}
}
8 changes: 2 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,8 @@ const applyConfig = (config) => {
blockHasOwnFocusManagement: false,
};

// Grid Block
config.blocks.blocksConfig.__grid.gridAllowedBlocks = [
...config.blocks.blocksConfig.__grid.gridAllowedBlocks,
'eAgendas',
'video',
];
// Remove old Grid Block
config.blocks.blocksConfig.__grid.restricted = true;
// Twitter
config.blocks.blocksConfig.tweetBlock = {
...config.blocks.blocksConfig.tweetBlock,
Expand Down
Loading