Skip to content

Commit 11751ab

Browse files
committed
Set up custom Postgres image
1 parent b031944 commit 11751ab

4 files changed

Lines changed: 89 additions & 0 deletions

File tree

.github/workflows/docker-build.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- 'warehouse-postgres-docker/**'
9+
workflow_dispatch:
10+
11+
env:
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: hackclub/warehouse-postgres
14+
15+
jobs:
16+
build-and-push:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
packages: write
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
with:
26+
submodules: recursive
27+
28+
- name: Set up Docker Buildx
29+
uses: docker/setup-buildx-action@v3
30+
31+
- name: Log in to GitHub Container Registry
32+
uses: docker/login-action@v3
33+
with:
34+
registry: ${{ env.REGISTRY }}
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Extract metadata (tags, labels) for Docker
39+
id: meta
40+
uses: docker/metadata-action@v5
41+
with:
42+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
43+
tags: |
44+
type=raw,value=17
45+
type=raw,value=17-{{sha}}
46+
47+
- name: Build and push Docker image
48+
uses: docker/build-push-action@v6
49+
with:
50+
context: ./warehouse-postgres-docker
51+
push: true
52+
tags: ${{ steps.meta.outputs.tags }}
53+
labels: ${{ steps.meta.outputs.labels }}
54+
cache-from: type=gha
55+
cache-to: type=gha,mode=max
56+

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "warehouse-postgres-docker/vendor/pg_xxhash"]
2+
path = warehouse-postgres-docker/vendor/pg_xxhash
3+
url = https://github.com/hatarist/pg_xxhash.git
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
ARG BASE_IMAGE=postgres:17-alpine
2+
3+
## Custom Alpine Postgres docker file with pg_xxhash extension
4+
FROM ${BASE_IMAGE} AS builder
5+
6+
# Install required dependencies for building the extension
7+
RUN apk --no-cache add \
8+
make \
9+
gcc \
10+
g++ \
11+
clang19 \
12+
llvm19 \
13+
postgresql-dev
14+
15+
# Copy the vendored pg_xxhash source
16+
COPY vendor/pg_xxhash /xxhash
17+
18+
WORKDIR /xxhash
19+
20+
# Build and install the extension
21+
RUN make && make install
22+
23+
## Final image - start fresh from base
24+
FROM ${BASE_IMAGE}
25+
26+
## Copy all extensions from the builder stage
27+
COPY --from=builder /usr/local/lib/postgresql/* /usr/local/lib/postgresql/
28+
COPY --from=builder /usr/local/share/postgresql/extension/* /usr/local/share/postgresql/extension/
29+
Submodule pg_xxhash added at c42850e

0 commit comments

Comments
 (0)