Skip to content

Commit

Permalink
Configure tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Romanow committed Sep 29, 2024
1 parent 4977dd6 commit 75ac183
Show file tree
Hide file tree
Showing 15 changed files with 138 additions and 4 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build
on:
push:
branches:
- master
jobs:
validate:
name: validate
runs-on: ubuntu-latest
outputs:
matrix: |
{
"dir": ${{ steps.set-matrix.outputs.dirs }}
}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Validate
uses: pre-commit/action@v3.0.0

- name: Configure matrix for test
id: set-matrix
run: |
DIRS=$(find . -type f -name 'docker-compose.yml' -exec dirname "{}" \; | sort -u | jq -R | jq -s -c)
echo "dirs=${DIRS}" >> "$GITHUB_OUTPUT"
test:
name: test
runs-on: ubuntu-latest
needs: validate
strategy:
matrix: ${{ fromJson(needs.validate.outputs.matrix) }}
fail-fast: false
max-parallel: 15
steps:
- uses: actions/checkout@v4

- uses: docker/setup-buildx-action@v3

- name: Run containers
timeout-minutes: 10
working-directory: ${{ matrix.dir }}
run: |
docker compose -f up -d --wait
- name: Stop containers
if: always()
working-directory: ${{ matrix.dir }}
run: |
docker compose down -v
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
[![Build](https://github.com/Romanow/docker-compose-examples/actions/workflows/build.yaml/badge.svg?branch=master)](https://github.com/Romanow/docker-compose-examples/actions/workflows/build.yaml)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)

# Docker Compose examples

* [Kafka](kafka/README.md)
* [Monitoring](monitoring/README.md)
* [Postgres](postgres/README.md)
* [Logging](logging/README.md)
* [ElasticSearch](elastic/README.md)
* [Tracing](tracing/README.md)
* [Elastic](elastic/README.md)
* [Frontend](frontend/README.md)
* [Java](java/README.md)
2 changes: 1 addition & 1 deletion elastic/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# ElasticSearch

* [Single Node](docker-compose.single-node.yml)
* [Single Node](docker-compose.yml)
File renamed without changes.
1 change: 1 addition & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Frontend
11 changes: 11 additions & 0 deletions frontend/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
simple-frontend:
image: "romanowalex/simple-frontend:v2.0"
container_name: simple-frontend
ports:
- "8080:80"
healthcheck:
test: "curl --fail http://localhost || exit 1"
interval: 5s
timeout: 3s
retries: 5
1 change: 1 addition & 0 deletions java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Java
20 changes: 20 additions & 0 deletions java/builders/build.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM amazoncorretto:17 AS builder

WORKDIR application
COPY . .

RUN ./gradlew clean assemble && \
mv build/libs/camunda-base.jar application.jar && \
java -Djarmode=layertools -jar application.jar extract

FROM amazoncorretto:17

ENV JAVA_TOOL_OPTIONS="-XX:MaxRAMPercentage=75.0"

WORKDIR application
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./

ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
21 changes: 21 additions & 0 deletions java/builders/main.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM amazoncorretto:17 AS builder

WORKDIR application

ARG JAR_FILE=build/libs/echo-server.jar
COPY ${JAR_FILE} application.jar

RUN java -Djarmode=layertools -jar application.jar extract

FROM amazoncorretto:17

ENV JAVA_TOOL_OPTIONS="-XX:MaxRAMPercentage=75.0"

WORKDIR application

COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./

ENTRYPOINT ["java", "org.springframework.boot.loader.launch.JarLauncher"]
14 changes: 14 additions & 0 deletions java/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: "3.9"
services:
echo-server:
image: romanowalex/echo-server:v2.0
container_name: echo-server
environment:
SPRING_PROFILES_ACTIVE: simple
ports:
- "8080:8080"
healthcheck:
test: [ "CMD", "curl", "--silent", "--fail", "http://localhost:8080/manage/health" ]
interval: 5s
timeout: 5s
retries: 5
2 changes: 1 addition & 1 deletion kafka/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Kafka and Zookeeper

* [Single Node](docker-compose.standalone.yml)
* [Single Node](docker-compose.yml)
File renamed without changes.
6 changes: 6 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash



docker compose -f docker-compose.single-node.yml up -d --wait
docker compose -f docker-compose.single-node.yml down -v
2 changes: 1 addition & 1 deletion tracing/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Jaeger Tracing

* [All-In-One](docker-compose.all-in-one.yml)
* [All-In-One](docker-compose.yml)
File renamed without changes.

0 comments on commit 75ac183

Please sign in to comment.