Skip to content

Commit 70bb24c

Browse files
committed
update: Update to deploy
1 parent 32d7c5b commit 70bb24c

8 files changed

Lines changed: 98 additions & 44 deletions

File tree

.github/workflows/ci-cd.yml

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,37 @@ jobs:
1717
- name: Checkout code
1818
uses: actions/checkout@v4
1919

20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
2023
- name: Login to Docker Hub
2124
if: github.event_name != 'pull_request'
2225
uses: docker/login-action@v3
2326
with:
2427
username: ${{ secrets.DOCKERHUB_USERNAME }}
2528
password: ${{ secrets.DOCKERHUB_TOKEN }}
2629

27-
- name: Build Prometheus
28-
run: docker build -f Dockerfile.prometheus -t $PROM_IMAGE:${{ github.sha }} .
29-
30-
- name: Push Prometheus
31-
if: github.event_name != 'pull_request'
32-
run: |
33-
docker tag $PROM_IMAGE:${{ github.sha }} $PROM_IMAGE:latest
34-
docker push $PROM_IMAGE:${{ github.sha }}
35-
docker push $PROM_IMAGE:latest
36-
37-
- name: Build Grafana
38-
run: docker build -f Dockerfile.grafana -t $GRAF_IMAGE:${{ github.sha }} .
39-
40-
- name: Push Grafana
41-
if: github.event_name != 'pull_request'
42-
run: |
43-
docker tag $GRAF_IMAGE:${{ github.sha }} $GRAF_IMAGE:latest
44-
docker push $GRAF_IMAGE:${{ github.sha }}
45-
docker push $GRAF_IMAGE:latest
30+
- name: Build and Push Prometheus
31+
uses: docker/build-push-action@v5
32+
with:
33+
context: .
34+
file: Dockerfile.prometheus
35+
36+
push: ${{ github.event_name != 'pull_request' }}
37+
tags: |
38+
${{ env.PROM_IMAGE }}:${{ github.sha }}
39+
${{ env.PROM_IMAGE }}:latest
40+
cache-from: type=gha
41+
cache-to: type=gha,mode=max
42+
43+
- name: Build and Push Grafana
44+
uses: docker/build-push-action@v5
45+
with:
46+
context: .
47+
file: Dockerfile.grafana
48+
push: ${{ github.event_name != 'pull_request' }}
49+
tags: |
50+
${{ env.GRAF_IMAGE }}:${{ github.sha }}
51+
${{ env.GRAF_IMAGE }}:latest
52+
cache-from: type=gha
53+
cache-to: type=gha,mode=max

Dockerfile.grafana

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
FROM grafana/grafana:12.3.0-18147126998
1+
FROM grafana/grafana:12.3.0
22

33
ENV GF_AUTH_ANONYMOUS_ENABLED=true
44
ENV GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
55

66
COPY grafana/provisioning /etc/grafana/provisioning
7-
87
COPY grafana/provisioning/dashboards/json /var/lib/grafana/dashboards

Dockerfile.prometheus

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
FROM prom/prometheus:v3.6.0
22

3-
COPY prometheus.yml /etc/prometheus/prometheus.yml
3+
USER root
4+
5+
RUN apk add --no-cache gettext
6+
7+
WORKDIR /etc/prometheus
8+
9+
COPY prometheus.yml.template /etc/prometheus/prometheus.yml.template
10+
11+
RUN echo "#!/bin/sh" > /entrypoint.sh && \
12+
echo "envsubst < /etc/prometheus/prometheus.yml.template > /etc/prometheus/prometheus.yml" >> /entrypoint.sh && \
13+
echo "exec /bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/prometheus --web.console.libraries=/usr/share/prometheus/console_libraries --web.console.templates=/usr/share/prometheus/consoles" >> /entrypoint.sh && \
14+
chmod +x /entrypoint.sh
15+
16+
USER nobody
17+
18+
ENTRYPOINT ["/entrypoint.sh"]

docker-compose.dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
networks:
77
- shared_ecommerce_network
88
volumes:
9-
- ./prometheus.yml:/etc/prometheus/prometheus.yml
9+
- ./prometheus.dev.yml:/etc/prometheus/prometheus.dev.yml
1010

1111
grafana:
1212
image: grafana/grafana:12.3.0-18147126998
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: 1
2+
3+
datasources:
4+
- name: Prometheus
5+
type: prometheus
6+
access: proxy
7+
orgId: 1
8+
url: http://prometheus:9090
9+
isDefault: true
10+
editable: true

grafana/provisioning/datasources/datasource.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ datasources:
55
type: prometheus
66
access: proxy
77
orgId: 1
8-
url: http://prometheus:9090
8+
url: ${PROMETHEUS_URL}
99
isDefault: true
1010
editable: true

prometheus.dev.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
global:
2+
scrape_interval: 15s
3+
scrape_timeout: 10s
4+
5+
scrape_configs:
6+
- job_name: 'ecommerce-app'
7+
metrics_path: /ecommerce/api/actuator/prometheus
8+
static_configs:
9+
- targets: ['ecommerce-app:8080']
10+
11+
- job_name: 'reviews-app'
12+
metrics_path: /reviews/api/actuator/prometheus
13+
static_configs:
14+
- targets: ['reviews-app:8081']
15+
16+
- job_name: 'payment-app'
17+
metrics_path: /payment/api/actuator/prometheus
18+
static_configs:
19+
- targets: ['payment-app:8082']
20+
21+
- job_name: 'postgres'
22+
static_configs:
23+
- targets: ['postgres-exporter:9187']
24+
25+
- job_name: 'mongodb'
26+
static_configs:
27+
- targets: ['mongodb-exporter:9216']
28+
29+
- job_name: 'rabbitmq'
30+
static_configs:
31+
- targets: ['rabbitmq:15692']
32+
33+
- job_name: 'prometheus'
34+
static_configs:
35+
- targets: ['localhost:9090']

prometheus.yml

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,22 @@
11
global:
2-
scrape_interval: 15s
2+
scrape_interval: 30s
33
scrape_timeout: 10s
44

55
scrape_configs:
66
- job_name: 'ecommerce-app'
77
metrics_path: /ecommerce/api/actuator/prometheus
8+
scheme: https
89
static_configs:
9-
- targets: ['ecommerce-app:8080']
10+
- targets: ['${ECOMMERCE_HOST}:443']
1011

1112
- job_name: 'reviews-app'
1213
metrics_path: /reviews/api/actuator/prometheus
14+
scheme: https
1315
static_configs:
14-
- targets: ['reviews-app:8081']
16+
- targets: ['${REVIEWS_HOST}:443']
1517

1618
- job_name: 'payment-app'
1719
metrics_path: /payment/api/actuator/prometheus
20+
scheme: https
1821
static_configs:
19-
- targets: ['payment-app:8082']
20-
21-
- job_name: 'postgres'
22-
static_configs:
23-
- targets: ['postgres-exporter:9187']
24-
25-
- job_name: 'mongodb'
26-
static_configs:
27-
- targets: ['mongodb-exporter:9216']
28-
29-
- job_name: 'rabbitmq'
30-
static_configs:
31-
- targets: ['rabbitmq:15692']
32-
33-
- job_name: 'prometheus'
34-
static_configs:
35-
- targets: ['localhost:9090']
22+
- targets: ['${PAYMENT_HOST}:443']

0 commit comments

Comments
 (0)