Пример создания Continuous Integration/Continuous Delivery процесса для проекта, написанного на Java, c использованием Docker За основу был взят репозитарий, форкнутый с https://github.com/nikhilpathania/hello-world-greeting и его реализация в книге Learning Continuous Integration with Jenkins 2nd Edition by Nikhil Pathania Здесь доступен оригинальный код автора книги https://github.com/PacktPublishing/Learning-Continuous-Integration-with-Jenkins-Second-Edition Все подготовительные работы(установка и интеграция Jenkins,Maven,SonarQube,Nexus) были выполнены в предыдущих статьях: […]
Записи с меткой ‘docker’
Jenkins: создание Continuous Integration/Continuous delivery процесса в Jenkins для проекта Java с использованием Docker


Установка Nexus и создание Docker-репозитария на Ubuntu16


Установка Java
1 |
# apt-get update && apt-get install default-jdk |
1 |
# update-alternatives --config java |
1 2 |
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java Nothing to configure. |
1 |
# nano /etc/environment |
1 |
JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64" |
1 |
# source /etc/environment |
1 |
# echo $JAVA_HOME |
1 |
/usr/lib/jvm/java-8-openjdk-amd64 |
Установка Nexus
1 |
# wget http://download.sonatype.com/nexus/3/latest-unix.tar.gz |
1 |
# tar xvf latest-unix.tar.gz -C /opt/ |
1 |
# ln -s /opt/nexus-* /opt/nexus |
1 |
# useradd -m -r -s /bin/false nexus |
1 |
# chown -R nexus:nexus /opt/nexus-* /opt/sonatype-work /opt/nexus |
1 |
# nano /opt/nexus/bin/nexus.rc |
1 |
run_as_user="nexus" |
1 |
# nano /etc/systemd/system/nexus.service |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[Unit] Description=nexus service After=network.target [Service] Type=forking ExecStart=/opt/nexus/bin/nexus start ExecStop=/opt/nexus/bin/nexus stop User=nexus Restart=on-abort [Install] WantedBy=multi-user.target |
1 |
# systemctl daemon-reload && systemctl enable nexus |
1 |
# systemctl start nexus && systemctl status nexus |
Логи смотрим в
1 |
# tail -f /opt/sonatype-work/nexus3/log/*.log |
Настройка ротации логов Nexus
1 |
# cat /etc/logrotate.d/nexus |
1 2 3 4 5 6 7 8 9 10 |
/opt/sonatype-work/nexus3/log/*.log { daily dateext copytruncate missingok rotate 3 compress delaycompress notifempty } |
Установка Nginx
1 |
# wget -q -O - https://nginx.org/keys/nginx_signing.key | apt-key add - |
1 |
# nano /etc/apt/sources.list.d/nginx.list |
1 2 |
deb http://nginx.org/packages/ubuntu/ xenial nginx deb-src http://nginx.org/packages/ubuntu/ xenial nginx |
1 |
# apt-get update && apt-get install nginx |
1 |
# systemctl enable nginx && systemctl start nginx |
Настройка проксирования Nginx на Nexus
1 |
# nano /etc/nginx/conf.d/nexus.mydomain.com.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
upstream nexus_server { server 127.0.0.1:8081 fail_timeout=0; } server { listen 80; server_name nexus.mydomain.com www.nexus.mydomain.com; error_log /var/log/nginx/nexus-error.log; access_log /var/log/nginx/nexus-access.log main; location / { proxy_redirect off; proxy_pass http://nexus_server; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_read_timeout 90; } } |
1 |
# nano /etc/nginx/ssl.conf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
ssl_session_cache shared:SSL:20m; ssl_session_timeout 1d; ssl_prefer_server_ciphers on; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; ssl_dhparam /etc/nginx/ssl/dhparam.pem; # ssl_ecdh_curve secp521r1; ## Improves TTFB by using a smaller SSL buffer than the nginx default ssl_buffer_size 8k; ## Enables OCSP stapling ssl_stapling on; resolver 8.8.8.8; ssl_stapling_verify on; ## Send header to tell the browser to prefer https to http #add_header Strict-Transport-Security max-age=31536000; |
1 |
# openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
1 |
# nginx -t && service nginx reload |
Перевод Nexus […]
Установка и использование Docker на Centos7


1.Установка Docker Для установки Docker требуется 64-х разрядная операционная система и ядро версии 3.10 и выше.
1 |
# uname -r |
1 |
3.10.0-327.36.2.el7.x86_64 |
1 |
# cat /etc/redhat-release |
1 |
CentOS Linux release 7.2.1511 (Core) |
Обновим пакеты
1 |
# yum update |
Добавляем репозитарий Docker
1 |
# tee /etc/yum.repos.d/docker.repo <<-'EOF' |
1 2 3 4 5 6 7 |
[dockerrepo] name=Docker Repository baseurl=https://yum.dockerproject.org/repo/main/centos/7/ enabled=1 gpgcheck=1 gpgkey=https://yum.dockerproject.org/gpg EOF |
Непосредственно установим Docker
1 |
# yum install docker-engine |
Добавление Docker в автозагрузку
1 |
# systemctl enable docker |
Запуск Docker
1 |
# systemctl start docker |
Проверка состояния Docker
1 |
# systemctl status docker |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2016-10-20 23:10:36 EEST; 6s ago Docs: https://docs.docker.com Main PID: 1366 (dockerd) Memory: 18.5M CGroup: /system.slice/docker.service ├─1366 /usr/bin/dockerd └─1370 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-interval=0 --st... Oct 20 23:10:35 centos71.kamaok.org.ua dockerd[1366]: time="2016-10-20T23:10:35.240268299+03:00" level=warning msg="mountpoint for pids not found" Oct 20 23:10:35 centos71.kamaok.org.ua dockerd[1366]: time="2016-10-20T23:10:35.240569857+03:00" level=info msg="Loading containers: start." Oct 20 23:10:35 centos71.kamaok.org.ua dockerd[1366]: time="2016-10-20T23:10:35.530700626+03:00" level=warning msg="Running modprobe bridge br_netfilter f... Oct 20 23:10:35 centos71.kamaok.org.ua dockerd[1366]: time="2016-10-20T23:10:35.718801030+03:00" level=info msg="Firewalld running: false" Oct 20 23:10:36 centos71.kamaok.org.ua dockerd[1366]: time="2016-10-20T23:10:36.303073111+03:00" level=info msg="Default bridge (docker0) is assig...address" Oct 20 23:10:36 centos71.kamaok.org.ua dockerd[1366]: time="2016-10-20T23:10:36.430876877+03:00" level=info msg="Loading containers: done." Oct 20 23:10:36 centos71.kamaok.org.ua dockerd[1366]: time="2016-10-20T23:10:36.431063740+03:00" level=info msg="Daemon has completed initialization" Oct 20 23:10:36 centos71.kamaok.org.ua dockerd[1366]: time="2016-10-20T23:10:36.431087154+03:00" level=info msg="Docker daemon" commit=bb80604 gra...n=1.12.2 Oct 20 23:10:36 centos71.kamaok.org.ua dockerd[1366]: time="2016-10-20T23:10:36.457437494+03:00" level=info msg="API listen on /var/run/docker.sock" Oct 20 23:10:36 centos71.kamaok.org.ua systemd[1]: Started Docker Application Container Engine. Hint: Some lines were ellipsized, use -l to show in full. |
Просмотр Docker компонентов и их версий
1 |
# docker version |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
Client: Version: 1.12.2 API version: 1.24 Go version: go1.6.3 Git commit: bb80604 Built: OS/Arch: linux/amd64 Server: Version: 1.12.2 API version: 1.24 Go version: go1.6.3 Git commit: bb80604 Built: OS/Arch: linux/amd64 |
Просмотр размещения […]
Установка и использование Docker на Debian


1.Установка Docker Установим пакеты необходимые для работы apt с https-методом и CA-сертификатами
1 |
# apt-get install apt-transport-https ca-certificates |
Импортирование GPG-ключа, которым подписаны пакеты
1 |
# apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D |
Добавление репозитария Docker
1 |
# echo "deb https://apt.dockerproject.org/repo debian-jessie main" | tee -a /etc/apt/sources.list.d/docker.list |
Обновление локального кеша пакетов
1 |
# apt-get update |
Проверка того, что установка Docker будет производиться с официального репозитария Docker, а не с Debian-репозитария
1 |
# apt-cache policy docker-engine | less |
1 2 3 4 5 |
Candidate: 1.12.1-0~jessie Version table: 1.12.1-0~jessie 0 500 https://apt.dockerproject.org/repo/ debian-jessie/main amd64 Packages …………………… |
Установка Docker
1 |
# apt-get install docker-engine |
Проверим,запустился ли докер после установки
1 |
# ps ax | grep docker |
Если […]