Skip to content

Commit c853a42

Browse files
committed
Initial implementation
1 parent b0720b5 commit c853a42

14 files changed

Lines changed: 743 additions & 1 deletion

File tree

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/mvnw text eol=lf
2+
*.cmd text eol=crlf
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Docker build and publish to GHCR
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
release:
8+
types: [published] # will use tag name regardless of naming
9+
10+
jobs:
11+
build_and_publish:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
packages: write
16+
steps:
17+
- name: Checkout current Repository
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Docker Buildx
21+
id: buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Available platforms
25+
run: echo ${{ steps.buildx.outputs.platforms }}
26+
27+
- name: Log in to the Container registry
28+
run: docker login --username Cambio-Project --password ${{secrets.PUBLISH_PACKAGES}} ghcr.io
29+
30+
- name: Extract metadata (tags, labels) for Docker
31+
id: meta
32+
uses: docker/metadata-action@v5
33+
with:
34+
images: ghcr.io/${{ github.repository }}
35+
tags: |
36+
type=ref,event=tag
37+
type=raw,value=latest
38+
39+
- name: Build and push Docker image
40+
uses: docker/build-push-action@v5
41+
with:
42+
context: .
43+
platforms: linux/amd64,linux/arm64
44+
push: true
45+
tags: ${{ steps.meta.outputs.tags }}
46+
labels: ${{ steps.meta.outputs.labels }}
47+
build-args: |
48+
EXECUTION_ENV=ci
49+
GITHUB_TOKEN=${{ secrets.PUBLISH_PACKAGES }}
50+
GITHUB_USER=${{ github.actor }}

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
HELP.md
2+
target/
3+
.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
wrapperVersion=3.3.2
18+
distributionType=only-script
19+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip

Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Stage 1: Build Spring Boot app
2+
FROM maven:3.9.5-eclipse-temurin-21 AS builder
3+
WORKDIR /app
4+
COPY pom.xml .
5+
COPY src ./src
6+
RUN mvn clean package -DskipTests
7+
8+
# Stage 2: Runtime with Java + Prometheus
9+
FROM eclipse-temurin:21-jre
10+
11+
# Set Prometheus version
12+
ENV PROM_VERSION=3.5.0
13+
14+
# Install Prometheus + promtool
15+
RUN curl -sSL https://github.com/prometheus/prometheus/releases/download/v${PROM_VERSION}/prometheus-${PROM_VERSION}.linux-amd64.tar.gz \
16+
| tar -xz -C /opt && \
17+
mv /opt/prometheus-${PROM_VERSION}.linux-amd64 /opt/prometheus
18+
19+
# Symlinks for convenience
20+
RUN ln -s /opt/prometheus/prometheus /usr/local/bin/prometheus && \
21+
ln -s /opt/prometheus/promtool /usr/local/bin/promtool
22+
23+
# Copy Spring Boot JAR
24+
COPY --from=builder /app/target/*.jar /prometheus-service.jar
25+
26+
# Prometheus config dir
27+
COPY prometheus.yml /etc/prometheus/prometheus.yml
28+
29+
# Expose ports
30+
EXPOSE 9090 8080
31+
32+
# Entrypoint: run both Prometheus + Spring Boot
33+
CMD sh -c "\
34+
prometheus \
35+
--config.file=/etc/prometheus/prometheus.yml \
36+
--storage.tsdb.path=/prometheus \
37+
--web.enable-lifecycle & \
38+
java -jar /prometheus-service.jar \
39+
"

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
Initial
1+
Endpoint:
2+
api/import
3+
Expects OpenMetrics file as Parameter "file"
4+
5+
Local Build:
6+
podman build -t prom-with-import .
7+
8+
Run:
9+
podman run -p 9090:9090 -p 8080:8080 prom-with-import

0 commit comments

Comments
 (0)