Skip to content

Commit 1d8f61e

Browse files
authored
Merge pull request #4 from optiop/feature/build-images
Build images with Github Action
2 parents 875fd6a + 399726c commit 1d8f61e

File tree

5 files changed

+54
-6
lines changed

5 files changed

+54
-6
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Docker build images
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
env:
10+
AWS_REGION: eu-central-1
11+
12+
permissions:
13+
id-token: write
14+
contents: read
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
image: [ 'grafana', 'postgres' ]
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Set AWS credentials
26+
uses: aws-actions/configure-aws-credentials@v4
27+
with:
28+
role-to-assume: arn:aws:iam::615677714887:role/postgres-grafana-on-ecs-role
29+
aws-region: ${{ env.AWS_REGION }}
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v1
33+
34+
- name: Login to Amazon ECR
35+
id: login-ecr
36+
uses: aws-actions/amazon-ecr-login@v2
37+
38+
- name: Build, tag, and push docker image to Amazon ECR
39+
uses: docker/build-push-action@v5
40+
with:
41+
context: ./src/grafana
42+
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
43+
tags: 615677714887.dkr.ecr.eu-central-1.amazonaws.com/postgres-grafana-on-ecs-${{ matrix.image }}-repo
44+
cache-from: type=gha
45+
cache-to: type=gha,mode=max

ops/repository/iam.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ resource "aws_iam_role" "github_action_role" {
4545
"token.actions.githubusercontent.com:aud" = "sts.amazonaws.com",
4646
"token.actions.githubusercontent.com:sub" = [
4747
"repo:${var.github_owner}/${var.github_repo}:ref:refs/heads/main",
48+
"repo:${var.github_owner}/${var.github_repo}:pull_request"
4849
]
4950
}
5051
}

src/docker-compose.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ version: "3.8"
22

33
services:
44
grafana:
5-
image: grafana/grafana
6-
volumes:
7-
- ./grafana/grafana.ini:/etc/grafana/grafana.ini
8-
- ./grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards
9-
- ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources
5+
build: ./grafana
106
ports:
117
- 3000:3000
128
environment:

src/grafana/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM grafana/grafana:10.3.4
2+
3+
COPY ./provisioning/datasources /etc/grafana/provisioning/datasources
4+
COPY ./provisioning/dashboards /etc/grafana/provisioning/dashboards
5+
6+
COPY ./grafana.ini /etc/grafana/grafana.ini

src/grafana/provisioning/datasources/postgres.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ datasources:
1515
maxIdleConnsAuto: true # Grafana v9.5.1+
1616
connMaxLifetime: 14400 # Grafana v5.4+
1717
postgresVersion: 903 # 903=9.3, 904=9.4, 905=9.5, 906=9.6, 1000=10
18-
timescaledb: false
18+
timescaledb: false

0 commit comments

Comments
 (0)