Skip to content

Instantly share code, notes, and snippets.

@vertexvaar
Last active January 20, 2022 09:55
Show Gist options
  • Save vertexvaar/eaa241ca5de0acc366198c097ed60fc9 to your computer and use it in GitHub Desktop.
Save vertexvaar/eaa241ca5de0acc366198c097ed60fc9 to your computer and use it in GitHub Desktop.
Dual Web Setup

Project Structure

app/local <- contains a full TYPO3 project (and a composer.json)
app/foreign <- contains a full TYPO3 project (and a composer.json)
packages/ <- contains multiple repositories
app/tests <- codeception acceptance tests which test the interaction between multiple repositories.

repos from packages are installed via composer in both "local" and "foreign" TYPO3 instances.
Both composer.jsons has a repositories section with type path and url /packages/*

version: '3.7'
services:
# First Apache container
local:
image: in2code/httpd:2.4-alpine
volumes:
# mount from app/local. The "local" instance has its own file system and configuration
- ./app/local/:/app/
# Mount all composer packages which are installed via composer into the local instance
- ./packages/:/packages/
env_file:
- .env
environment:
WEB_PHP_SERVICE: local-php
# For dinghy-hht-proxy
VIRTUAL_HOST: ${HOST_LOCAL}
VIRTUAL_PORT: 443
VIRTUAL_PROTO: https
networks:
default:
aliases:
# DNS in the docker network for this host
- ${HOST_LOCAL}
# The PHP FPM container for "local"
local-php:
build:
# Install ext-ssh2 and more
context: ./.project/docker/local-php
dockerfile: Dockerfile
volumes:
- ./app/local/:/app/
# Simulate NFS mount from the other server's file system
- ./app/foreign/public/typo3temp/:/mount/foreign/typo3temp/
# Mount packages. A change in a package in PHPStorm will affect both local and foreign (see below)
- ./packages/:/packages/
# For development stuff
- ./.project/:/.project/
- $HOME/.composer/auth.json:/tmp/composer/auth.json
- $HOME/.composer/cache/:/tmp/composer/cache/
- $HOME/.phive/:/tmp/phive/
# On Linux only
- $SSH_AUTH_SOCK:$SSH_AUTH_SOCK
env_file:
- .env
extra_hosts:
# Workaround so on Linux and MacOS we can always use "php -dremote_client=host.docker.internal" for debugging HTTP and CLI
- "host.docker.internal:host-gateway"
environment:
SSH_AUTH_SOCK: $SSH_AUTH_SOCK
# Application specific ENV for Local
IN2PUBLISH_CONTEXT: Local
TYPO3_INSTALL_DB_DBNAME: local
TYPO3_INSTALL_SITE_NAME: "[LOCAL] CP TYPO3 v11"
# The second webserver
foreign:
image: in2code/httpd:2.4-alpine
volumes:
# Mount app/foreign, because foreign has its own FS and config
- ./app/foreign/:/app/
# Mount packages so that one change in a package affects both local and foreign
- ./packages/:/packages/
env_file:
- .env
environment:
WEB_PHP_SERVICE: foreign-php
VIRTUAL_HOST: ${HOST_FOREIGN}
VIRTUAL_PORT: 443
VIRTUAL_PROTO: https
networks:
default:
aliases:
- ${HOST_FOREIGN}
foreign-php:
build:
context: ./.project/docker/foreign-php
dockerfile: Dockerfile
volumes:
# Same same, mount app/foreign and packages
- ./app/foreign/:/app/
- ./packages/:/packages/
- $HOME/.composer/auth.json:/tmp/composer/auth.json
- $HOME/.composer/cache/:/tmp/composer/cache/
- $SSH_AUTH_SOCK:$SSH_AUTH_SOCK
env_file:
- .env
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
SSH_AUTH_SOCK: $SSH_AUTH_SOCK
IN2PUBLISH_CONTEXT: Foreign
TYPO3_INSTALL_DB_DBNAME: foreign
TYPO3_INSTALL_SITE_NAME: "[FOREIGN] CP TYPO3 v11"
mysql:
image: in2code/mysql:5.7
env_file:
- .env
volumes:
- mysql:/var/lib/mysql/
# Contains a SQL init script that creates 4 databases. one for each side and for development and testing.
- ./.project/docker/mysql/docker-entrypoint-initdb.d/:/docker-entrypoint-initdb.d/
ports:
# .env contains SQLPORT=XXXXX so we always have the same port for this project
- ${SQLPORT}:3306
# Mail catcher
mail:
image: mailhog/mailhog
environment:
VIRTUAL_HOST: ${MAIL_HOST}
VIRTUAL_PORT: 8025
local-solr:
image: typo3solr/ext-solr:11.5.x-dev
volumes:
- local-solr-data:/var/solr
environment:
VIRTUAL_HOST: ${SOLR_LOCAL}
VIRTUAL_PORT: 8983
foreign-solr:
image: typo3solr/ext-solr:11.5.x-dev
volumes:
- foreign-solr-data:/var/solr
environment:
VIRTUAL_HOST: ${SOLR_FOREIGN}
VIRTUAL_PORT: 8983
blackfire:
image: blackfire/blackfire:2
env_file:
- .blackfire.env
redis:
image: redis
redisadmin:
image: erikdubbelboer/phpredisadmin
environment:
REDIS_1_HOST: redis
REDIS_1_NAME: TYPO3 Redis
# Only for starting acceptance tests since we need a container that can access both file systems to prepare the environment
codeception:
image: in2code/php-dev:7.4-fpm
volumes:
# Mount te full project. Tests are in app/tests
- ./:/app/
- ./packages/:/packages/
- $HOME/.composer/auth.json:/tmp/composer/auth.json
- $HOME/.composer/cache/:/tmp/composer/cache/
- $HOME/.phive/:/tmp/phive/
- $SSH_AUTH_SOCK:$SSH_AUTH_SOCK
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
SSH_AUTH_SOCK: $SSH_AUTH_SOCK
working_dir: /app/test
# For codeceptions acceptance tests
chrome:
image: selenium/standalone-chrome-debug
ports:
# VNC port to watch chrome
- ${CHROMEPORT}:5900
volumes:
- /dev/shm:/dev/shm
volumes:
mysql:
local-solr-data:
foreign-solr-data:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment