When working with Spring services and exposing REST API calls, you would usually want to have a set of customized objects exposed to the outside world. These objects, usually called DTOs, can expose some of the domain objects or some projection made out of domain objects (or something else). For mapping between domain data objects … Continue reading MapStruct
Multi-stage docker images
When working with docker images, it would be a good idea to keep the final image (especially for production) as small as possible. Usually, when building apps, there are a lot of extra stuff included that are really not necessary for the final image. This can be most obvious with Spring Boot applications, where build … Continue reading Multi-stage docker images
Docker volume on host machine – write access and shared permissions
Using docker for running all kinds of reports (reporting applications, such as performance tests or penetration tests etc.) in the CI is a common practice. However, sometimes you'd have to cleanup the report directory in order to create a new one. When running applications inside a docker, usually they will run as root and files … Continue reading Docker volume on host machine – write access and shared permissions
SpringBoot, Axon, Multiple Data Sources = ? are you doin’?
Ok, so, after playing with this for few days, I have decided to put this into a form of a post, to serve mostly as a reference for anyone facing the same or similar problem. After all, how do you think I solve my problems? Just like that, I search online for solution, then for … Continue reading SpringBoot, Axon, Multiple Data Sources = ? are you doin’?
Run WordPress inside Docker?
By using docker-compose, you can run WordPress site with one command. TLDR: https://github.com/divukman/wordpress-docker docker-compose.yaml: version: '2' services: db: image: mysql:5.7 volumes: - db_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: wordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wordpress: depends_on: - db image: wordpress:latest ports: - "8000:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_PASSWORD: wordpress volumes: db_data: Running $ docker-compose … Continue reading Run WordPress inside Docker?
Run SpringBoot app inside alpine docker container
# From alpine:latest FROM alpine # Install open JDK 11 RUN apk add openjdk11 # Create temp volume VOLUME /tmp # Add and run your app ADD /spring-boot-web-0.0.1-SNAPSHOT.jar myapp.jar ENTRYPOINT ["java", "-Djava.security.egd=file:/dev/./urandom", "-jar", "/myapp.jar"] Build the image: docker build -t alpine-java-3 . Run the image, map the ports 8080 to host machine: docker run -d … Continue reading Run SpringBoot app inside alpine docker container
Docker – Copy file from container to host directory
Ok, so here is one very common question. How do I copy file from a docker image instance (container) to a host file system? Why? One common scenario would be, for example, running a continuous integration server and running Cucumber tests. Once you generate the HTML report, you'd like to copy the file to host … Continue reading Docker – Copy file from container to host directory
Start Tomcat as a Windows service in the debug mode
From the tomcat/bin directory, start the tomcat exe or right click it to get to the properties. In the properties dialog, click the Java tab and BEFORE all of the -D options, add something like this: -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8998 Make sure they are first on the list and each in their own line. From then on, … Continue reading Start Tomcat as a Windows service in the debug mode
Maven/Gradle – exclude tests
Excldue tests in Maven, example: <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <excludes> <exclude>com/dimitar/reactive/springreactive/fluxandmono/*.java</exclude> <exclude>com/dimitar/reactive/springreactive/handler/*.java</exclude> <exclude>com/dimitar/reactive/springreactive/controller/*.java</exclude> </excludes> </configuration> </plugin> ... </plugins> </build> Maven documentation. Exclude tests in Gradle, example: test { exclude 'com/dimitar/reactive/springreactive/fluxandmono/**' } Gradle documentation.
Iptables – Block incoming traffic
I have setup a small home Linux server, based on Debian Linux (stable) and a Lenovo ThinkCentre hardware. Now, I wanted to have an ssh access from outside and I have encountered a few problems that I would like to talk about here. CG NAT Carrier-grade NAT, in essence, means that your home network is … Continue reading Iptables – Block incoming traffic