Skip to content

Instantly share code, notes, and snippets.

@stefanotroia
stefanotroia / gitlab-ci-mavenBuild.yml
Created November 5, 2019 17:10
Build Docker images with Maven in Gitlab CI/CD
image: docker:latest
services:
- docker:dind
variables:
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
DOCKER_DRIVER: overlay
SPRING_PROFILES_ACTIVE: gitlab-ci
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
@stefanotroia
stefanotroia / gitlab-ci-ansible.yml
Created November 5, 2019 17:13
Deploy in gitlab ci job with ansible
deploy:
image:
name: stefanotroia/ansible:latest
stage: deploy
script:
- printf "[ci_group]\n $SSH_SERVER ansible_ssh_user=$SSH_USER \n" > /etc/ansible/hosts
- cp $SSH_KEY key.pem && chmod 600 key.pem
- eval `keychain --eval` > /dev/null 2>&1
- ssh-add key.pem
- ansible-playbook $CI_PROJECT_DIR/ansible-scripts/deploy.yml
@stefanotroia
stefanotroia / playbook.yml
Created November 5, 2019 17:15
Ansible playbook example
- hosts: ansible_group
pre_tasks:
- name: 'System init'
include_tasks: docker-install.yml
tasks:
#[DOCKER] Create dockernetwork
- name: '[DOCKER] Create docker network'
become: yes
docker_network:
name: my_network#[NGINX] Run container
@stefanotroia
stefanotroia / pom.xml
Created November 5, 2019 17:17
Pom xml with jib plugin
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>1.1.2</version>
<configuration>
<from>
<image>openjdk:8-jre-alpine</image>
</from>
<to>
@stefanotroia
stefanotroia / tick-compose.yml
Created November 5, 2019 17:23
TICK docker compose
version: '3'
services:
influxdb:
image: 'influxdb:latest'
container_name: influxDB
networks:
- tick-network
volumes:
- '/home/tick/influxdb/data:/var/lib/influxdb'
- '/home/tick/influxdb/config/:/etc/influxdb/'
@stefanotroia
stefanotroia / snippet.java
Created November 13, 2019 17:15
Executor sample
ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(2));
@stefanotroia
stefanotroia / async.java
Last active November 13, 2019 17:18
Async Task
private ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(2));
service.sumbit(()-> {
log.info("Async");
//TODO LOGIC
});
@stefanotroia
stefanotroia / rabbit.yml
Created November 13, 2019 17:21
Spring rabbit conf
spring:
 rabbitmq:
 host: 127.0.0.1
 port: 5672
 username: "username"
 password: "password"
@stefanotroia
stefanotroia / consumer-1.java
Created November 13, 2019 17:22
Rabbit consume with threads
private ListeningExecutorService service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10));
@RabbitListener(queues = {DEMO})
public void consumeMessages(Message message) {
service.submit(()-> {this.consumeMessage(strMsg);});
}
@stefanotroia
stefanotroia / reactor.xml
Created November 13, 2019 17:25
Reactor dependecies
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
</dependency>
<dependency>
<groupId>io.projectreactor.rabbitmq</groupId>
<artifactId>reactor-rabbitmq</artifactId>
</dependency>