Skip to content

Commit

Permalink
[ADD] postgres 16 & ARM support
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardotglobal committed Aug 5, 2024
1 parent 8179fde commit a89c10e
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 112 deletions.
96 changes: 65 additions & 31 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: ci

on:
pull_request:
workflow_dispatch:
push:
branches:
- master
Expand All @@ -28,47 +29,80 @@ jobs:

build-test-push:
runs-on: ubuntu-latest
needs: pre-commit
strategy:
fail-fast: false
matrix:
# Test modern Odoo versions with latest Postgres version
pg_version:
- "16"
- "15"
- "14"
- "13"
- "12"
- "11"
- "10"
- "9.6"
platform:
- "amd64"
- "arm64"

env:
# Indicates what's the equivalent to tecnativa/postgres-autoconf:latest image
LATEST_RELEASE: "15-alpine"
# Variables found by default in Docker Hub builder
DOCKER_REPO: tecnativa/postgres-autoconf
DOCKER_TAG: ${{ matrix.pg_version }}-alpine
GIT_SHA1: ${{ github.sha }}
PG_LATEST: "16"
steps:
# Prepare
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
- run: pip install -r tests/ci-requirements.txt
# Build images
- run: ./hooks/build
# Test
- run: python -m unittest tests.test -v
# Push
- name: push to docker hub
if: github.repository == 'Tecnativa/docker-postgres-autoconf' && github.ref == 'refs/heads/master'
env:
REGISTRY_HOST: docker.io
REGISTRY_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
REGISTRY_USERNAME: ${{ secrets.DOCKERHUB_LOGIN }}
run: ./hooks/push
- name: push to github registry
if: github.repository == 'Tecnativa/docker-postgres-autoconf' && github.ref == 'refs/heads/master'
env:
REGISTRY_HOST: ghcr.io
REGISTRY_TOKEN: ${{ secrets.BOT_TOKEN }}
REGISTRY_USERNAME: ${{ secrets.BOT_LOGIN }}
run: ./hooks/push
- uses: actions/checkout@v4

- name: Set up python
uses: actions/setup-python@v1

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
if: matrix.platform != 'amd64'
with:
platforms: ${{ matrix.platform }}

- name: Get build date
id: date
run: echo "date=$(date --rfc-3339 ns)" >> $GITHUB_OUTPUT

- name: Get latest tag
id: tag-latest
if: matrix.pg_version == env.PG_LATEST
run: echo "tag=${{ matrix.platform == 'amd64' && ' latest' || format(' latest-{0}', matrix.platform) }}" >> $GITHUB_OUTPUT

- name: Build image
id: build
uses: redhat-actions/buildah-build@v2
with:
image: postgres-autoconf
tags: ${{ matrix.platform == 'amd64' && format('{0}-alpine', matrix.pg_version) || format('{0}-alpine-{1}', matrix.pg_version, matrix.platform) }}${{ steps.tag-latest.outputs.tag || '' }}
context: .
platforms: linux/${{ matrix.platform }}
containerfiles: |
Dockerfile
build-args: |
BUILD_DATE=${{ steps.date.outputs.date }}
VCS_REF=${{ github.sha }}
BASE_TAG=${{ matrix.pg_version }}-alpine
- name: Install requirements for testing
run: pip install -r tests/ci-requirements.txt

- name: Run unit tests
run: python -m unittest tests.test -v

- name: Push image to Docker Hub
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build.outputs.image }}
tags: ${{ steps.build.outputs.tags }}
registry: docker.io/tecnativa
username: ${{ secrets.DOCKERHUB_LOGIN }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Push image to GHCR
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build.outputs.image }}
tags: ${{ steps.build.outputs.tags }}
registry: ghcr.io/Tecnativa
username: ${{ github.BOT_LOGIN }}
password: ${{ secrets.BOT_TOKEN }}
9 changes: 1 addition & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,7 @@ ENV CERTS="{}" \
RUN apk add --no-cache python3 \
&& mkdir -p /etc/postgres \
&& chmod a=rwx /etc/postgres
RUN apk add --no-cache -t .build \
build-base \
linux-headers \
py3-pip \
python3-dev \
&& pip3 install --no-cache-dir \
netifaces \
&& apk del .build
RUN apk add --no-cache py3-netifaces
COPY autoconf-entrypoint /

# Metadata
Expand Down
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# PostgreSQL Auto-Conf

[![Build Status](https://travis-ci.org/Tecnativa/docker-postgres-autoconf.svg?branch=master)](https://travis-ci.org/Tecnativa/docker-postgres-autoconf)
[![Docker Pulls](https://img.shields.io/docker/pulls/tecnativa/postgres-autoconf.svg)](https://hub.docker.com/r/tecnativa/postgres-autoconf)
[![Layers](https://images.microbadger.com/badges/image/tecnativa/postgres-autoconf.svg)](https://microbadger.com/images/tecnativa/postgres-autoconf)
[![Commit](https://images.microbadger.com/badges/commit/tecnativa/postgres-autoconf.svg)](https://microbadger.com/images/tecnativa/postgres-autoconf)
[![License](https://img.shields.io/github/license/Tecnativa/docker-postgres-autoconf.svg)](https://github.com/Tecnativa/docker-postgres-autoconf/blob/master/LICENSE)

## What

Image that configures Postgres before starting it.
Expand Down Expand Up @@ -104,5 +98,3 @@ Wether to enable or not TLS in WAN connections.
#### `WAN_USERS`

Users allowed to connect from WAN.

[`Dockerfile`]: https://github.com/Tecnativa/docker-postgres-autoconf/blob/master/Dockerfile
26 changes: 0 additions & 26 deletions hooks/build

This file was deleted.

32 changes: 0 additions & 32 deletions hooks/push

This file was deleted.

4 changes: 0 additions & 4 deletions setup.cfg

This file was deleted.

3 changes: 0 additions & 3 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ class PostgresAutoconfCase(unittest.TestCase):

@classmethod
def setUpClass(cls):
with local.cwd(local.cwd / ".."):
print("Building image")
local["./hooks/build"] & FG
cls.image = f"tecnativa/postgres-autoconf:{local.env['DOCKER_TAG']}"
cls.cert_files = ("client.ca.cert.pem", "server.cert.pem", "server.key.pem")
return super().setUpClass()
Expand Down

0 comments on commit a89c10e

Please sign in to comment.