diff --git a/.github/workflows/_docker.yml b/.github/workflows/_docker.yml new file mode 100644 index 0000000..eb00b2f --- /dev/null +++ b/.github/workflows/_docker.yml @@ -0,0 +1,31 @@ +name: ~ build + +on: + workflow_call: + inputs: + tag: + type: string + required: true + +jobs: + builder: + name: builder image + runs-on: ubuntu-22.04 + steps: + - name: 'Checkout GitHub Action' + uses: actions/checkout@main + + - name: 'Login to GitHub Container Registry' + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: 'Build Postgres Image' + run: | + docker build \ + -f Dockerfile.postgres \ + --platform linux/amd64 \ + -t ghcr.io/trycompa/postgres:${{ inputs.tag }} . + docker push ghcr.io/trycompa/postgres:${{ inputs.tag }} \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..56ff555 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,13 @@ +name: main + +on: + push: + branches: + - main + +jobs: + docker: + name: docker + uses: ./.github/workflows/_docker.yml + with: + tag: '14' \ No newline at end of file diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 0000000..e780b3a --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,12 @@ +name: pr + +on: + pull_request: + workflow_dispatch: + +jobs: + docker: + name: docker + uses: ./.github/workflows/_docker.yml + with: + tag: 14-${{ github.sha }} diff --git a/Dockerfile.postgres b/Dockerfile.postgres new file mode 100644 index 0000000..2c28b9a --- /dev/null +++ b/Dockerfile.postgres @@ -0,0 +1,22 @@ +# Same major version as production +FROM imresamu/postgis:14-3.4 +LABEL org.opencontainers.image.source="https://github.com/trycompa/docker-postgres" + + +# Install build dependencies and pgvector +RUN apt-get update && apt-get install -y \ + build-essential \ + git \ + postgresql-server-dev-14 \ + && git clone --branch v0.5.1 https://github.com/pgvector/pgvector.git \ + && cd pgvector \ + && make \ + && make install \ + && cd .. \ + && rm -rf pgvector \ + && apt-get remove -y build-essential git postgresql-server-dev-14 \ + && apt-get autoremove -y \ + && rm -rf /var/lib/apt/lists/* + +# log all queries +CMD ["postgres", "-c", "log_statement=all"]