Skip to content

Commit 27b8a99

Browse files
committed
fix postgres service
1 parent 481ec56 commit 27b8a99

File tree

3 files changed

+29
-9
lines changed

3 files changed

+29
-9
lines changed

.github/workflows/custom.yaml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ name: Run with Postgres
33

44
on:
55
workflow_dispatch:
6+
push:
7+
branches:
8+
- main
69

710
jobs:
811
run:
912
runs-on: ubuntu-latest
10-
1113
services:
1214
postgres:
1315
image: postgres:18beta1-alpine
@@ -22,21 +24,27 @@ jobs:
2224
--health-timeout=5s
2325
--health-retries=5
2426
--name postgres
25-
--entrypoint /usr/local/bin/postgres_custom.sh
2627
volumes:
2728
- /tmp/postgres_logs:/var/log/postgresql
28-
- ./postgres_custom.sh:/usr/local/bin
29-
29+
- ${{ github.workspace }}/postgres/postgresql.conf:/var/lib/postgresql/data/postgresql.conf
3030
steps:
3131
- uses: actions/checkout@v3
32+
- name: Install Docker
33+
uses: docker/setup-buildx-action@v3
3234

33-
- name: Wait for Postgres
34-
run: |
35-
until pg_isready -h localhost -U postgres; do sleep 1; done
35+
# - name: Run Postgres
36+
# run: |
37+
# docker run -v /tmp/postgres_logs:/var/log/postgresql -e POSTGRES_PASSWORD=123 -e POSTGRES_DB=testing --name postgres -p 5432:5432 -d postgres:18beta1-alpine postgres -c shared_preload_libraries=auto_explain -c auto_explain.log_min_duration=0 -c auto_explain.log_analyze=true -c auto_explain.log_verbose=true -c auto_explain.log_buffers=true -c auto_explain.log_format=json -c logging_collector=on -c log_directory='/var/log/postgresql' -c log_filename='postgres.log'
38+
39+
- name: List networks
40+
run: docker container inspect postgres
41+
# - name: Wait for Postgres
42+
# run: |
43+
# pg_isready -h localhost -U postgres;
3644

3745
- name: Apply SQL file
3846
run: |
39-
psql -h localhost -U postgres -d testing -f bootstrap.sql
47+
psql -h 127.0.0.1 -U postgres -d testing -f bootstrap.sql
4048
env:
4149
PGPASSWORD: 123
4250

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
postgres \
1+
#!/bin/sh
2+
docker-entrypoint.sh \
3+
postgres \
24
-c shared_preload_libraries=auto_explain \
35
-c auto_explain.log_min_duration=0 \
46
-c auto_explain.log_analyze=true \

postgres/postgresql.conf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
listen_addresses='*'
2+
shared_preload_libraries=auto_explain
3+
auto_explain.log_min_duration=0
4+
auto_explain.log_analyze=true
5+
auto_explain.log_verbose=true
6+
auto_explain.log_buffers=true
7+
auto_explain.log_format=json
8+
logging_collector=on
9+
log_directory='/var/log/postgresql'
10+
log_filename='postgres.log'

0 commit comments

Comments
 (0)