Skip to content

Commit 80d231a

Browse files
authored
chore(workflows): Buld postgres container (#129)
1 parent 2055070 commit 80d231a

File tree

4 files changed

+58
-7
lines changed

4 files changed

+58
-7
lines changed

.github/workflows/build.yml

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ on:
88

99
env:
1010
REGISTRY: ghcr.io
11-
IMAGE_NAME: ${{ github.repository }}
1211

1312
jobs:
1413
build-container:
@@ -18,6 +17,9 @@ jobs:
1817
contents: read
1918
packages: write
2019

20+
env:
21+
IMAGE_NAME: ${{ github.repository }}
22+
2123
steps:
2224
- name: Checkout repository
2325
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -81,3 +83,51 @@ jobs:
8183
env:
8284
DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && '0' || '7' }}
8385

86+
build-postgres-container:
87+
if: github.event_name != 'pull_request'
88+
runs-on: ubuntu-latest
89+
permissions:
90+
contents: read
91+
packages: write
92+
93+
env:
94+
IMAGE_NAME: ${{ github.repository }}-pgdb
95+
96+
steps:
97+
- name: Checkout repository
98+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
99+
100+
- name: Log in to the Container registry
101+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
102+
with:
103+
registry: ghcr.io
104+
username: ${{ github.actor }}
105+
password: ${{ secrets.GITHUB_TOKEN }}
106+
107+
- name: Set up Buildx
108+
id: setup-buildx
109+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1
110+
111+
- name: Extract metadata (tags, labels) for Container
112+
id: meta
113+
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0
114+
with:
115+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
116+
tags: |
117+
type=ref,event=branch
118+
type=semver,pattern={{version}}
119+
120+
- name: Build and push Docker images
121+
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # 6.18.0
122+
with:
123+
context: .
124+
file: internal/server/postgres/infra/Containerfile
125+
platforms: linux/amd64,linux/arm64
126+
push: ${{ github.event_name != 'pull_request' }}
127+
tags: ${{ steps.meta.outputs.tags }}
128+
labels: ${{ steps.meta.outputs.labels }}
129+
cache-from: type=gha
130+
cache-to: type=gha,mode=max
131+
env:
132+
DOCKER_BUILD_RECORD_RETENTION_DAYS: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && '0' || '7' }}
133+

examples/docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111

1212
api:
1313
build:
14-
context: api
14+
context: ..
1515
dockerfile: Containerfile
1616
ports:
1717
- "50051:50051"
@@ -27,8 +27,8 @@ services:
2727

2828
database:
2929
build:
30-
context: api/src/internal/repository/postgres/infra
31-
dockerfile: Containerfile
30+
context: ..
31+
dockerfile: internal/server/postgres/infra/Containerfile
3232
environment:
3333
POSTGRES_USER: postgres
3434
POSTGRES_PASSWORD: postgres
@@ -75,5 +75,5 @@ configs:
7575
lc_numeric = 'en_US.utf8' # locale for number formatting
7676
lc_time = 'en_US.utf8' # locale for time formatting
7777
default_text_search_config = 'pg_catalog.english'
78-
shared_preload_libraries = 'pg_partman_bgw'
78+
shared_preload_libraries = 'pg_cron'
7979

internal/server/postgres/dataserverimpl.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ func (s *DataPlatformDataServiceServerImpl) GetLatestForecasts(
306306
ForecasterName: fc.ForecasterName,
307307
ForecasterVersion: fc.ForecasterVersion,
308308
},
309-
LocationUuid: fc.GeometryUuid.String(),
310-
Metadata: fc.Metadata,
309+
LocationUuid: fc.GeometryUuid.String(),
310+
Metadata: fc.Metadata,
311311
CreatedTimestampUtc: timestamppb.New(fc.CreatedAtUtc.Time),
312312
}
313313
}

internal/server/postgres/infra/Containerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ RUN apt-get update \
99
&& apt-get install -y --no-install-recommends postgresql-18-cron \
1010
&& rm -rf /var/lib/apt/lists/*
1111

12+
CMD [ "postgres","-c","shared_preload_libraries=pg_cron" ]

0 commit comments

Comments
 (0)