Unverified Commit 9c7591f9 authored by Sascha Marcel Schmidt's avatar Sascha Marcel Schmidt
Browse files

[TASK] removes environment and leaves just the typo3 stuff

parent 09b08654
data/etc
!data/etc/nginx
.idea
\ No newline at end of file
/bin
/vendor
/typo3_src
/html/index.php
/html/typo3
/html/fileadmin/
/html/typo3conf/ext/*
/html/typo3conf/AdditionalConfiguration.php
/html/typo3conf/PackageStates.php
/html/typo3conf/l10n
/html/typo3temp/
/html/uploads/
!/html/typo3conf/ext/t3olayout
# Makefile for t3o
#
DOCKER_COMPOSE="$$(pwd)/data/scripts/docker-compose.sh"
COMPOSER="$$(pwd)/data/scripts/composer.sh"
include .env
.PHONY: help
help:
@echo "Please use 'make <target>' where <target> is one of"
@echo " help to show this menu."
@echo " help2 for more help."
@echo " init for: composer-install, install-typo3"
@echo " reset for: kill, down, init"
@echo " pull docker-compose: Pull images for services."
@echo " build docker-compose: Build or rebuild services."
@echo " ps docker-compose: List containers."
@echo " up docker-compose: Build, (re)create, start, and attach"
@echo " to containers for a service."
@echo " down docker-compose: Stops containers and removes containers, networks,"
@echo " volumes, and images created by 'up'."
@echo " stop docker-compose: Stop running containers without removing them."
@echo " kill docker-compose: Force stop service containers."
@echo " install-typo3 docker-compose: Start TYPO3"
@echo " log Constantly echo log items to the console."
@echo " composer-install PHP Composer: Install."
@echo " composer-update PHP Composer: Update."
@echo
@echo "Recommended:"
@echo " make init up log"
.PHONY: help2
help2:
@echo
@echo "help2"
@echo "====="
@echo
@echo "Once TYPO3 is running direct your browser to one of:"
@echo " https://t3o.typo3.127.0.0.1.xip.io/typo3/"
@echo " https://t3o.typo3.127.0.0.1.xip.io/typo3/sysext/install/Start/Install.php"
@echo
@echo "For a local installation it may be necessary to save file"
@echo " ./data/typo3/html/typo3conf/AdditionalConfiguration.sample.php"
@echo "as"
@echo " ./data/typo3/html/typo3conf/AdditionalConfiguration.php"
@echo "to overcome the 'untrusted host error'."
@echo
@echo "End of help2."
@echo
.PHONY: init
init: composer-install install-typo3
@echo
@echo "Direct your browser to:"
@echo " https://t3o.typo3.127.0.0.1.xip.io/typo3/"
@echo
@echo "Type 'make help2' for more help."
@echo
.PHONY: reset
reset: kill down init
.PHONY: pull
pull:
$(DOCKER_COMPOSE) pull
.PHONY: build
build:
$(DOCKER_COMPOSE) build --no-cache
.PHONY: ps
ps:
$(DOCKER_COMPOSE) ps
.PHONY: up
up:
$(DOCKER_COMPOSE) up -d
.PHONY: down
down:
$(DOCKER_COMPOSE) down --remove-orphans
.PHONY: stop
stop:
$(DOCKER_COMPOSE) stop
.PHONY: kill
kill:
$(DOCKER_COMPOSE) kill
.PHONY: install-typo3
install-typo3: up
$(DOCKER_COMPOSE) run --rm db /src/data/scripts/wait-for-it.sh -h $(DATABASE_HOST_NAME) -p $(DATABASE_PORT) -t 30
$(DOCKER_COMPOSE) run --rm php ./bin/typo3cms install:setup \
--non-interactive \
--force \
--database-user-name $(DATABASE_USER) \
--database-user-password $(DATABASE_USER_PASSWORD) \
--database-host-name $(DATABASE_HOST_NAME) \
--database-port $(DATABASE_PORT) \
--database-name $(DATABASE_NAME) \
--use-existing-database \
--admin-user-name $(ADMIN_USER_NAME) \
--admin-password $(ADMIN_PASSWORD) \
--site-name $(TYPO3_SITENAME) \
--site-setup-type site
.PHONY: log
log:
$(DOCKER_COMPOSE) logs -f --tail=100
.PHONY: composer-install
composer-install:
$(COMPOSER) --working-dir=data/typo3 install
.PHONY: composer-update
composer-update:
$(COMPOSER) --working-dir=data/typo3 up
# TYPO3.org main page
## typo3.org
### Prerequisites
[docker engine](https://docs.docker.com/engine/installation/)
Make sure to have an instance of [jwilder/nginx-proxy](https://github.com/jwilder/nginx-proxy) running on your development box.
An easy way to get it up and running is using [torvitas/nginx-proxy-configuration](https://github.com/torvitas/docker-nginx-proxy-configuration).
### Quickstart
`
git clone https://git-t3o.typo3.org/t3o/typo3.org.git
go in "typo3.org" directory
make init up log
go to folder ``data/typo3/html/typo3conf`` and copy ``AdditionalConfiguration.sample.php`` to ``AdditionalConfiguration.php``
... and finally [click here](https://t3o.typo3.127.0.0.1.xip.io)
### Composer
Example:
`
./data/scripts/composer.sh --working-dir=data/typo3/ info
`
For your convenience there are the following make jobs:
`
make composer-install
make composer-update
`
access_log /proc/self/fd/1;
error_log /proc/self/fd/2;
server {
server_name ter.typo3.localhost;
listen 80;
index index.php index.html;
root /var/www/html/;
include /etc/nginx/conf.d/typo3.base;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_param TYPO3_CONTEXT Development;
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_read_timeout 1200;
}
client_max_body_size 100M;
location ~ /\.(js|css)$ {
expires 604800s;
}
if (!-e $request_filename){
rewrite ^/(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ /$1.$3 last;
}
location ~* ^/fileadmin/(.*/)?_recycler_/ {
deny all;
}
location ~* ^/fileadmin/templates/.*(\.txt|\.ts)$ {
deny all;
}
location ~* ^/typo3conf/ext/[^/]+/Resources/Private/ {
deny all;
}
location ~* ^/(typo3/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) {
}
location / {
if ($query_string ~ ".+") {
return 405;
}
if ($http_cookie ~ 'nc_staticfilecache|be_typo_user|fe_typo_user' ) {
return 405;
} # pass POST requests to PHP
if ($request_method !~ ^(GET|HEAD)$ ) {
return 405;
}
if ($http_pragma = 'no-cache') {
return 405;
}
if ($http_cache_control = 'no-cache') {
return 405;
}
error_page 405 = @nocache;
try_files /typo3temp/tx_ncstaticfilecache/$host${request_uri}index.html @nocache;
}
location @nocache {
try_files $uri $uri/ /index.php$is_args$args;
}
#!/bin/bash
#
# Run composer in a container
#
# This script will attempt to mirror the host paths by using volumes for the
# following paths:
# * $(pwd)
# * $(dirname $COMPOSE_FILE) if it's set
# * $HOME if it's set
#
# You can add additional volumes (or any docker run options) using
# the $COMPOSER_OPTIONS environment variable.
COMPOSER_OPTIONS=${COMPOSER_OPTIONS:-}
# You can set the composer cache directory using the $COMPOSER_CACHE
# environment variable.
COMPOSER_CACHE=${COMPOSER_CACHE:-/tmp/composer}
# You can set the ssh key to be used using the $SSH_IDENTITY_FILE
# environment variable.
SSH_IDENTITY_FILE=${SSH_IDENTITY_FILE:-~/.ssh/id_rsa}
set -e
VERSION="1.2-alpine"
IMAGE="composer/composer:$VERSION"
# Setup volume mounts for composer config, context and ssh keys
if [ "$(pwd)" != '/' ]; then
VOLUMES="-v $(pwd):$(pwd)"
fi
if [ -n "$COMPOSER_FILE" ]; then
composer_dir=$(dirname $COMPOSER_FILE)
fi
# TODO: also check --file argument
if [ -n "$composer_dir" ]; then
VOLUMES="$VOLUMES -v $composer_dir:$composer_dir"
fi
if [ -n "$SSH_IDENTITY_FILE" ]; then
ssh_identity_dir=$(dirname $SSH_IDENTITY_FILE)
fi
# TODO: also check --file argument
if [ -n "$ssh_identity_dir" ]; then
VOLUMES="$VOLUMES -v $ssh_identity_dir:/root/.ssh"
fi
if [ -n "$COMPOSER_CACHE" ]; then
composer_cache_dir=$(dirname $COMPOSER_CACHE)
fi
# TODO: also check --file argument
if [ -n "$composer_cache_dir" ]; then
VOLUMES="$VOLUMES -v $composer_cache_dir:/composer/cache"
fi
if [ -n "$HOME" ]; then
VOLUMES="$VOLUMES -v $HOME:$HOME -v $HOME:/root" # mount $HOME in /root to share docker.config
fi
# Only allocate tty if we detect one
if [ -t 1 ]; then
DOCKER_RUN_OPTIONS="-t"
fi
if [ -t 0 ]; then
DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS -i"
fi
exec docker run --rm -u $(id -u) $DOCKER_RUN_OPTIONS $COMPOSER_OPTIONS $VOLUMES -w "$(pwd)" $IMAGE "$@"
#!/bin/bash
#
# Run docker-compose in a container
#
# This script will attempt to mirror the host paths by using volumes for the
# following paths:
# * $(pwd)
# * $(dirname $COMPOSE_FILE) if it's set
# * $HOME if it's set
#
# You can add additional volumes (or any docker run options) using
# the $COMPOSE_OPTIONS environment variable.
#
set -e
VERSION="1.8.1"
IMAGE="docker/compose:$VERSION"
# Setup options for connecting to docker host
if [ -z "$DOCKER_HOST" ]; then
DOCKER_HOST="/var/run/docker.sock"
fi
if [ -S "$DOCKER_HOST" ]; then
DOCKER_ADDR="-v $DOCKER_HOST:$DOCKER_HOST -e DOCKER_HOST"
else
DOCKER_ADDR="-e DOCKER_HOST -e DOCKER_TLS_VERIFY -e DOCKER_CERT_PATH"
fi
# Setup volume mounts for compose config and context
if [ "$(pwd)" != '/' ]; then
VOLUMES="-v $(pwd):$(pwd)"
fi
if [ -n "$COMPOSE_FILE" ]; then
compose_dir=$(dirname $COMPOSE_FILE)
fi
# TODO: also check --file argument
if [ -n "$compose_dir" ]; then
VOLUMES="$VOLUMES -v $compose_dir:$compose_dir"
fi
if [ -n "$HOME" ]; then
VOLUMES="$VOLUMES -v $HOME:$HOME -v $HOME:/root" # mount $HOME in /root to share docker.config
fi
# Only allocate tty if we detect one
if [ -t 1 ]; then
DOCKER_RUN_OPTIONS="-t"
fi
if [ -t 0 ]; then
DOCKER_RUN_OPTIONS="$DOCKER_RUN_OPTIONS -i"
fi
exec docker run --rm $DOCKER_RUN_OPTIONS $DOCKER_ADDR $COMPOSE_OPTIONS $VOLUMES -w "$(pwd)" $IMAGE "$@"
#!/usr/bin/env bash
# Use this script to test if a given TCP host/port are available
cmdname=$(basename $0)
echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
usage()
{
cat << USAGE >&2
Usage:
$cmdname host:port [-s] [-t timeout] [-- command args]
-h HOST | --host=HOST Host or IP under test
-p PORT | --port=PORT TCP port under test
Alternatively, you specify the host and port as host:port
-s | --strict Only execute subcommand if the test succeeds
-q | --quiet Don't output any status messages
-t TIMEOUT | --timeout=TIMEOUT
Timeout in seconds, zero for no timeout
-- COMMAND ARGS Execute command with args after the test finishes
USAGE
exit 1
}
wait_for()
{
if [[ $TIMEOUT -gt 0 ]]; then
echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT"
else
echoerr "$cmdname: waiting for $HOST:$PORT without a timeout"
fi
start_ts=$(date +%s)
while :
do
(echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1
result=$?
if [[ $result -eq 0 ]]; then
end_ts=$(date +%s)
echoerr "$cmdname: $HOST:$PORT is available after $((end_ts - start_ts)) seconds"
break
fi
sleep 1
done
return $result
}
wait_for_wrapper()
{
# In order to support SIGINT during timeout: http://unix.stackexchange.com/a/57692
if [[ $QUIET -eq 1 ]]; then
timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
else
timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT --timeout=$TIMEOUT &
fi
PID=$!
trap "kill -INT -$PID" INT
wait $PID
RESULT=$?
if [[ $RESULT -ne 0 ]]; then
echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for $HOST:$PORT"
fi
return $RESULT
}
# process arguments
while [[ $# -gt 0 ]]
do
case "$1" in
*:* )
hostport=(${1//:/ })
HOST=${hostport[0]}
PORT=${hostport[1]}
shift 1
;;
--child)
CHILD=1
shift 1
;;
-q | --quiet)
QUIET=1
shift 1
;;
-s | --strict)
STRICT=1
shift 1
;;
-h)
HOST="$2"
if [[ $HOST == "" ]]; then break; fi
shift 2
;;
--host=*)
HOST="${1#*=}"
shift 1
;;
-p)
PORT="$2"
if [[ $PORT == "" ]]; then break; fi
shift 2
;;
--port=*)
PORT="${1#*=}"
shift 1
;;
-t)
TIMEOUT="$2"
if [[ $TIMEOUT == "" ]]; then break; fi
shift 2
;;
--timeout=*)
TIMEOUT="${1#*=}"
shift 1
;;
--)
shift
CLI="$@"
break
;;
--help)
usage
;;
*)
echoerr "Unknown argument: $1"
usage
;;
esac
done
if [[ "$HOST" == "" || "$PORT" == "" ]]; then
echoerr "Error: you need to provide a host and port to test."
usage
fi
TIMEOUT=${TIMEOUT:-15}
STRICT=${STRICT:-0}
CHILD=${CHILD:-0}
QUIET=${QUIET:-0}
if [[ $CHILD -gt 0 ]]; then
wait_for
RESULT=$?
exit $RESULT
else
if [[ $TIMEOUT -gt 0 ]]; then
wait_for_wrapper
RESULT=$?
else
wait_for
RESULT=$?
fi
fi
if [[ $CLI != "" ]]; then
if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then
echoerr "$cmdname: strict mode, refusing to execute subprocess"
exit $RESULT
fi
exec $CLI
else
exit $RESULT
fi
/bin
/vendor
/typo3_src
/html/index.php
/html/typo3
/html/fileadmin/
/html/typo3conf/ext/*
/html/typo3conf/AdditionalConfiguration.php
/html/typo3conf/PackageStates.php
/html/typo3conf/l10n
/html/typo3temp/
/html/uploads/
!/html/typo3conf/ext/t3olayout
version: "2"
services:
data:
image: busybox
volumes:
- ./:/src
- ./data/etc/db/conf.d:/etc/mysql/conf.d
- ./data/etc/db/entrypoint.d:/docker-entrypoint-initdb.d
- /tmp/composer/cache:/tmp/composer/cache
- /var/lib/mysql
- ./data/typo3:/var/www
- ./data/etc/nginx:/etc/nginx/conf.d
- ./data/etc/php/entrypoint.d/user/:/usr/local/entrypoint.d/user/
- ./data/etc/solr/server/solr/mycores/:/opt/solr/server/solr/mycores/
db:
image: mariadb:10
environment: &db_env
MYSQL_USER: "${DATABASE_USER}"
MYSQL_PASSWORD: "${DATABASE_USER_PASSWORD}"
MYSQL_DATABASE: "${DATABASE_NAME}"
MYSQL_ROOT_PASSWORD: "${DATABASE_ROOT_PASSWORD}"
volumes_from:
- data
nginx:
image: nginx
networks:
- proxy
- default
environment:
VIRTUAL_HOST: t3o.typo3.*
VIRTUAL_PORT: 80
CERT_NAME: default
volumes_from:
- data
depends_on:
- php
php:
image: torvitas/php-fpm:7-alpine
environment:
<<: *db_env
TYPO3_CONTEXT: "${TYPO3_CONTEXT}"
WEB_ROOT: '/var/www/'
TYPO3_SITENAME: 'TYPO3 Extension Repository'
volumes_from:
- data
working_dir: /var/www