From 82c87f37cc05a5b6f587acfd05e6f888e7fca0d3 Mon Sep 17 00:00:00 2001 From: Junior Oliveira Date: Fri, 22 Mar 2024 11:53:43 -0300 Subject: [PATCH] Merge infra to develop (#64) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adiciona Dockerfile para imagem de produção * Adiciona arquivos de configuração do tema MapaCe para produção * Corrige Dockerfile da imagem de produção * Atualiza os arquivos do github actions * Corrige arquivo ci.yml do github actions * Atualiza ci.yml para ajustar a branch do plugin MultipleLocalAuth --------- Co-authored-by: rafaelsdomingos --- .github/workflows/ci.yml | 92 ++++++++----------- .github/workflows/rc.yml | 53 ----------- Dockerfile | 68 ++++++++++++++ docker/common/config.d/0.main.php | 16 ++++ docker/common/config.d/logo.php | 18 ++++ docker/common/config.d/maps.php | 16 ++++ docker/common/config.d/plugins.php | 8 ++ docker/common/config.d/sharing.php | 6 ++ docker/common/config.php | 15 +++ docker/production/config.d/authentication.php | 40 ++++++++ src/plugins/MultipleLocalAuth | 2 +- 11 files changed, 224 insertions(+), 110 deletions(-) delete mode 100644 .github/workflows/rc.yml create mode 100644 Dockerfile create mode 100644 docker/common/config.d/0.main.php create mode 100644 docker/common/config.d/logo.php create mode 100644 docker/common/config.d/maps.php create mode 100644 docker/common/config.d/plugins.php create mode 100644 docker/common/config.d/sharing.php create mode 100644 docker/common/config.php create mode 100644 docker/production/config.d/authentication.php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33d0fccbf7..240ac6effd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,66 +1,46 @@ name: ci on: - push: - branches: - - "master" - - "develop" - tags: - - "v*.*.*" pull_request: - branches: - - "develop" + branches: + - homolog + + workflow_dispatch: jobs: - docker: + BUILD: runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - # list of Docker images to use as base name for tags - images: | - docker.io/hacklab/mapasculturais - # ghcr.io/username/app - # generate Docker tags based on the following events/attributes - tags: | - type=ref,event=branch - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Hub - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 + steps: + + - uses: actions/checkout@v4.1.1 + + - name: Docker Login + uses: docker/login-action@v3.0.0 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - # - - # name: Login to GHCR - # if: github.event_name != 'pull_request' - # uses: docker/login-action@v2 - # with: - # registry: ghcr.io - # username: ${{ github.repository_owner }} - # password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v4 + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Checkout submodules + run: git submodule update --init --recursive + + - name: Ajusta branch do MultipleLocalAuth + run: cd src/plugins/MultipleLocalAuth && git checkout v3.0.0 + + - name: Criação da Imagem docker + uses: docker/build-push-action@v5.0.0 with: - file: ./docker/Dockerfile - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + context: ./ + file: ./Dockerfile + push: true + tags: | + secultceara/mapascultural:7.3.7 + secultceara/mapascultural:latest + DEPLOY: + needs: BUILD + runs-on: mapahomolog + steps: + - name: Pull das imagens docker + run: cd /opt/docker/mapa7 && sudo docker-compose pull + - name: Restart do docker-compose para atualizar o container com a nova imagem + run: cd /opt/docker/mapa7 && sudo docker-compose down && sudo docker-compose up -d \ No newline at end of file diff --git a/.github/workflows/rc.yml b/.github/workflows/rc.yml deleted file mode 100644 index 42bcffca74..0000000000 --- a/.github/workflows/rc.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Release Candidate - -on: - push: - branches: - - "release/*" - -jobs: - docker: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Extract branch tag - id: tag - run: | - BRANCH=${{ github.ref_name }} - TAG="${BRANCH/release\//}" - echo "tag=$TAG-RC" >> $GITHUB_OUTPUT - echo "BRANCH=$BRANCH" >> $GITHUB_OUTPUT - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: | - docker.io/hacklab/mapasculturais - tags: ${{ steps.tag.outputs.tag }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Hub - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v4 - with: - file: ./docker/Dockerfile - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..f1fbf0c84f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,68 @@ +FROM php:8.2-fpm + +ENV PNPM_HOME=/root/.local/share/pnpm +ENV PATH=$PATH:/root/.local/share/pnpm +ENV COMPOSER_ALLOW_SUPERUSER=1 + +# Copy source +COPY composer.json /var/www/composer.json +COPY composer.lock /var/www/composer.lock +COPY config /var/www/config +COPY public /var/www/html +COPY scripts /var/www/scripts +COPY src /var/www/src +COPY var /var/www/var +COPY docker/common/config.d /var/www/config/common.d +COPY docker/production/config.d /var/www/config/prod.d +COPY docker/recreate-pending-pcache-cron.sh /recreate-pending-pcache-cron.sh +COPY docker/jobs-cron.sh /jobs-cron.sh +COPY docker/entrypoint.sh /entrypoint.sh +COPY version.txt /var/www/version.txt + + +RUN apt-get update && apt-get install -y --no-install-recommends \ + imagemagick libmagickcore-dev git libmagickwand-dev \ + libcurl4-gnutls-dev libpq-dev libfreetype6-dev libjpeg62-turbo-dev libpng-dev libzip-dev libzstd1 && \ + # Instalação do node + curl -sL https://deb.nodesource.com/setup_18.x | bash - && \ + apt-get install -y nodejs && \ + ## Instalação das extensões do node + npm install -g pnpm terser uglifycss autoprefixer postcss sass && \ + # Install extensions + docker-php-ext-install -j$(nproc) opcache pdo_pgsql zip xml curl opcache && \ + # Install GD + docker-php-ext-install -j$(nproc) iconv && \ + docker-php-ext-configure gd --with-jpeg && \ + docker-php-ext-install -j$(nproc) gd && \ + # Install APCu + no | pecl install apcu && echo "extension=apcu.so" > /usr/local/etc/php/conf.d/apcu.ini && \ + # Install imagick + autodetect | pecl install imagick && echo "extension=imagick.so" > /usr/local/etc/php/conf.d/ext-imagick.ini && \ + # Install igbinary + pecl install igbinary && docker-php-ext-enable igbinary && \ + # Install msgpack + yes | pecl install msgpack && echo "extension=msgpack.so" > /usr/local/etc/php/conf.d/msgpack.ini && \ + # Install redis + no | pecl install -o -f redis && docker-php-ext-enable redis && \ + # Install composer + php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \ + php composer-setup.php --install-dir=/usr/local/bin && \ + rm composer-setup.php && \ + #Execução do composer + cd /var/www && composer.phar install && \ + # Instalação dos pacotes node + cd /var/www/src && pnpm install --recursive && pnpm run build && \ + sass themes/BaseV1/assets/css/sass/main.scss:themes/BaseV1/assets/css/main.css && \ + # alteração das permissões + ln -s /var/www/html /var/www/public && \ + chown www-data:www-data -R /var/www && \ + # Limpeza do apt + rm -rf /var/lib/apt/lists + +WORKDIR /var/www + +ENTRYPOINT ["/entrypoint.sh"] + +EXPOSE 9000 + +CMD ["php-fpm"] diff --git a/docker/common/config.d/0.main.php b/docker/common/config.d/0.main.php new file mode 100644 index 0000000000..85f91a4b35 --- /dev/null +++ b/docker/common/config.d/0.main.php @@ -0,0 +1,16 @@ + 'Mapas Culturais do Ceará', + 'app.siteDescription' => 'O Mapas Culturais é uma plataforma colaborativa que reúne informações sobre agentes, espaços, eventos, projetos culturais e oportunidades', + + + // Define o tema ativo no site principal. Deve ser informado o namespace do tema e neste deve existir uma classe Theme. + 'themes.active' => 'MapasCE', + + // Ids dos selos verificadores. Para utilizar múltiplos selos informe os ids separados por vírgula. + 'app.verifiedSealsIds' => '1', + +]; \ No newline at end of file diff --git a/docker/common/config.d/logo.php b/docker/common/config.d/logo.php new file mode 100644 index 0000000000..c6236af47b --- /dev/null +++ b/docker/common/config.d/logo.php @@ -0,0 +1,18 @@ + 'Mapa Cultural', + + /* Segunda linha do logo configurável */ + 'logo.subtitle' => 'do Ceará', + + /* + Define a url da imagem da logo do site - Substituirá a logo padrão + */ + 'logo.image' => 'img/logo-Mapa-CE.png', + + /* Esconde o título e subtitulo */ + 'logo.hideLabel' => true, +]; diff --git a/docker/common/config.d/maps.php b/docker/common/config.d/maps.php new file mode 100644 index 0000000000..145a6f4e49 --- /dev/null +++ b/docker/common/config.d/maps.php @@ -0,0 +1,16 @@ + [ + -14.2400732, //latitude + -53.1805018 // longitude + ], + + 'maps.zoom.default' => 5, + 'maps.zoom.approximate' => 14, + 'maps.zoom.precise' => 16, + 'maps.zoom.max' => 18, + 'maps.zoom.min' => 5, + + 'maps.tileServer' => '//{s}.tile.osm.org/{z}/{x}/{y}.png', +]; \ No newline at end of file diff --git a/docker/common/config.d/plugins.php b/docker/common/config.d/plugins.php new file mode 100644 index 0000000000..5af51696bd --- /dev/null +++ b/docker/common/config.d/plugins.php @@ -0,0 +1,8 @@ + [ + 'MultipleLocalAuth' => [ 'namespace' => 'MultipleLocalAuth' ], + 'SamplePlugin' => ['namespace' => 'SamplePlugin'], + ] +]; \ No newline at end of file diff --git a/docker/common/config.d/sharing.php b/docker/common/config.d/sharing.php new file mode 100644 index 0000000000..b65b6d3bf4 --- /dev/null +++ b/docker/common/config.d/sharing.php @@ -0,0 +1,6 @@ + env('SHARE_IMAGE', 'img/share-square.png'), + 'share.image_twitter' => env('SHARE_IMAGE_TWITTER', 'img/share-square.png'), +]; \ No newline at end of file diff --git a/docker/common/config.php b/docker/common/config.php new file mode 100644 index 0000000000..bd85d94ec6 --- /dev/null +++ b/docker/common/config.php @@ -0,0 +1,15 @@ + '\MultipleLocalAuth\Provider', + 'auth.config' => array( + 'salt' => env('AUTH_SALT', null), + 'timeout' => '24 hours', + 'strategies' => [ + 'Facebook' => array( + 'app_id' => env('AUTH_FACEBOOK_APP_ID', null), + 'app_secret' => env('AUTH_FACEBOOK_APP_SECRET', null), + 'scope' => env('AUTH_FACEBOOK_SCOPE', 'email'), + ), + + 'LinkedIn' => array( + 'api_key' => env('AUTH_LINKEDIN_API_KEY', null), + 'secret_key' => env('AUTH_LINKEDIN_SECRET_KEY', null), + 'redirect_uri' => $_APP_BASE_URL . 'autenticacao/linkedin/oauth2callback', + 'scope' => env('AUTH_LINKEDIN_SCOPE', 'r_emailaddress') + ), + 'Google' => array( + 'client_id' => env('AUTH_GOOGLE_CLIENT_ID', null), + 'client_secret' => env('AUTH_GOOGLE_CLIENT_SECRET', null), + 'redirect_uri' => $_APP_BASE_URL . 'autenticacao/google/oauth2callback', + 'scope' => env('AUTH_GOOGLE_SCOPE', 'email'), + ), + 'Twitter' => array( + 'app_id' => env('AUTH_TWITTER_APP_ID', null), + 'app_secret' => env('AUTH_TWITTER_APP_SECRET', null), + ), + + ] + ), +]; diff --git a/src/plugins/MultipleLocalAuth b/src/plugins/MultipleLocalAuth index a3ff47d5ab..05ba57531b 160000 --- a/src/plugins/MultipleLocalAuth +++ b/src/plugins/MultipleLocalAuth @@ -1 +1 @@ -Subproject commit a3ff47d5ab162ea7bb024dc81149e74de942af7a +Subproject commit 05ba57531b4992c000f515ab5ef5ac59f6cdd577