Skip to content

Commit b320244

Browse files
authored
Merge pull request #151 from akunzai/dev-e2e
Add E2E tests and improve development environment
2 parents c794250 + cea6858 commit b320244

35 files changed

Lines changed: 1560 additions & 107 deletions

.devcontainer/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Requirements
44

55
- [Docker Engine](https://docs.docker.com/install/)
6-
- [Docker Compose V2](https://docs.docker.com/compose/cli-command/)
6+
- [Docker Compose](https://docs.docker.com/compose/cli-command/)
77
- [mkcert](https://github.com/FiloSottile/mkcert)
88
- [Visual Studio Code](https://code.visualstudio.com/)
99
- Bash
@@ -13,7 +13,8 @@
1313
```sh
1414
# set up TLS certs in Host
1515
mkdir -p .secrets
16-
mkcert -cert-file .secrets/cert.pem -key-file .secrets/key.pem 'auth.dev.local'
16+
mkcert -cert-file .secrets/cert.pem -key-file .secrets/key.pem '*.dev.local'
17+
cp "$(mkcert -CAROOT)/rootCA.pem" .secrets/ca.pem
1718

1819
# set up hosts in Host
1920
echo "127.0.0.1 auth.dev.local www.dev.local" | sudo tee -a /etc/hosts
@@ -34,8 +35,8 @@ docker compose -f compose.yml -f compose.debug.yml up -d
3435

3536
## URLs
3637

37-
- [Joomla!](http://www.dev.local/administrator/)
38-
- [Keycloak](https://auth.dev.local:8443)
38+
- [Joomla!](https://www.dev.local/administrator/)
39+
- [Keycloak](https://auth.dev.local)
3940

4041
## Credentials
4142

.devcontainer/compose.yml

Lines changed: 90 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,48 @@
11
name: joomla-external-login_devcontainer
22
services:
3+
joomla:
4+
build:
5+
context: ./joomla
6+
image: joomla:external-login
7+
volumes:
8+
- type: volume
9+
source: joomla_data
10+
target: /var/www/html
11+
- type: bind
12+
source: ${LOCAL_WORKSPACE_FOLDER:-..}/.devcontainer/joomla/logs
13+
target: /var/www/html/administrator/logs
14+
- type: bind
15+
source: ${LOCAL_WORKSPACE_FOLDER:-..}
16+
target: /workspace
17+
consistency: cached
18+
- type: bind
19+
source: ${LOCAL_WORKSPACE_FOLDER:-..}/.devcontainer/php.ini
20+
target: /usr/local/etc/php/php.ini
21+
read_only: true
22+
- type: bind
23+
source: ${LOCAL_WORKSPACE_FOLDER:-..}/.vscode
24+
target: /var/www/html/.vscode
25+
consistency: cached
26+
environment:
27+
JOOMLA_DB_HOST: ${JOOMLA_DB_HOST:-mysql}
28+
JOOMLA_DB_PASSWORD: ${JOOMLA_DB_PASSWORD:-${MYSQL_ROOT_PASSWORD:-secret}}
29+
SSL_CERT_FILE: /run/secrets/ca.pem
30+
secrets:
31+
- ca.pem
32+
depends_on:
33+
- mysql
34+
- traefik
35+
external_links:
36+
- traefik:store.dev.local
37+
- traefik:www.dev.local
38+
labels:
39+
- traefik.enable=true
40+
- traefik.http.routers.joomla.entrypoints=websecure
41+
- traefik.http.routers.joomla.rule=Host(`www.dev.local`)
342

443
keycloak:
544
build: ./keycloak
645
image: keycloak:cas
7-
restart: unless-stopped
846
volumes:
947
- type: volume
1048
source: keycloak_data
@@ -17,7 +55,10 @@ services:
1755
- type: bind
1856
source: ${LOCAL_WORKSPACE_FOLDER:-..}/.devcontainer/keycloak/import
1957
target: /opt/keycloak/data/import
20-
command: start --optimized --import-realm
58+
# https://www.keycloak.org/server/configuration#_starting_keycloak
59+
command:
60+
- start-dev
61+
- --import-realm
2162
environment:
2263
# https://www.keycloak.org/server/configuration
2364
KC_BOOTSTRAP_ADMIN_USERNAME: ${KC_BOOTSTRAP_ADMIN_USERNAME:-admin}
@@ -26,74 +67,73 @@ services:
2667
KC_PROXY_HEADERS: xforwarded
2768
# https://www.keycloak.org/server/all-config
2869
KC_HOSTNAME: auth.dev.local
29-
KC_HTTPS_CERTIFICATE_FILE: /run/secrets/cert.pem
30-
KC_HTTPS_CERTIFICATE_KEY_FILE: /run/secrets/key.pem
31-
ports:
32-
- 127.0.0.1:8443:8443
70+
SSL_CERT_FILE: /run/secrets/ca.pem
3371
secrets:
34-
- cert.pem
35-
- key.pem
36-
networks:
37-
default:
38-
aliases:
39-
- auth.dev.local
40-
41-
joomla:
42-
build:
43-
context: ./joomla
44-
image: joomla:external-login
45-
volumes:
46-
- type: volume
47-
source: joomla_data
48-
target: /var/www/html
49-
- type: volume
50-
source: joomla_log
51-
target: /var/www/html/administrator/logs
52-
- type: bind
53-
source: ${LOCAL_WORKSPACE_FOLDER:-..}
54-
target: /workspace
55-
consistency: cached
56-
- type: bind
57-
source: ${LOCAL_WORKSPACE_FOLDER:-..}/.devcontainer/php.ini
58-
target: /usr/local/etc/php/php.ini
59-
read_only: true
60-
- type: bind
61-
source: ${LOCAL_WORKSPACE_FOLDER:-..}/.vscode
62-
target: /var/www/html/.vscode
63-
consistency: cached
64-
environment:
65-
JOOMLA_DB_HOST: ${JOOMLA_DB_HOST:-mysql}
66-
JOOMLA_DB_PASSWORD: ${JOOMLA_DB_PASSWORD:-${MYSQL_ROOT_PASSWORD:-secret}}
67-
ports:
68-
- 127.0.0.1:80:80
72+
- ca.pem
6973
depends_on:
7074
- mysql
71-
- keycloak
72-
networks:
73-
default:
74-
aliases:
75-
- www.dev.local
75+
- traefik
76+
external_links:
77+
- traefik:www.dev.local
78+
- traefik:auth.dev.local
79+
labels:
80+
- traefik.enable=true
81+
- traefik.http.routers.openmage.entrypoints=websecure
82+
- traefik.http.routers.openmage.rule=Host(`auth.dev.local`)
83+
- traefik.http.services.openmage.loadbalancer.server.port=8080
7684

7785
mysql:
7886
# https://hub.docker.com/_/mysql
7987
image: mysql
80-
restart: unless-stopped
8188
volumes:
82-
- mysql_data:/var/lib/mysql
89+
- type: volume
90+
source: mysql_data
91+
target: /var/lib/mysql
8392
environment:
8493
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-secret}
8594
MYSQL_DATABASE: ${MYSQL_DATABASE:-joomla}
8695
ports:
8796
- 127.0.0.1:3306:3306
8897

98+
traefik:
99+
# https://hub.docker.com/_/traefik
100+
image: traefik
101+
networks:
102+
default:
103+
aliases:
104+
- auth.dev.local
105+
- www.dev.local
106+
volumes:
107+
- /var/run/docker.sock:/var/run/docker.sock:ro
108+
- ./traefik/etc:/etc/traefik
109+
command:
110+
- --api.insecure=true
111+
- --api.dashboard=true
112+
- --entrypoints.web.address=:80
113+
- --entrypoints.web.http.redirections.entryPoint.to=websecure
114+
- --entrypoints.web.http.redirections.entryPoint.scheme=https
115+
- --entrypoints.websecure.address=:443
116+
- --entrypoints.websecure.http.tls=true
117+
- --providers.docker=true
118+
- --providers.docker.exposedByDefault=false
119+
- --providers.file.directory=/etc/traefik/dynamic/
120+
ports:
121+
- 127.0.0.1:80:80
122+
- 127.0.0.1:443:443
123+
- 127.0.0.1:9090:8080
124+
secrets:
125+
- cert.pem
126+
- key.pem
127+
89128
secrets:
129+
ca.pem:
130+
file: .secrets/ca.pem
90131
cert.pem:
91132
file: .secrets/cert.pem
92133
key.pem:
93134
file: .secrets/key.pem
94135

95136
volumes:
96137
joomla_data: null
97-
joomla_log: null
138+
mysql_data: null
98139
keycloak_data: null
99-
mysql_data: null

.devcontainer/devcontainer.json

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
11
// https://aka.ms/devcontainer.json
22
{
33
"name": "Joomla External Login",
4-
// https://github.com/devcontainers/images/tree/main/src/php
54
"dockerComposeFile": "compose.yml",
65
"service": "joomla",
76
"workspaceFolder": "/workspace",
8-
"portsAttributes": {
9-
"8443": {
10-
"label": "Keycloak",
11-
"protocol": "https"
12-
},
13-
"80": {
14-
"label": "Joomla",
15-
"protocol": "http"
16-
}
17-
},
18-
"otherPortsAttributes": {
19-
"onAutoForward": "ignore"
20-
},
217
"remoteEnv": {
228
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
239
},
@@ -42,9 +28,6 @@
4228
// https://containers.dev/features
4329
"features": {
4430
"ghcr.io/danzilberdan/devcontainers/opencode:0": {},
45-
"ghcr.io/devcontainers/features/git:1": {
46-
"version": "system"
47-
},
4831
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
4932
"moby": false
5033
}

.devcontainer/generate-certs.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
# Generate self-signed CA and server certificates for local development
3+
# Usage: ./generate-certs.sh [SECRETS_DIR]
4+
# Example: ./generate-certs.sh .secrets
5+
6+
set -e
7+
8+
SECRETS_DIR="${1:-.secrets}"
9+
DOMAINS="www.dev.local,auth.dev.local"
10+
11+
echo "=================================================="
12+
echo "Certificate Generation Script"
13+
echo "=================================================="
14+
echo "Output directory: ${SECRETS_DIR}"
15+
echo "Domains: ${DOMAINS}"
16+
echo ""
17+
18+
# Create secrets directory if not exists
19+
mkdir -p "${SECRETS_DIR}"
20+
21+
# Check if certificates already exist
22+
if [[ -f "${SECRETS_DIR}/ca.pem" && -f "${SECRETS_DIR}/cert.pem" && -f "${SECRETS_DIR}/key.pem" ]]; then
23+
echo "Certificates already exist in ${SECRETS_DIR}"
24+
echo "To regenerate, remove existing certificates first."
25+
exit 0
26+
fi
27+
28+
echo "Step 1: Generating CA certificate..."
29+
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
30+
-keyout "${SECRETS_DIR}/ca-key.pem" \
31+
-out "${SECRETS_DIR}/ca.pem" \
32+
-subj "/CN=Local Dev CA"
33+
echo "✓ CA certificate created"
34+
35+
echo ""
36+
echo "Step 2: Generating server certificate..."
37+
openssl req -nodes -newkey rsa:2048 \
38+
-keyout "${SECRETS_DIR}/key.pem" \
39+
-out "${SECRETS_DIR}/cert.csr" \
40+
-subj "/CN=dev.local"
41+
42+
openssl x509 -req -days 365 \
43+
-in "${SECRETS_DIR}/cert.csr" \
44+
-CA "${SECRETS_DIR}/ca.pem" \
45+
-CAkey "${SECRETS_DIR}/ca-key.pem" \
46+
-CAcreateserial \
47+
-out "${SECRETS_DIR}/cert.pem" \
48+
-extfile <(echo "subjectAltName=DNS:${DOMAINS//,/,DNS:}")
49+
50+
# Clean up temporary files
51+
rm -f "${SECRETS_DIR}/cert.csr" "${SECRETS_DIR}/ca.srl"
52+
echo "✓ Server certificate created"
53+
54+
echo ""
55+
echo "=================================================="
56+
echo "Certificate Generation Completed!"
57+
echo "=================================================="
58+
echo "Files created:"
59+
echo " - ${SECRETS_DIR}/ca.pem (CA certificate)"
60+
echo " - ${SECRETS_DIR}/ca-key.pem (CA private key)"
61+
echo " - ${SECRETS_DIR}/cert.pem (Server certificate)"
62+
echo " - ${SECRETS_DIR}/key.pem (Server private key)"
63+
echo ""

.devcontainer/joomla/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ RUN --mount=type=cache,target=/var/lib/apt/lists,sharing=locked \
1616
set -eux; \
1717
apt-get update; \
1818
# install the system tools we need
19-
apt-get install -y --no-install-recommends mariadb-client unzip; \
19+
apt-get install -y --no-install-recommends git mariadb-client unzip rsync; \
2020
# install the PHP extensions we need
2121
savedAptMark="$(apt-mark showmanual)"; \
2222
apt-get install -y --no-install-recommends \
23-
libfreetype6-dev libicu-dev \
23+
libfreetype6-dev libicu-dev libssl-dev \
2424
libjpeg62-turbo-dev libpng-dev \
2525
libxml2-dev libxslt1-dev \
2626
libzip-dev libwebp-dev \
2727
${PHP_EXTRA_BUILD_DEPS:-}; \
2828
# https://www.php.net/manual/en/image.installation.php
2929
docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp; \
30-
docker-php-ext-install -j$(nproc) opcache \
31-
intl gd mysqli pcntl pdo_mysql soap xsl zip; \
30+
docker-php-ext-install -j$(nproc) ftp \
31+
gd intl mysqli opcache pcntl pdo_mysql soap xsl zip; \
3232
curl -Lo /usr/local/bin/pickle https://github.com/FriendsOfPHP/pickle/releases/latest/download/pickle.phar && \
3333
chmod +x /usr/local/bin/pickle; \
3434
pickle install --no-interaction apcu-stable; \

0 commit comments

Comments
 (0)