Skip to content

Commit

Permalink
fix(infra): add caddy container and update github actions (#10)
Browse files Browse the repository at this point in the history
* fix(infra): add caddy container

* fix(infra): update github actions and reorganize project structure

github actions workflow 단계에 컨테이너들이 실행 중인지 확인하는 단계를 추가하였으며  Caddyfile에 변경이 있을 경우 Caddy 컨테이너 reload한다.
Caddyfile과 docker-compose.yml 파일을 grafana 폴더에서 레포지토리의 루트 폴더로 이동한다.
docker-compose.yml에 caddy 컨테이너를 추가한다.

* fix(infra): modify logging service configuration to resolve prior push

이전의 푸쉬 중 잘못 작성한 코드를 수정함

caddy와 log(grafana+loki)로 docker compose profile을 나눔
sparse-checkout을 삭제함

* fix(infra): resolve typo
  • Loading branch information
ssupecial authored Jan 22, 2024
1 parent 3df726e commit 3a80325
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 8 deletions.
33 changes: 29 additions & 4 deletions .github/workflows/update-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,42 @@ jobs:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Grafana Configuration
- name: Load dotenv from secret for Grafana Configuration
run: |
cat <<EOF > ./grafana/.env
cat <<EOF > .env
# Sensitive configurations from GitHub Secrets
GF_SMTP_HOST = ${{ secrets.SMTP_HOST }}
GF_SMTP_USER = ${{ secrets.SMTP_USER }}
GF_SMTP_PASSWORD = ${{ secrets.SMTP_PASSWORD }}
GF_SMTP_FROM_ADDRESS = ${{ secrets.FROM_ADDRESS }}
EOF
- name: Check if containers are running
id: check-container
run: |
{
echo 'stdout<<EOF'
docker compose --profile log ps -q
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Initialize containers
if: steps.check-container.outputs.stdout == ''
run: |
docker compose --profile caddy up -d --no-recreate
docker compose --profile log up -d --no-recreate
- name: Run Docker Compose
run: |
cd ./grafana
docker compose up -d
docker compose --profile log up -d
- name: Copy Caddyfile into Caddy Container
run: |
docker cp ./Caddyfile caddy:/etc/caddy/Caddyfile
- name: Gracefully reload Caddy
run: |
docker exec -w /etc/caddy caddy caddy reload
- name: Remove unused docker storages
run: docker system prune -a -f --volumes
File renamed without changes.
24 changes: 20 additions & 4 deletions grafana/docker-compose.yml → docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,55 @@ networks:
loki:

services:
caddy:
profiles: ['caddy']
image: caddy:2.7.6-alpine
container_name: caddy
restart: always
ports:
- "80:80"
- "443:443"
network_mode: host

loki-test:
profiles: ['log']
image: grafana/loki:2.9.0
container_name: loki-test
ports:
- "3199:3100"
volumes:
- '$PWD/loki-config-test.yml:/etc/loki/loki-config.yml'
- '$PWD/grafana/loki-config-test.yml:/etc/loki/loki-config.yml'
command: -config.file=/etc/loki/loki-config.yml
networks:
- loki

loki-stage:
profiles: ['log']
image: grafana/loki:2.9.0
container_name: loki-stage
ports:
- "3101:3100"
volumes:
- '$PWD/loki-config-stage.yml:/etc/loki/loki-config.yml'
- '$PWD/grafana/loki-config-stage.yml:/etc/loki/loki-config.yml'
command: -config.file=/etc/loki/loki-config.yml
networks:
- loki

loki-aws:
profiles: ['log']
image: grafana/loki:2.9.0
container_name: loki-aws
ports:
- "3100:3100"
volumes:
- '$PWD/loki-config-aws.yml:/etc/loki/loki-config.yml'
- '$PWD/grafana/loki-config-aws.yml:/etc/loki/loki-config.yml'
command: -config.file=/etc/loki/loki-config.yml
networks:
- loki


grafana:
profiles: ['log']
image: grafana/grafana:latest
env_file:
- .env
Expand All @@ -51,8 +65,10 @@ services:
- '3000:3000'
volumes:
- 'grafana_storage:/var/lib/grafana'
- '$PWD/grafana.ini:/etc/grafana/grafana.ini'
- '$PWD/grafana/grafana.ini:/etc/grafana/grafana.ini'
networks:
- loki


volumes:
grafana_storage: {}

0 comments on commit 3a80325

Please sign in to comment.