feat(magento): switch to ghcr.io/alexcheng1982/docker-magento2:2.4.6-p3; update Compose/Env/Tasks/Docs

• Docs: updated to MAGENTO_VOLUME; removed Installation/User_Administration guides
• Compose: volume path → /var/www/html; switched variables to MAGENTO_*/MYSQL_*/OPENSEARCH_*
• Env: new variable set + APACHE_SERVERNAME
• Task: setup:install via docker compose exec (multiline form)
• Schema: removed obsolete credentials definition
Link: https://chatgpt.com/share/68b8dc30-361c-800f-aa69-88df514cb160
This commit is contained in:
2025-09-04 02:25:49 +02:00
parent 4f8ce598a9
commit 0e72dcbe36
11 changed files with 79 additions and 108 deletions

View File

@@ -4,7 +4,7 @@
```bash ```bash
cd {{ PATH_DOCKER_COMPOSE_INSTANCES }}magento/ cd {{ PATH_DOCKER_COMPOSE_INSTANCES }}magento/
docker compose down docker compose down
docker volume rm magento_data docker volume rm MAGENTO_VOLUME
cd {{ PATH_DOCKER_COMPOSE_INSTANCES }} && rm -vR {{ PATH_DOCKER_COMPOSE_INSTANCES }}magento cd {{ PATH_DOCKER_COMPOSE_INSTANCES }} && rm -vR {{ PATH_DOCKER_COMPOSE_INSTANCES }}magento
``` ```

View File

@@ -1,30 +0,0 @@
# ⚙️ Installation & First Run
## 1) Prepare DNS & Ports
Ensure a canonical domain is mapped (e.g. `shop.{{ PRIMARY_DOMAIN }}`) and a free localhost port in `group_vars/all/10_ports.yml`:
```
web-app-magento: 80xx
```
## 2) Seed Credentials
Provide (at minimum) an admin password in your inventory (vault recommended):
```yaml
applications:
web-app-magento:
credentials:
admin_password: "use-a-strong-secret"
```
The admin username/email are taken from `users.administrator.*`.
## 3) Deploy
Run the Infinito.Nexus playbook for your host(s). The role will:
- Start OpenSearch (single node)
- Start MariaDB (if `central_database` is disabled, the app-local DB is used instead)
- Start Magento application container
- Wire environment via `templates/env.j2`
## 4) Verify
Open your domain (e.g. `https://shop.{{ PRIMARY_DOMAIN }}`) and complete any remaining onboarding steps in the admin panel.
**Admin Panel:** `{{ domains | get_url('web-app-magento', WEB_PROTOCOL) }}/admin`
(Default path can vary; set a custom `ADMINURI` later via `bin/magento setup:config:set` if desired.)

View File

@@ -1,6 +1,6 @@
# 🔼 Upgrade # 🔼 Upgrade
> Always back up the database and the `magento_data` volume before upgrades. > Always back up the database and the `MAGENTO_VOLUME` volume before upgrades.
1. Update images/versions in the application config (`roles/web-app-magento/config/main.yml` or inventory overrides). 1. Update images/versions in the application config (`roles/web-app-magento/config/main.yml` or inventory overrides).
2. Recreate containers: 2. Recreate containers:

View File

@@ -1,15 +0,0 @@
# 👤 User Administration
- Access the admin panel at:
`{{ domains | get_url('web-app-magento', WEB_PROTOCOL) }}/admin`
*(or your custom admin path if configured)*
- New admin accounts can be created via the web UI or CLI:
```bash
docker compose exec -it application bin/magento admin:user:create \
--admin-user="john" \
--admin-password="SuperSecret_12345" \
--admin-email="john@example.com" \
--admin-firstname="John" \
--admin-lastname="Doe"
```

View File

@@ -19,8 +19,8 @@ server:
docker: docker:
services: services:
application: application:
image: "bitnami/magento" image: "ghcr.io/alexcheng1982/docker-magento2"
version: "latest" version: "2.4.6-p3"
name: "magento" name: "magento"
backup: backup:
no_stop_required: true no_stop_required: true

View File

@@ -1,6 +1 @@
credentials:
admin_password:
description: "Password for the initial Magento admin account"
algorithm: "alphanumeric"
validation:
min_length: 12

View File

@@ -1,6 +1,32 @@
- name: "load docker, db/redis/proxy for {{ application_id }}" - name: "load docker, db/redis/proxy for {{ application_id }}"
include_role: include_role:
name: sys-stk-full-stateful name: sys-stk-full-stateful
vars:
docker_compose_flush_handlers: true
- name: flush docker service - name: "Run Magento setup:install (in container)"
meta: flush_handlers command: >
docker compose exec -T application bash -lc "
cd /var/www/html && bin/magento setup:install \
--base-url='{{ MAGENTO_URL }}/' \
--db-host=\"$MYSQL_HOST\" \
--db-name=\"$MYSQL_DATABASE\" \
--db-user=\"$MYSQL_USER\" \
--db-password=\"$MYSQL_PASSWORD\" \
--search-engine='opensearch' \
--opensearch-host=\"$OPENSEARCH_HOST\" \
--opensearch-port=\"$OPENSEARCH_PORT_NUMBER\" \
--admin-firstname=\"$MAGENTO_ADMIN_FIRSTNAME\" \
--admin-lastname=\"$MAGENTO_ADMIN_LASTNAME\" \
--admin-email=\"$MAGENTO_ADMIN_EMAIL\" \
--admin-user=\"$MAGENTO_ADMIN_USERNAME\" \
--admin-password=\"$MAGENTO_ADMIN_PASSWORD\""
args:
chdir: "{{ docker_compose.directories.instance }}"
register: magento_install
changed_when: >
(magento_install.stdout is defined and
('Magento installation complete' in magento_install.stdout
or 'successfully installed' in magento_install.stdout))
- include_tasks: utils/run_once.yml

View File

@@ -2,8 +2,3 @@
- name: "construct {{ role_name }}" - name: "construct {{ role_name }}"
include_tasks: 01_core.yml include_tasks: 01_core.yml
when: run_once_web_app_magento is not defined when: run_once_web_app_magento is not defined
- name: run the docker magento tasks once
set_fact:
run_once_web_app_magento: true
when: run_once_web_app_magento is not defined

View File

@@ -1,34 +1,33 @@
{% include 'roles/docker-compose/templates/base.yml.j2' %} {% include 'roles/docker-compose/templates/base.yml.j2' %}
application: application:
{% set container_port = 8080 %} {% set container_port = 80 %}
{% include 'roles/docker-container/templates/base.yml.j2' %} {% include 'roles/docker-container/templates/base.yml.j2' %}
image: "{{ magento_image }}:{{ magento_version }}" image: "{{ MAGENTO_IMAGE }}:{{ MAGENTO_VERSION }}"
container_name: "{{ magento_name }}" container_name: "{{ MAGENTO_CONTAINER }}"
ports: ports:
- "127.0.0.1:{{ ports.localhost.http[application_id] }}:{{ container_port }}" - "127.0.0.1:{{ ports.localhost.http[application_id] }}:{{ container_port }}"
volumes: volumes:
- "data:/bitnami/magento" - "data:/var/www/html"
{% include 'roles/docker-container/templates/depends_on/dmbs_excl.yml.j2' %} {% include 'roles/docker-container/templates/depends_on/dmbs_excl.yml.j2' %}
depends_on: # search:
- search # condition: service_healthy
{% include 'roles/docker-container/templates/healthcheck/tcp.yml.j2' %} {% include 'roles/docker-container/templates/healthcheck/tcp.yml.j2' %}
{% include 'roles/docker-container/templates/networks.yml.j2' %} {% include 'roles/docker-container/templates/networks.yml.j2' %}
search: search:
{% set container_port = 9200 %} {% set container_port = 9200 %}
image: "{{ magento_search_image }}:{{ magento_search_version }}" image: "{{ MAGENTO_SEARCH_IMAGE }}:{{ MAGENTO_SEARCH_VERSION }}"
container_name: "{{ magento_search_name }}" container_name: "{{ MAGENTO_SEARCH_NAME }}"
{% include 'roles/docker-container/templates/base.yml.j2' %} {% include 'roles/docker-container/templates/base.yml.j2' %}
environment: environment:
- discovery.type=single-node - discovery.type=single-node
- plugins.security.disabled=true
- OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m - OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m
{% include 'roles/docker-container/templates/healthcheck/tcp.yml.j2' %} {% include 'roles/docker-container/templates/healthcheck/tcp.yml.j2' %}
{% include 'roles/docker-container/templates/networks.yml.j2' %} {% include 'roles/docker-container/templates/networks.yml.j2' %}
{% include 'roles/docker-compose/templates/volumes.yml.j2' %} {% include 'roles/docker-compose/templates/volumes.yml.j2' %}
data: data:
name: {{ magento_data }} name: {{ MAGENTO_VOLUME }}
{% include 'roles/docker-compose/templates/networks.yml.j2' %} {% include 'roles/docker-compose/templates/networks.yml.j2' %}

View File

@@ -3,30 +3,32 @@
# - https://github.com/bitnami/containers/tree/main/bitnami/magento # - https://github.com/bitnami/containers/tree/main/bitnami/magento
# Host & URLs # Host & URLs
MAGENTO_HOST="{{ domains | get_domain(application_id) }}" MAGENTO_URL="{{ MAGENTO_URL }}"
MAGENTO_BASE_URL="{{ domains | get_url(application_id, WEB_PROTOCOL) }}/" MAGENTO_BACKEND_FRONTNAME="admin"
MAGENTO_ENABLE_HTTPS={{ (WEB_PORT == 443) | string | lower }} MAGENTO_USE_SECURE={{ (WEB_PORT == 443) | ternary('1','0') }}
MAGENTO_BASE_URL_SECURE={{ (WEB_PORT == 443) | ternary('1','0') }}
MAGENTO_USE_SECURE_ADMIN={{ (WEB_PORT == 443) | ternary('1','0') }}
# Admin (seed from global administrator) # Admin (seed from global administrator)
MAGENTO_USERNAME="{{ users.administrator.username }}" MAGENTO_ADMIN_USERNAME="{{ users.administrator.username }}"
MAGENTO_PASSWORD="{{ applications | get_app_conf(application_id, 'credentials.admin_password') }}" MAGENTO_ADMIN_PASSWORD="{{ users.administrator.password }}"
MAGENTO_EMAIL="{{ users.administrator.email }}" MAGENTO_ADMIN_EMAIL="{{ users.administrator.email }}"
MAGENTO_FIRST_NAME="{{ users.administrator.firstname | default('Admin') }}" MAGENTO_ADMIN_FIRSTNAME="{{ users.administrator.firstname | default('Admin') }}"
MAGENTO_LAST_NAME="{{ users.administrator.lastname | default('User') }}" MAGENTO_ADMIN_LASTNAME="{{ users.administrator.lastname | default('User') }}"
# Database (central DB preferred) # Database (central DB preferred)
MARIADB_HOST="{{ database_host }}" MYSQL_HOST="{{ database_host }}"
MARIADB_PORT_NUMBER="{{ database_port }}" MYSQL_PORT="{{ database_port }}"
MAGENTO_DATABASE_USER="{{ database_username }}" MYSQL_USER="{{ database_username }}"
MAGENTO_DATABASE_PASSWORD="{{ database_password }}" MYSQL_PASSWORD="{{ database_password }}"
MAGENTO_DATABASE_NAME="{{ database_name }}" MYSQL_DATABASE="{{ database_name }}"
# Search (Magento 2.4+) # Search (Magento 2.4+)
MAGENTO_SEARCH_ENGINE="opensearch"
OPENSEARCH_HOST="search" OPENSEARCH_HOST="search"
OPENSEARCH_PORT_NUMBER="9200" OPENSEARCH_PORT_NUMBER="9200"
OPENSEARCH_INITIAL_ADMIN_PASSWORD="{{ users.administrator.password }}"
# SMTP # SMTP (post-install youll wire these in Magento admin or env.php)
SMTP_HOST="{{ SYSTEM_EMAIL.HOST }}" SMTP_HOST="{{ SYSTEM_EMAIL.HOST }}"
SMTP_PORT="{{ SYSTEM_EMAIL.PORT }}" SMTP_PORT="{{ SYSTEM_EMAIL.PORT }}"
SMTP_USER="{{ users['no-reply'].email }}" SMTP_USER="{{ users['no-reply'].email }}"
@@ -34,6 +36,6 @@ SMTP_PASSWORD="{{ users['no-reply'].mailu_token }}"
SMTP_PROTOCOL={{ SYSTEM_EMAIL.TLS | ternary('tls','ssl') }} SMTP_PROTOCOL={{ SYSTEM_EMAIL.TLS | ternary('tls','ssl') }}
# Misc # Misc
ALLOW_EMPTY_PASSWORD="no" PHP_MEMORY_LIMIT="768M"
BITNAMI_DEBUG="false"
PHP_MEMORY_LIMIT="1024M" APACHE_SERVERNAME={{ MAGENTO_DOMAIN }}

View File

@@ -3,15 +3,14 @@ application_id: "web-app-magento"
database_type: "mariadb" database_type: "mariadb"
# Magento (application container) # Magento (application container)
magento_version: "{{ applications | get_app_conf(application_id, 'docker.services.application.version', True) | default('latest') }}" MAGENTO_DOMAIN: "{{ domains | get_domain(application_id) }}"
magento_image: "{{ applications | get_app_conf(application_id, 'docker.services.application.image', True) | default('bitnami/magento') }}" MAGENTO_URL: "{{ domains | get_url(application_id, WEB_PROTOCOL) }}"
magento_name: "{{ applications | get_app_conf(application_id, 'docker.services.application.name', True) | default('magento') }}" MAGENTO_VERSION: "{{ applications | get_app_conf(application_id, 'docker.services.application.version') }}"
magento_data: "{{ applications | get_app_conf(application_id, 'docker.volumes.data', True) | default('magento_data') }}" MAGENTO_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.application.image') }}"
MAGENTO_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.application.name') }}"
MAGENTO_VOLUME: "{{ applications | get_app_conf(application_id, 'docker.volumes.data') }}"
# Search (OpenSearch) # Search (OpenSearch)
magento_search_version: "{{ applications | get_app_conf(application_id, 'docker.services.search.version', True) | default('latest') }}" MAGENTO_SEARCH_VERSION: "{{ applications | get_app_conf(application_id, 'docker.services.search.version') }}"
magento_search_image: "{{ applications | get_app_conf(application_id, 'docker.services.search.image', True) | default('opensearchproject/opensearch') }}" MAGENTO_SEARCH_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.search.image') }}"
magento_search_name: "{{ applications | get_app_conf(application_id, 'docker.services.search.name', True) | default('magento-opensearch') }}" MAGENTO_SEARCH_NAME: "{{ applications | get_app_conf(application_id, 'docker.services.search.name') }}"
# Docker helpers
docker_compose_flush_handlers: true