From 36cc982f6980bb10cb40a48135c32f7069803c99 Mon Sep 17 00:00:00 2001 From: Pierre Gauthier Date: Fri, 3 Jan 2025 09:01:45 +0100 Subject: [PATCH] Deploy script & Clean ReadMe --- .env | 2 +- .github/workflows/deploy-demo.yml | 40 +++++++ README.md | 110 +----------------- compose.override.yaml => compose.override.yml | 16 ++- compose.yaml => compose.yml | 0 src/package.json | 1 - 6 files changed, 56 insertions(+), 113 deletions(-) create mode 100644 .github/workflows/deploy-demo.yml rename compose.override.yaml => compose.override.yml (84%) rename compose.yaml => compose.yml (100%) diff --git a/.env b/.env index 6429b4d..4a8d5f9 100644 --- a/.env +++ b/.env @@ -8,7 +8,7 @@ ORO_IMAGE_INIT=${ORO_IMAGE}-init # Variables used internal in instances ORO_USER_RUNTIME=www-data -ORO_ENV=prod +ORO_ENV=dev # Data for install ORO_USER_NAME=admin diff --git a/.github/workflows/deploy-demo.yml b/.github/workflows/deploy-demo.yml new file mode 100644 index 0000000..83b4dda --- /dev/null +++ b/.github/workflows/deploy-demo.yml @@ -0,0 +1,40 @@ +name: Deploy demo + +on: + workflow_dispatch: + +jobs: + deploy-demo: + name: Deploy demo + runs-on: ubuntu-latest + if: always() + steps: + - name: Deploy in EC2 + env: + BRANCH: ${{ format('origin/{0}', github.ref_name) }} + PRIVATE_KEY: ${{ secrets.AWS_DEPLOY_KEY }} + HOSTNAME : ${{ secrets.AWS_HOSTNAME }} + USER_NAME : ${{ secrets.AWS_USER }} + run: | + echo "$PRIVATE_KEY" > private_key && chmod 600 private_key + ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} " + cd /home/ubuntu/ && + [ -d oro ] || git clone https://github.com/Elastic-Suite/oro-demo.git oro && + cd /home/ubuntu/oro && + [ -d src/packages/GallyPlugin ] || git clone https://github.com/Elastic-Suite/gally-oro-connector.git src/packages/GallyPlugin && + docker system prune -af && + ([[ $(docker volume ls -q | awk '!/_/' | wc -l) -eq 0 ]] || docker volume rm $(docker volume ls -q | awk '!/_/' | tr '\n' ' ')) && + docker compose down && + git fetch --all && git reset --hard && git checkout ${{ env.BRANCH }} && + cd /home/ubuntu/oro/src/packages/GallyPlugin && + git fetch --all && git reset --hard && git checkout ${{ env.BRANCH }} && + cd /home/ubuntu/oro && + docker compose -f compose.yml run --rm php-fpm-app bash -c "source ~/.bashrc; composer install" && + mkdir -p src/public/media && + sudo chown ubuntu:ubuntu -R src && + docker compose -f compose.yml up install && + docker compose -f compose.yml up -d --build && + docker compose exec php-fpm-app composer repositories.gally-connector '{ "type": "path", "url": "./packages/GallyPlugin", "options": { "versions": { "gally/oro-plugin": "2.0.0"}} }' && + docker compose exec php-fpm-app composer require gally/oro-plugin:2.0.0 && + docker compose exec php-fpm-app bin/console cache:clear + " diff --git a/README.md b/README.md index f53d925..28534f8 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,11 @@ bin/php-cs-fixer fix --diff packages/GallyPlugin/ bin/phpstan --memory-limit=1G analyse -c packages/GallyPlugin/phpstan.neon bin/phpunit --config phpunit.xml.dist packages/GallyPlugin/ --stop-on-fail ``` +Create/edit js files +```shell +docker compose exec php-fpm-app bin/console oro:assets:install --relative-symlink # Only required once on js creation +docker compose exec php-fpm-app bin/console oro:assets:build --watch +``` ## How this env was build @@ -50,108 +55,3 @@ mv oro src # Add user id / group id in .env ``` -## Prerequisites - -Install [Docker](https://docs.docker.com/engine/install/) with [Docker Compose](https://docs.docker.com/compose/install/). - -**Note:** The application uses port 80, so make sure that other services do not use it. - -## Run Application - -#### 1. Download Repository With Docker Compose Configuration File - -Check out the git repository: -```bash -git clone https://github.com/oroinc/docker-demo.git -cd docker-demo -``` -Or download the archive file and extract it: -```bash -wget https://github.com/oroinc/docker-demo/archive/master.tar.gz -O - | tar -xzf - -cd docker-demo -``` - -#### 2. Run Application Containers - -The configuration is entirely predefined, and you can only change the domain name where the application will be located. By default, it is `oro.demo`. If you need to change the domain, edit the `.env` file and change `ORO_APP_DOMAIN=my-custom-domain.demo`. - -Run init service: -```bash -docker compose up restore -``` - -Alternatively, you can install the application from scratch, but it will require more time and resources. - -Run install service: -```bash -docker compose up install -``` - -You can run the application as soon as it is installed or initialized. - -Run application: -```bash -docker compose up application -``` - -The docker compose will download the required images, create networks and run containers. -Application [orocommerce-application](https://github.com/oroinc/orocommerce-application) is used by default. -You can run other community applications, such as `crm-application`, `platform-application`, or `commerce-crm-application`. -To select another application, set another image in the `.env` file, for example: -```bash -ORO_IMAGE=docker.io/oroinc/crm-application -``` -If you want to get the application in a different locale, add the contents of the file `.env-locale-de_DE` or `.env-locale-fr_FR` to `.env` and restart the restore service and application. -```bash -cat .env-locale-de_DE >> .env -``` - -To track the logs from the php-fpm-app container, run `docker compose logs -f php-fpm-app`. To get the list of containers, run `docker compose ps`. - -#### 3. Add a Record to File `/etc/hosts` - -``` -127.0.0.1 oro.demo -``` - -#### 4. Open the Application in a Browser - -Now, you can open URL [http://oro.demo](http://oro.demo) in your browser. - -To access the back-office, use *admin* as both login and password. -To access the storefront, use the credentials of the predefined demo user roles. To log in as a buyer, use *BrandaJSanborn@example.org* both as your login and password. To log in as a manager, use *AmandaRCole@example.org* both as your login and password. - -## Access the Mail Catcher - -[Smtp service](https://github.com/mailhog/MailHog) is additionally launched so that you can send emails from the application. It receives all mail and has a web interface that enables you to view it and perform the required actions. The web interface for the mail catcher is available at the address [http://oro.demo/mailcatcher](http://oro.demo/mailcatcher). - -## Stop the Application - -- To stop and remove all containers, run `docker compose down`. - -- To stop and remove all containers with the data saved in volumes, run `docker compose down -v`. - -## Troubleshooting - -- If you deployed the application before, pull fresh images with `docker compose pull`. - -## About this Project - -This repository provides a Docker Compose configuration file (compose.yaml) and demonstrates how to run different applications + required services in containers. Oro Inc. provides images with applications Community Edition in public Docker Hub. - -**This deployment is NOT intended for a production environment.** - -**Docker images with different applications:** -OroCommerce Community Edition: [docker.io/oroinc/orocommerce-application](https://hub.docker.com/r/oroinc/orocommerce-application) -OroCRM Community Edition: [docker.io/oroinc/crm-application](https://hub.docker.com/r/oroinc/crm-application) -OroPlatform Community Edition: [docker.io/oroinc/platform-application](https://hub.docker.com/r/oroinc/platform-application) - -One image is used to run containers in several roles: web server, php-fpm, consumer, websocket server, and cron service. -All these services must be running, and the PostgreSQL database must be prepared for a full-fledged application. - -License -------- - -[MIT][1] Copyright (c) 2013 - 2023, Oro, Inc. - -[1]: LICENSE diff --git a/compose.override.yaml b/compose.override.yml similarity index 84% rename from compose.override.yaml rename to compose.override.yml index 9c6fdf3..9234f3c 100644 --- a/compose.override.yaml +++ b/compose.override.yml @@ -8,20 +8,23 @@ x-depends_on: &default-depends_on services: web: - ports: !reset [] + ports: !reset + - target: 80 + mode: host networks: default: aliases: - ${ORO_APP_DOMAIN} labels: - traefik.enable=true + - traefik.http.services.oro5-web.loadbalancer.server.port=80 # Serve oro over http - - traefik.http.routers.oro-http.rule=Host(`${ORO_APP_DOMAIN}`) - - traefik.http.routers.oro-http.entrypoints=http + - traefik.http.routers.oro5-web-http.rule=Host(`${ORO_APP_DOMAIN}`) + - traefik.http.routers.oro5-web-http.entrypoints=http # Serve oro over https - - traefik.http.routers.oro-https.rule=Host(`${ORO_APP_DOMAIN}`) - - traefik.http.routers.oro-https.entrypoints=https - - traefik.http.routers.oro-https.tls=true + - traefik.http.routers.oro5-web-https.rule=Host(`${ORO_APP_DOMAIN}`) + - traefik.http.routers.oro5-web-https.entrypoints=https + - traefik.http.routers.oro5-web-https.tls=true php-fpm-app: build: @@ -45,6 +48,7 @@ services: # Ensure that host.docker.internal is correctly defined on Linux - host.docker.internal:host-gateway - gally.local:host-gateway + - gally.connector.local:host-gateway volumes: - root_home:/root diff --git a/compose.yaml b/compose.yml similarity index 100% rename from compose.yaml rename to compose.yml diff --git a/src/package.json b/src/package.json index 9e16358..e11084d 100644 --- a/src/package.json +++ b/src/package.json @@ -49,7 +49,6 @@ "focus-visible": "5.2.0", "fullcalendar": "3.4.0", "fuse.js": "6.6.2", - "fusioncharts": "^4.1.2", "grapesjs": "0.20.1", "grapesjs-parser-postcss": "1.0.1", "grapesjs-plugin-export": "1.0.11",