Working with Jenkins
Short instruction to work with Jenkins.
- Connect to Jenkins login (page)http://adcentrl-jenkins.devopss.ru/ and use your credentials to login. Jenkins deploy site from project that call "Deploy_WP".
- For Build project open "Deploy_WP" and click on "Build with parameters" then choose your branch and click on "build" button.
- "Stage view" need to look for state of running build. Windows of stages needed to check logs end errors.
- Jenkins using script to deploy app. To see the text of this script, click on "Configure".
- Also this project use environments to run app. To see and manage list of evironments you can if connect to this (page)http://adcentrl-jenkins.devopss.ru/configfiles/editConfig?id=staging-env
- List of environments are manual and developers could add change or create new list of environents (here)http://adcentrl-jenkins.devopss.ru/configfiles/selectProvider and add it to jenknis script. Better user custom type of file.
Script Description
Stage 1 "Getup Code"
Jenkins do checkout code of repository and branch that will be selected in "Build with parameters" page. Jenkins do checkout from last commit of repository. Also print hash of commit.
Stage 2 "Get configs"
Copying environments to file and pushing it to directory on server. List on environments located (here)http://adcentrl-jenkins.devopss.ru/configfiles/editConfig?id=staging-env
Stage 3 "Build WP Image"
Runs docker from Dockerfile in home directory. And then pushing results to hub.
Stage 4 "Start App"
Runs docker-compose to deploy application with current parameters thats are created in Stage 3.
Run application locally
List of commands that could help run application on local machine:
- Be sure that Docker and Docker compose are installed. if not use this links Install Docker and Install Docker Compose
- Create directory on local machine by command:
sudo mkdir *your directory name* - Give permitions to directory:
sudo chown *your username*:*your username* . - Download docker-compose.yml and .env.sample file from repo:
git clone *repo_url* .Also user-b *branch name*key to put name of needed branch - Rename .env.sample to .env:
sudo cp .env.sample .env - Be sure that docker-compose.yml and .env files are in the same directory.
- Before run docker-compose use this command an once
sudo docker login hub.shakuro.comlogin - shakuro, pass - ask your SysAdm - Run docker compose:
sudo docker-compose up -d-d means run continers as a daemon - If need to explore logs of container:
sudo docker logs *container name* - If need to explore what environments container is using:
sudo docker inspect *container name* - Connect to running container:
sudo docker exec -ti *container name* bashorsudo docker exec -ti *container name* sh - Restart container:
sudo docker restart *container name* - Run command in container:
sudo docker exec -ti *container name* *linux command*. For example:sudo docker exec -ti nginx cat /etc/nginx/sites-available/default. Also it could be run inside of container. - Copy file to container:
sudo docker cp path/to/file *container name*:/path/to/directory/or/file