Skip to content

Commit

Permalink
Merge pull request #37 from akunzai/dev-containers
Browse files Browse the repository at this point in the history
Improve Joomla! 4 compatibility
  • Loading branch information
akunzai authored Nov 26, 2023
2 parents 9aae346 + ddaf80a commit 5c27db6
Show file tree
Hide file tree
Showing 435 changed files with 5,600 additions and 4,698 deletions.
89 changes: 0 additions & 89 deletions .devcontainer/Dockerfile

This file was deleted.

40 changes: 40 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Dev Containers

## Requirements

- [Docker Engine](https://docs.docker.com/install/)
- [Docker Compose V2](https://docs.docker.com/compose/cli-command/)
- [mkcert](https://github.com/FiloSottile/mkcert)
- [Visual Studio Code](https://code.visualstudio.com/)
- Bash

## Getting Start

```sh
# set up TLS certs and hosts in Host
./init.sh www.dev.local store.dev.local

# start containers
docker compose up -d

# install OpenMage
./openmage/install.sh

# install the Joomla! (requires Joomla! version >= 4.3)
./joomla/install.sh
```

## Admin URLs

- [OpenMage](https://store.dev.local/admin/)
- [Joomla!](https://www.dev.local/administrator/)

## Credentials

- Username: `admin`
- Password: `ChangeTheP@ssw0rd`

## Setup

- [OpenMage](./openmage/)
- [Joomla!](./joomla/)
6 changes: 2 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/php-mariadb
// Update the VARIANT arg in docker-compose.yml to pick a PHP version
// Update the PHP_VERSION arg in docker-compose.yml to pick a PHP version
{
"name": "Joomla",
"dockerComposeFile": "docker-compose.yml",
"service": "joomla",
"workspaceFolder": "/workspace",
"overrideCommand": false,
"customizations": {
"vscode": {
"extensions": [
Expand All @@ -15,6 +14,5 @@
"redhat.vscode-xml"
]
}
},
"forwardPorts": [8080, 3306]
}
}
89 changes: 79 additions & 10 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,99 @@ version: '2'

services:
joomla:
container_name: magebridge-joomla
build:
context: .
dockerfile: Dockerfile
context: ./joomla
args:
VARIANT: "8.1-apache-bookworm"
JOOMLA_VERSION: "3.10.12"
JOOMLA_VERSION: '4.4.0'
PHP_VERSION: '8.2'
image: joomla:magebridge
volumes:
- ..:/workspace:cached
- joomla-data:/var/www/html
- ..:/workspace:cached
- ./php.ini:/usr/local/etc/php/php.ini:ro
- ./joomla/log:/var/www/html/administrator/logs
environment:
JOOMLA_DB_HOST: ${JOOMLA_DB_HOST:-mysql}
JOOMLA_DB_PASSWORD: ${JOOMLA_DB_PASSWORD:-${MYSQL_ROOT_PASSWORD:-secret}}
# https://xdebug.org/docs/all_settings
XDEBUG_CONFIG: 'client_host=localhost log=/tmp/xdebug.log'
XDEBUG_MODE: develop,debug
external_links:
- traefik:store.dev.local
labels:
- traefik.enable=true
- traefik.http.routers.joomla.entrypoints=websecure
- traefik.http.routers.joomla.rule=Host(`www.dev.local`)
depends_on:
- mysql
- traefik

openmage:
container_name: magebridge-openmage
build:
context: ./openmage
args:
OPENMAGE_VERSION: '20.2.0'
PHP_VERSION: '8.2'
image: openmage:magebridge
volumes:
- openmage-data:/var/www/html
- ..:/var/www/html/.modman/MageBridge:cached
- ./php.ini:/usr/local/etc/php/php.ini:ro
- ./openmage/log:/var/www/html/var/log
environment:
JOOMLA_DB_HOST: mysql
JOOMLA_DB_PASSWORD: secret
# https://github.com/OpenMage/magento-lts/blob/32773dd4f82bb44bac89e8eca97379dad2a10af5/app/Mage.php#L22
# MAGE_IS_DEVELOPER_MODE: '1'
# https://xdebug.org/docs/all_settings
XDEBUG_CONFIG: 'client_host=localhost log=/tmp/xdebug.log'
XDEBUG_MODE: develop,debug
external_links:
- traefik:www.dev.local
labels:
- traefik.enable=true
- traefik.http.routers.openmage.entrypoints=websecure
- traefik.http.routers.openmage.rule=Host(`store.dev.local`)
depends_on:
- mysql
- traefik

mysql:
container_name: magebridge-mysql
# https://hub.docker.com/_/mysql
image: mysql
volumes:
- mysql-data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: joomla
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-secret}
MYSQL_DATABASE: ${MYSQL_DATABASE:-openmage}
ports:
- 127.0.0.1:3306:3306

traefik:
# https://hub.docker.com/_/traefik
image: traefik
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./traefik/etc:/etc/traefik
- ./certs:/etc/traefik/certs
command:
- --api.insecure=true
- --api.dashboard=true
- --entrypoints.web.address=:80
- --entrypoints.web.http.redirections.entryPoint.to=websecure
- --entrypoints.web.http.redirections.entryPoint.scheme=https
- --entrypoints.websecure.address=:443
- --entrypoints.websecure.http.tls=true
- --providers.docker=true
- --providers.docker.exposedByDefault=false
- --providers.file.directory=/etc/traefik/dynamic/
ports:
- 127.0.0.1:80:80
- 127.0.0.1:443:443
- 127.0.0.1:9090:8080

volumes:
joomla-data: null
mysql-data: null
mysql-data: null
openmage-data: null
32 changes: 32 additions & 0 deletions .devcontainer/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -euo pipefail

if [ $# -le 0 ] || [ "$1" == "--help" ] || [ "$1" == "-h" ]; then
echo "Usage: $0 <host> [<host>...]"
exit 1
fi

for host in "$@"; do
if ! grep -q "${host}" /etc/hosts; then
echo "127.0.0.1 ${host}" | sudo tee -a /etc/hosts
fi
done

CURRENTDIR=$(dirname "$0")
CERT_FILE="${CURRENTDIR}/certs/cert.pem"
KEY_FILE="${CURRENTDIR}/certs/key.pem"

if [ -e "${KEY_FILE}" ] && [ -e "${CERT_FILE}" ]; then
echo "Certificate already exists"
exit 0
fi

if [ -z "$(command -v mkcert)" ]; then
echo "mkcert is not installed, try 'brew install mkcert'"
exit 1
fi

mkcert -install
mkdir -vp $(dirname "$CERT_FILE")
mkcert -cert-file "$CERT_FILE" -key-file "$KEY_FILE" $@
78 changes: 78 additions & 0 deletions .devcontainer/joomla/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# https://mcr.microsoft.com/v2/vscode/devcontainers/php/tags/list
ARG PHP_VERSION=8.2
# https://hub.docker.com/_/joomla
ARG JOOMLA_VERSION=4.4.0

FROM joomla:${JOOMLA_VERSION}-apache AS joomla

# https://hub.docker.com/_/php
FROM php:${PHP_VERSION}-apache-bookworm

ENV LANG=en_US.UTF-8

# install MySQL client
RUN apt-get update \
&& apt-get install -y --no-install-recommends default-mysql-client \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*

# install pickle
# https://github.com/FriendsOfPHP/pickle
RUN set -eux; \
curl -Lo /usr/local/bin/pickle https://github.com/FriendsOfPHP/pickle/releases/latest/download/pickle.phar && \
chmod +x /usr/local/bin/pickle;

# install the PHP extensions we need
RUN set -eux; \
savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
apt-get install -y --no-install-recommends \
libfreetype6-dev libicu-dev libjpeg62-turbo-dev \
libpng-dev libxml2-dev libxslt1-dev libzip-dev libwebp-dev \
${PHP_EXTRA_BUILD_DEPS:-}; \
# https://www.php.net/manual/en/image.installation.php
docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp; \
docker-php-ext-install -j$(nproc) opcache \
intl gd mysqli pcntl pdo_mysql soap xsl zip; \
pickle install --no-interaction apcu; \
pickle install --no-interaction redis; \
pickle install --no-interaction xdebug; \
docker-php-ext-enable apcu opcache redis xdebug; \
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
apt-mark auto '.*' > /dev/null; \
[ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; \
find /usr/local -type f -executable -exec ldd '{}' ';' \
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \
| sort -u \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| xargs -r apt-mark manual; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
rm -rf /var/lib/apt/lists/*;

# set up Apache2
RUN set -eux; \
# enable Apache2 modules
a2enmod rewrite expires include deflate remoteip headers; \
# disable Apache2 server signature
echo 'ServerSignature Off' >> /etc/apache2/apache2.conf; \
echo 'ServerTokens Prod' >> /etc/apache2/apache2.conf; \
# enable support for TLS termination
echo 'SetEnvIf X-Forwarded-Proto https HTTPS=on' >> /etc/apache2/apache2.conf;

# install composer
# https://hub.docker.com/_/composer
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

# set up Joomla!
# Disable remote database security requirements.
ENV JOOMLA_INSTALLATION_DISABLE_LOCALHOST_CHECK=1
COPY --from=joomla /entrypoint.sh /
COPY --from=joomla /makedb.php /
COPY --from=joomla --chown=www-data:www-data /usr/src/joomla /usr/src/joomla
RUN set -eux; \
chown -R www-data:www-data /usr/src/joomla; \
chmod -R g+w /usr/src/joomla;

ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]
Loading

0 comments on commit 5c27db6

Please sign in to comment.