Skip to content

Jeremiaszmacura/app-automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Build and run jenkins from docker-compose witj public ip adress using ngrok


Up

docker-compose up -d

Down

docker-compose down

Remove volumes

docker volume rm jenkins-data jenkins-docker-certs


To use Github webhook with Jenkins as localhost use ngrok:

Linux - run ngrok container to map localhost:8080 to ip adress

docker run -it -e NGROK_AUTHTOKEN=<token> ngrok/ngrok http localhost:8080

Windows/MacOS - run ngrok container to map host.docker.internal:8080 to ip adress

docker run -it -e NGROK_AUTHTOKEN=<token> ngrok/ngrok http host.docker.internal:8080

TO get new created ip adress go to

http://localhost:4040


Build and run jenkins manually


Build Jenkins image from Dockerfile

docker build -t myjenkins-blueocean:2.361.3-1 ./jenkins/Dockerfile

Create docker network for container

docker network create jenkins

Run Jenkins container

Unix

docker run --name jenkins-blueocean --restart=on-failure --detach \
--network jenkins --env DOCKER_HOST=tcp://docker:2376 \
--env DOCKER_CERT_PATH=/certs/client --env DOCKER_TLS_VERIFY=1 \
--publish 8080:8080 --publish 50000:50000 \
--volume jenkins-data:/var/jenkins_home \
--volume jenkins-docker-certs:/certs/client:ro \
myjenkins-blueocean:2.361.3-1

Windows

docker run --name jenkins-blueocean --restart=on-failure --detach --network jenkins --env DOCKER_HOST=tcp://docker:2376 --env DOCKER_CERT_PATH=/certs/client --env DOCKER_TLS_VERIFY=1 --volume jenkins-data:/var/jenkins_home --volume jenkins-docker-certs:/certs/client:ro --publish 8080:8080 --publish 50000:50000 myjenkins-blueocean:2.361.3-1

Get Jenkins secret

docker logs jenkins-blueocean


Development setup


Create python virutal enviroment

Create and active virtual enviroment using venv library:

python3 -m venv .venv
source .venv/bin/activate (Linux)
.venv\Scripts\activate (Windows)

In some Windows cases before activating venv:

Set-ExecutionPolicy Unrestricted -Scope Process

Setup flask app

Linux/MacOS

export FLASK_APP=flaskr/run.py

Windows cmd

set FLASK_APP=flaskr/run.py

Windows powershell

$env:FLASK_APP = "flaskr/run.py"

Install app as library in development mode using setuptool

python -m pip install -e .[dev]

Build package (run command each time after changes anmd before building image from Dockerfile)

python setup.py bdist_wheel

Run PosgreSQL database as container

docker run --name postgres_workshops -e POSTGRES_DB=dev_database -e POSTGRES_USER=dev_user -e POSTGRES_PASSWORD=dev_user -p 5432:5432 -d postgres:14

Run flask app

flask run

Run unit tests

pytest tests

Run linter

Pytlint

python -m pylint flaskr/** tests/**

Black check

python -m black --check .

Black fix

python -m black .