# Biuro websites

## Information
- Task in [Jira](https://biurobaltic.atlassian.net/browse/LIV-1802)
- Project repository [dev.biuro](http://git.biuro.lt/biuro/dev.biuro)
- Created from [wordpress-nginx-docker](https://github.com/mjstealey/wordpress-nginx-docker)
- SSL Certificates are created with [SSL For Free](https://www.sslforfree.com/?domains=biuro.lt%20www.biuro.lt%20dev.biuro.lt%20staging.biuro.lt%20biuro.lv%20www.biuro.lv%20dev.biuro.lv%20staging.biuro.lv%20biuro.ee%20www.biuro.ee%20dev.biuro.ee%20staging.biuro.ee)

## Installation
- Install [Docker Desktop](https://www.docker.com/products/docker-desktop) on your machine
	- Creating new User on my machine helped me with sharing C drive problem (https://tomssl.com/2018/01/11/sharing-your-c-drive-with-docker-for-windows-when-using-azure-active-directory-azuread-aad/)
- Clone [dev.biuro](http://git.biuro.lt/biuro/dev.biuro) repository
- in Command Prompt run `docker-compose up` and wait until WP cli exits (dev-biuro-wordpress-cli exited with code 0)
- set dev.biuro.lt, dev.biuro.lv, dev.biuro.ee to 127.0.0.1 in hosts
- check if dev.biuro.lt, dev.biuro.lv, dev.biuro.ee works
- for CSS & JS assets we user npm, install `C:\web\dev.biuro\ npm install`

## Development
- `C:\web\dev.biuro\ npm run dev`

## Production
- build CSS & JS assets - `C:\web\dev.biuro\ npm run build`
- build new image `docker build -t biuro/web:2.0.0 .` (update version number)
- login to biuro docker account  `docker login --username=biuro --password=9Ndtjd2vKsLvGuFOeFq1KdJs`
- push image to docker repository - `docker push biuro/web:2.0.0`

## Production
- update biuro/web image version in .env file (staging or www)
- upload to server .env file
- login to server via ssh and navigatate to root folder (biuro-staging or wwww)
- login to biuro docker account - `sudo docker login --username=biuro --password=9Ndtjd2vKsLvGuFOeFq1KdJs`
- use new image version  - `sudo docker-compose up -d`
- exit  - `exit`

### connect to servers
- generate ppk file from `!information/ssh-keys/biurolt.pem` key
- save on your PC, DO NOT OVERWITE existing ones. There is ssh/ folder added to gitignore, you can store them here.
- login su ssh or ftp using generated personal ppk key

### staging.biuro.lt (staging.www)
- server: 18.197.154.248
- user: ubuntu

### biuro.lt (www)
- server: 18.195.10.89
- user: admin

### Basic Auth
- biuro_wp_api
- LabAiGeRsKodsu89wapI

## Wordpress
- Regions created using [Wordpress Network](https://codex.wordpress.org/Create_A_Network)

### User
- biuro
- laikinas2587
- info@biuro.eu

### DB backup
- `C:\web\dev.biuro> docker exec -i dev-biuro-mysql mysqldump -udev_user -pY6V6bFkD6@GyD!wTShgFmWz! --default-character-set=utf8 dev_biuro > docker/mariadb/data-004.sql`
- `sudo docker exec -i biuro-staging-mysql mysqldump -ustaging_user -p'qzl8pMNV^gZ&c1!7ebVsXqQh' --default-character-set=utf8 staging_biuro > docker/mariadb/data-022.sql`
- `sudo docker exec -i biuro-www-mysql mysqldump -uwww_user -p'qzl8pMNV^gZ&c1!7ebVsXqQh' --default-character-set=utf8 www_biuro > docker/mariadb/data-020.sql`

### DB restore
- `C:\web\dev.biuro> docker exec -i dev-biuro-mysql mysql -udev_user -pY6V6bFkD6@GyD!wTShgFmWz! --default-character-set=utf8 dev_biuro < docker/mariadb/data-004.sql`

### Plugins
#### Akismet Anti-Spam
#### Biuro Contacts
#### Biuro Feedbacks
#### Biuro HTML
#### Biuro Sections
#### Biuro Services
#### Cookies Warning
#### Data Controller
#### Jobs Importer
#### Pods - Custom Content Types and Fields
#### Polylang
#### Yoast SEO

### SEO
- [Biuro SEO auditas](https://docs.google.com/document/d/1FiwVoiLvGGmi9V-HPBgJ3gsh3wGswt27csgvfdTU24w/edit?usp=sharing)
- [Biuro raktinių žodžių analizė](https://docs.google.com/spreadsheets/d/1ggnqKuGxFFkLgI6NDZq4PXpRY_whdHX0kjZj7pCP_fk/edit?ts=5b5eaa62#gid=0)
- [Biuro.lt SEO issues](https://docs.google.com/spreadsheets/d/1dXP0dh_v2sFajrcwR2_9HONMadCdZQW4Y2dVXvhxG3E/edit?ts=5b5eaa6b#gid=748245000)

p.s. might not be shared with everyone

### UX goals
- [Biuro goals framework](https://docs.google.com/spreadsheets/d/1NYUE9lFjfnB8k6rtW8MA0UBolK_rxLHrJ8MkfWJ5b0o/edit?ts=5b459b0e#gid=1585165681)

## Documentation
### Social links
in Admin sidebar: SEO -> Social -> Accounts tab



## Known local issues (Windows 10)
### Error
ERROR: for mysql  Cannot start service mysql: error while creating mount source path '/host_mnt/c/web/dev.biuro/var/mariadb': mkdir /host_mnt/c: file exists

### Solution
Restart docker (sometimes PC restart may be required)

### Error
Can't share C drive

### Solution
- https://tomssl.com/2018/01/11/sharing-your-c-drive-with-docker-for-windows-when-using-azure-active-directory-azuread-aad/




## After release do:
- check biuro.lv && biuro.ee job descriptions
- check if tag manager is loaded

## Other (Commands)
- docker-compose up -d
- docker-compose start
- docker-compose stop

- docker-compose rm -fv

- docker ps

- docker update --restart=no dev-biuro-mysql
- docker update --restart=no dev-biuro-nginx
- docker update --restart=no dev-biuro-wordpress

- docker system prune --all

- docker stop dev-biuro-mysql
- docker stop dev-biuro-nginx
- docker stop dev-biuro-wordpress

- docker restart dev-biuro-mysql
- docker restart dev-biuro-nginx
- docker restart dev-biuro-wordpress

- sudo docker-compose up -d

- sudo docker restart staging-biuro-nginx
- curl docker

- docker images

- docker rmi 568c4670fa80

- docker save ourdemo > ourdemo.tar

- docker load --input ourdemo.tar

- sudo chown -R www-data:www-data wordpress/wp-content/plugins


### DB preview
- `docker exec -it dev-biuro-nginx sh`
- `docker exec -it dev-biuro-wordpress bash`
- `docker exec -it dev-biuro-mysql bash`
- `mysql -udev_user -p'Y6V6bFkD6@GyD!wTShgFmWz!' --default-character-set=utf8`
- `use dev_biuro;`
- `show tables;`




- `sudo docker exec -it biuro-staging-mysql bash`
- `sudo docker exec -it biuro-www-mysql bash`
- `mysql -uroot -p'#w1ML4QfWaR*8dBYRL7aZJI$' --default-character-set=utf8`
- `use staging_biuro;`
- `use www_biuro;`

- `use information_schema;`
- `select * from SCHEMATA;`

### READ list
- https://ansi.23-5.eu/2017/06/wordpress-docker-nginx/
- https://ropenscilabs.github.io/r-docker-tutorial/04-Dockerhub.html
- https://www.katacoda.com/courses/docker/
- https://hub.docker.com/r/chriszarate/wordpress/
- https://dev.to/netcell/wordpress-development-with-docker-2jk9


