diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..d9d6b5e --- /dev/null +++ b/.github/workflows/build.yaml @@ -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 + + diff --git a/README.md b/README.md index 4639dbc..fd1cc9f 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/elastic/README.md b/elastic/README.md index e63632e..094e6cf 100644 --- a/elastic/README.md +++ b/elastic/README.md @@ -1,3 +1,3 @@ # ElasticSearch -* [Single Node](docker-compose.single-node.yml) +* [Single Node](docker-compose.yml) diff --git a/elastic/docker-compose.single-node.yml b/elastic/docker-compose.yml similarity index 100% rename from elastic/docker-compose.single-node.yml rename to elastic/docker-compose.yml diff --git a/frontend/README.md b/frontend/README.md new file mode 100644 index 0000000..986524d --- /dev/null +++ b/frontend/README.md @@ -0,0 +1 @@ +# Frontend diff --git a/frontend/docker-compose.yml b/frontend/docker-compose.yml new file mode 100644 index 0000000..c8eeb93 --- /dev/null +++ b/frontend/docker-compose.yml @@ -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 diff --git a/java/README.md b/java/README.md new file mode 100644 index 0000000..8772b23 --- /dev/null +++ b/java/README.md @@ -0,0 +1 @@ +# Java diff --git a/java/builders/build.dockerfile b/java/builders/build.dockerfile new file mode 100644 index 0000000..e140efd --- /dev/null +++ b/java/builders/build.dockerfile @@ -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"] \ No newline at end of file diff --git a/java/builders/main.dockerfile b/java/builders/main.dockerfile new file mode 100644 index 0000000..37fbfc3 --- /dev/null +++ b/java/builders/main.dockerfile @@ -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"] diff --git a/java/docker-compose.yml b/java/docker-compose.yml new file mode 100644 index 0000000..d4c6260 --- /dev/null +++ b/java/docker-compose.yml @@ -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 diff --git a/kafka/README.md b/kafka/README.md index c9f2a66..8aba0b8 100644 --- a/kafka/README.md +++ b/kafka/README.md @@ -1,3 +1,3 @@ # Kafka and Zookeeper -* [Single Node](docker-compose.standalone.yml) +* [Single Node](docker-compose.yml) diff --git a/kafka/docker-compose.single-node.yml b/kafka/docker-compose.yml similarity index 100% rename from kafka/docker-compose.single-node.yml rename to kafka/docker-compose.yml diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..dd89414 --- /dev/null +++ b/test.sh @@ -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 \ No newline at end of file diff --git a/tracing/README.md b/tracing/README.md index 8d5581e..825ee28 100644 --- a/tracing/README.md +++ b/tracing/README.md @@ -1,3 +1,3 @@ # Jaeger Tracing -* [All-In-One](docker-compose.all-in-one.yml) +* [All-In-One](docker-compose.yml) diff --git a/tracing/docker-compose.all-in-one.yml b/tracing/docker-compose.yml similarity index 100% rename from tracing/docker-compose.all-in-one.yml rename to tracing/docker-compose.yml