Skip to content

Commit a959924

Browse files
committed
Add Dockerfile and entrypoint_config_from_env.sh
Update README as well
1 parent 75f9fb9 commit a959924

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM amazon/aws-for-fluent-bit:latest
2+
3+
COPY entrypoint_config_from_env.sh /

README.md

+88
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,90 @@
11
# aws-for-fluent-bit-config-from-env
22
AWS FireLens Fluent Bit image with an option to provide a custom config as an environment variable (`FLUENT_BIT_CONFIG_BASE64`) in base64 format
3+
4+
This customization won't be needed if either https://github.com/aws/containers-roadmap/issues/56 or https://github.com/aws/aws-for-fluent-bit/issues/521 is resolved
5+
6+
## Build and push
7+
8+
```
9+
# Set vars
10+
aws_region=REGION
11+
ecr_domain="AWS_ACCOUNT_ID.dkr.ecr.$aws_region.amazonaws.com"
12+
docker_image="$ecr_domain/custom-fluent-bit:latest"
13+
14+
# Build
15+
docker build -t "$docker_image" .
16+
17+
# Push
18+
aws ecr get-login-password --region "$aws_region" | docker login --username AWS --password-stdin "$ecr_domain"
19+
docker push "$docker_image"
20+
```
21+
22+
## Task definition example
23+
24+
```
25+
{
26+
"family": "firelens-example-cloudwatch_logs",
27+
"taskRoleArn": "arn:aws:iam::AWS_ACCOUNT_ID:role/ecs_task_iam_role",
28+
"executionRoleArn": "arn:aws:iam::AWS_ACCOUNT_ID:role/ecs_task_execution_role",
29+
"networkMode": "awsvpc",
30+
"cpu": "256",
31+
"memory": "512",
32+
"requiresCompatibilities": [
33+
"FARGATE"
34+
],
35+
"containerDefinitions": [
36+
{
37+
"essential": true,
38+
"name": "app",
39+
"image": "nginx",
40+
"logConfiguration": {
41+
"logDriver": "awsfirelens"
42+
},
43+
"memoryReservation": 100
44+
},
45+
{
46+
"essential": true,
47+
"name": "log_router",
48+
"image": "AWS_ACCOUNT_ID.dkr.ecr.REGION.amazonaws.com/custom-fluent-bit:latest",
49+
"command": [
50+
"/entrypoint_config_from_env.sh"
51+
],
52+
"firelensConfiguration": {
53+
"type": "fluentbit",
54+
"options": {
55+
"config-file-type": "file",
56+
"config-file-value": "/fluent-bit/configs/config-from-env.conf"
57+
}
58+
},
59+
"logConfiguration": {
60+
"logDriver": "awslogs",
61+
"options": {
62+
"awslogs-group": "firelens-container",
63+
"awslogs-region": "REGION",
64+
"awslogs-create-group": "true",
65+
"awslogs-stream-prefix": "firelens"
66+
}
67+
},
68+
"environment": [
69+
{
70+
"name": "FLUENT_BIT_CONFIG_BASE64",
71+
"value": "W09VVFBVVF0KICAgIE5hbWUgY2xvdWR3YXRjaF9sb2dzCiAgICBNYXRjaCAqCiAgICByZWdpb24gJHtGTFVFTlRfQklUX0xPR19SRUdJT059CiAgICBsb2dfa2V5IGxvZwogICAgbG9nX2dyb3VwX25hbWUgJHtGTFVFTlRfQklUX0xPR19HUk9VUH0KICAgIGxvZ19zdHJlYW1fcHJlZml4ICR7RkxVRU5UX0JJVF9MT0dfU1RSRUFNX1BSRUZJWH0KICAgIGF1dG9fY3JlYXRlX2dyb3VwIE9uCg=="
72+
},
73+
{
74+
"name": "FLUENT_BIT_LOG_REGION",
75+
"value": "REGION"
76+
},
77+
{
78+
"name": "FLUENT_BIT_LOG_GROUP",
79+
"value": "fluent-bit-cloudwatch"
80+
},
81+
{
82+
"name": "FLUENT_BIT_LOG_STREAM_PREFIX",
83+
"value": "from-fluent-bit-"
84+
}
85+
],
86+
"memoryReservation": 50
87+
}
88+
]
89+
}
90+
```

entrypoint_config_from_env.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
base64 -d <<< "$FLUENT_BIT_CONFIG_BASE64" > /fluent-bit/configs/config-from-env.conf
6+
7+
exec /entrypoint.sh "$@"

0 commit comments

Comments
 (0)