
> All paths in the code snippets are relative to the current directory!

# Shell/DataDeployment.sh

Get the production data (database and files) on another server, f.e. your development machine:

```
DEPLOY_TARGET_USER="localuser" \
DEPLOY_TARGET_HOST="127.0.0.1" \
DEPLOY_TARGET_PORT="22" \
DEPLOY_TARGET_DB_USER="localdbuser" \
DEPLOY_TARGET_DB_HOST="127.0.0.1" \
DEPLOY_TARGET_DB_PORT="3306" \
DEPLOY_TARGET_DB_NAME="localdbname" \
DEPLOY_TARGET_FILES_PATH="/path/to/local/files" \
Shell/DataDeployment.sh [localdbpassword] [productiondbpassword]
```

DEPLOY_TARGET_XXX could be your development machine.

The DEPLOY_TARGET_USER should have access to www102@corratec.live.bgm-hosting.com by ssh key authorization.

If you don't want to set "localdbpassword" (which I wouldn't want either, but I found no other solution for GitLab CI) and there is no environment variable DEPLOY_TARGET_DB_PASSWORD the script will ask you for it.
If you don't want to set "localdbpassword" (which I wouldn't want either, for GitLab CI we set it as secret environment variable) and there is no environment variable PRODUCTION_DB_PASSWORD the script will ask you for it.

# Shell/TYPO3SourceDeployment.sh

Get the TYPO3 source on a server, f.e. your development machine:

```
DEPLOY_TARGET_USER="localuser" \
DEPLOY_TARGET_HOST="127.0.0.1" \
DEPLOY_TARGET_PORT="22" \
DEPLOY_TARGET_PATH="/path/to/local/directory/for/typo3/sources/" \
TYPO3_VERSION="7.6.13" \
Shell/TYPO3SourceDeployment.sh
```

DEPLOY_TARGET_XXX could be your development machine.

# Surf/

Surf deployments.

## Surf/ProductionDeployment.php

Deploy to production corratec.live.bgm-hosting.com:

```
GEM_PATH=".gems" \
SURF_WORKSPACE=".surfworkspace" \
TYPO3_SOURCE="/var/www/www102/corratec.com/deployment/shared/typo3_src-7.6.13" \
Surf/surf.phar --configurationPath="Surf" -vvv deploy ProductionDeployment
```

Your local user should have access to www102@corratec.live.bgm-hosting.com by ssh key authorization.

## Surf/StagingDeployment.php

Deploy to staging staging.corratec.live.bgm-hosting.com:

```
GEM_PATH=".gems" \
SURF_WORKSPACE=".surfworkspace" \
TYPO3_SOURCE="/var/www/www102/corratec.com/deployment/shared/typo3_src-7.6.13" \
Surf/surf.phar --configurationPath="Surf" -vvv deploy StagingDeployment
```

Your local user should have access to www102@corratec.live.bgm-hosting.com by ssh key authorization.

## Surf/ReviewDeployment.php

Deploy to review <branchname>.staging.internet.corratec.bgm-hosting.com:

```
GEM_PATH=".gems" \
SURF_WORKSPACE=".surfworkspace" \
TYPO3_SOURCE="/var/www/www102/corratec.com/deployment/shared/typo3_src-7.6.13" \
<<<<<<< HEAD
CI_BUILD_REF_NAME="<branchname>" \
=======
CI_COMMIT_REF_NAME="<branchname>" \
>>>>>>> internet8
Surf/surf.phar --configurationPath="Surf" -vvv deploy ReviewDeployment
```

Your local user should have access to www1@tau.bgm-hosting.com by ssh key authorization.

Before you run the deployment, you have to make sure that the mandatory directories exist on tau.bgm-hosting.com:

```
DEPLOY_TARGET_USER="www1" \
DEPLOY_TARGET_HOST="tau.bgm-hosting.com" \
DEPLOY_TARGET_PORT="20022" \
<<<<<<< HEAD
CI_BUILD_REF_NAME="<branchname>" \
ssh -p"$DEPLOY_TARGET_PORT" "$DEPLOY_TARGET_USER@$DEPLOY_TARGET_HOST" "mkdir -p /var/www/www1/vhosts/corratec/review.internet/$CI_BUILD_REF_NAME/releases/0000000 && ln -s /var/www/www1/vhosts/corratec/review.internet/$CI_BUILD_REF_NAME/releases/0000000 /var/www/www1/vhosts/corratec/review.internet/$CI_BUILD_REF_NAME/releases/current"
=======
CI_COMMIT_REF_NAME="<branchname>" \
ssh -p"$DEPLOY_TARGET_PORT" "$DEPLOY_TARGET_USER@$DEPLOY_TARGET_HOST" "mkdir -p /var/www/www1/vhosts/corratec/review.internet/$CI_COMMIT_REF_NAME/releases/0000000 && ln -s /var/www/www1/vhosts/corratec/review.internet/$CI_COMMIT_REF_NAME/releases/0000000 /var/www/www1/vhosts/corratec/review.internet/$CI_COMMIT_REF_NAME/releases/current"
>>>>>>> internet8
```

# Test/Alive.sh

Test if the TYPO3 frontend and backend answer:

```
TEST_URL="http://bgmweb:webbgm@corratec.live.bgm-hosting.com" \
Test/Alive.sh
```

# Docker/Dockerfile

If you don't want to install all the deployment dependencies (compass, sass, ruby, ...) on your local machine, you can
use a Docker image to run all the scripts mentioned above.

Bet practice is to run the scripts with the help of Docker/testdockerimage.sh. So adjust 
Docker/testdockerimage.sh and then run:

```
docker run --rm --name cor-buildcontainer -v "$PWD/../":/build -e "SSH_PRIVATE_KEY=-----BEGIN RSA PRIVATE KEY-----
		INSERT YOUR PRIVATE KEY WHICH ALLOWS ACCESS TO THE TARGET SERVER BY SSH KEY AUTHORIZATION
-----END RSA PRIVATE KEY-----" dockerregistry.bgm-gmbh.de/corratec/internet /build/Build/Docker/testdockerimage.sh
```

## Build Docker image after changes in Docker/Dockerfile

1. Build the docker image:

```
docker build -t dockerregistry.bgm-gmbh.de/corratec/internet:latest Docker
```

2. Upload the docker image:

```
docker login -u root -p <gitlabserver_root_password> dockerregistry.bgm-gmbh.de
docker push dockerregistry.bgm-gmbh.de/corratec/internet
```
