Skip to content

Commit

Permalink
Provide Docker images (#159)
Browse files Browse the repository at this point in the history
Closes #158
  • Loading branch information
kou authored Nov 9, 2023
1 parent 640dcf4 commit f04789b
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 2 deletions.
19 changes: 19 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

*
!package/docker/
39 changes: 38 additions & 1 deletion .github/workflows/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,26 @@ jobs:
ARCHITECTURE=${PACKAGE_TARGET##*-}
echo "ARCHITECTURE=${ARCHITECTURE}" >> $GITHUB_ENV
case ${PACKAGE_TARGET} in
debian-bookworm-*)
DOCKER_IMAGE_BUILD=yes
DOCKER_TAG_PREFIX="ghcr.io/${GITHUB_REPOSITORY}:"
DOCKER_TAG_SUFFIX="-bookworm-${POSTGRESQL_VERSION}"
DOCKER_TAGS="${DOCKER_VERSION}"
if [ "${GITHUB_REF_TYPE}" = "tag" ]; then
DOCKER_TAGS="${DOCKER_TAG_PREFIX}${GITHUB_REF_NAME}${DOCKER_TAG_SUFFIX}"
DOCKER_TAGS+=",${DOCKER_TAG_PREFIX}latest${DOCKER_TAG_SUFFIX}"
else
DOCKER_TAGS="${DOCKER_TAG_PREFIX}main${DOCKER_TAG_SUFFIX}"
fi
echo "DOCKER_TAGS=${DOCKER_TAGS}" >> $GITHUB_ENV
;;
*)
DOCKER_IMAGE_BUILD=no
;;
esac
echo "DOCKER_IMAGE_BUILD=${DOCKER_IMAGE_BUILD}" >> $GITHUB_ENV
source_archive=$(echo ${BASE_NAME}-*.tar.gz)
VERSION=${source_archive#${BASE_NAME}-}
VERSION=${VERSION%.tar.gz}
Expand Down Expand Up @@ -172,10 +192,13 @@ jobs:
${{ matrix.target }}.tar.gz
env:
GH_TOKEN: ${{ github.token }}
- name: Push Docker image
- name: Push Docker image for building packages
run: |
pushd ${BASE_NAME}/package/${PACKAGE}
rake docker:push || :
cp \
${TASK_NAMESPACE}/repositories/*/pool/*/*/*/*/*.deb \
../docker/
popd
- name: Test
run: |
Expand All @@ -190,3 +213,17 @@ jobs:
local \
package/${PACKAGE}/${TASK_NAMESPACE}/repositories
popd
- uses: docker/setup-qemu-action@v3
if: env.DOCKER_IMAGE_BUILD == 'yes'
- uses: docker/setup-buildx-action@v3
if: env.DOCKER_IMAGE_BUILD == 'yes'
id: buildx
- uses: docker/build-push-action@v5
if: env.DOCKER_IMAGE_BUILD == 'yes'
id: build-push
with:
context: ${{ env.BASE_NAME }}
file: ${{ env.BASE_NAME }}/package/${{ env.PACKAGE }}/Dockerfile
platforms: linux/${{ env.ARCHITECTURE }}
push: ${{ github.event_name == 'push' }}
tags: ${{ env.DOCKER_TAGS }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@
/package/*/apt/env.sh
/package/*/apt/repositories/
/package/*/apt/tmp/
/package/docker/*.deb
52 changes: 52 additions & 0 deletions package/docker/apache-arrow-flight-sql-enable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

set -eux

psql=(psql \
--no-align \
--no-psqlrc \
--tuples-only)
select_shared_preload_libraries=<<SQL
SELECT setting
FROM pg_file_settings
WHERE
name ='shared_preload_libraries' AND
applied
SQL
shared_preload_libraries=$("${psql[@]}" --command "${select_shared_preload_libraries}")
if [ -n "${shared_preload_libraries}" ]; then
shared_preload_libraries+=","
fi
shared_preload_libraries+="arrow_flight_sql"
echo "shared_preload_libraries = '${shared_preload_libraries}'" | \
tee -a "${PGDATA}/postgresql.conf"

ssl=$(psql \
--no-psqlrc \
--tuples-only \
--no-align \
--command "SELECT setting FROM pg_settings WHERE name ='ssl'")
if [ "${ssl}" = "on" ]; then
uri="grpc+tls://0.0.0.0:15432"
else
uri="grpc://0.0.0.0:15432"
fi
echo "arrow_flight_sql.uri = '${url}'" | \
tee -a "${PGDATA}/postgresql.conf"
36 changes: 36 additions & 0 deletions package/postgresql-15-pgdg/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

FROM postgres:15-bookworm

COPY package/docker/postgresql-15-pgdg-apache-arrow-flight-sql_*_amd64.deb ./
RUN \
apt update && \
apt install -y -V lsb-release wget && \
wget https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb && \
apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb && \
rm apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb && \
apt update && \
apt install -y -V \
./postgresql-15-pgdg-apache-arrow-flight-sql_*.deb && \
rm -f postgresql-15-pgdg-apache-arrow-flight-sql_*.deb && \
apt clean && \
rm -rf /var/lib/apt/lists/*

COPY package/docker/apache-arrow-flight-sql-enable.sh /docker-entrypoint-initdb.d/

EXPOSE 15432
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ RUN \
libkrb5-dev \
meson \
ninja-build \
pkg-config \
postgresql-server-dev-15 && \
apt clean
36 changes: 36 additions & 0 deletions package/postgresql-16-pgdg/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

FROM postgres:16-bookworm

COPY package/docker/postgresql-16-pgdg-apache-arrow-flight-sql_*_amd64.deb ./
RUN \
apt update && \
apt install -y -V lsb-release wget && \
wget https://apache.jfrog.io/artifactory/arrow/debian/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb && \
apt install -y -V ./apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb && \
rm apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb && \
apt update && \
apt install -y -V \
./postgresql-16-pgdg-apache-arrow-flight-sql_*.deb && \
rm -f postgresql-16-pgdg-apache-arrow-flight-sql_*.deb && \
apt clean && \
rm -rf /var/lib/apt/lists/*

COPY package/docker/apache-arrow-flight-sql-enable.sh /docker-entrypoint-initdb.d/

EXPOSE 15432
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ RUN \
libkrb5-dev \
meson \
ninja-build \
pkg-config \
postgresql-server-dev-16 && \
apt clean
1 change: 1 addition & 0 deletions src/afs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ extern "C"
# define AFS_FUNC __func__
#endif

// #define AFS_DEBUG
#ifdef AFS_DEBUG
# define P(...) ereport(DEBUG5, errmsg_internal(__VA_ARGS__))
#else
Expand Down
6 changes: 5 additions & 1 deletion test/helper/sandbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def initdb(shared_preload_libraries: [],
end
conf.puts("logging_collector = on")
conf.puts("log_filename = '#{@log_base_name}'")
conf.puts("log_min_messages = debug5") if ENV["AFS_DEBUG"] == "yes"
conf.puts("shared_preload_libraries = " +
"'#{shared_preload_libraries.join(",")}'")
conf.puts("arrow_flight_sql.uri = '#{@flight_sql_uri}'")
Expand Down Expand Up @@ -375,7 +376,10 @@ def setup_postgres
begin
yield
ensure
stop_postgres if @postgresql
if @postgresql
stop_postgres
puts(@postgresql.read_log) unless passed?
end
end
end

Expand Down

0 comments on commit f04789b

Please sign in to comment.