-
Notifications
You must be signed in to change notification settings - Fork 5
Build local debian image for specific pg versions using the base podman image #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
qount25
wants to merge
8
commits into
postgres-pm:master
Choose a base branch
from
qount25:pg-ver-on-demand-deb-image
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e7669ea
Use full pg version instead of major when forming package name
9fd9648
Use base deb podman image and patch it locally with correct pg versio…
2ae1b01
Problem: users cannot set which minor version of postgresql package t…
0118b31
Problem: podman error on SOME freshly installed systems when running …
8977f44
Problem: pbuilder uses tar, which results in "Cannot readlink: Invali…
e7f816c
Fix: nil error in Timescaledb package, deps should've been an empty a…
cfa3032
Fix: rubocop errors
a6b6c4e
Dockerfile comment: vim and ripgres are for debugging!
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,8 @@ | |
/.yardoc | ||
/_yardoc/ | ||
/coverage/ | ||
/doc/ | ||
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
.idea | ||
Gemfile.lock | ||
Gemfile.lock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
Known podman issues | ||
=================== | ||
|
||
"Unable to start container" error | ||
--------------------------------- | ||
When you first build a package, podman downloads the base image and attempts | ||
to create a local image with correct version PostgreSQL installed into it. | ||
However on some systems, running podman may initially result in the following | ||
error: | ||
|
||
``` | ||
Error: unable to start container "[CONTAINER_ID]": container create failed (no logs from conmon): conmon bytes "": readObjectStart: expect { or n, but found , error found in #0 byte of ...||..., bigger context ...||... | ||
``` | ||
|
||
To fix this issue the following steps need to be performed: | ||
|
||
1. Wipe all podman runtime and configuration: | ||
|
||
pkill -9 -f 'conmon|podman' | ||
rm -rf ~/.local/share/containers/ | ||
rm -rf ~/.config/containers/ | ||
rm -rf /run/user/$(id -u)/libpod/ | ||
podman system reset --force | ||
|
||
2. Reinstall podman and its components: | ||
|
||
sudo apt reinstall podman conmon runc crun | ||
|
||
3. Create storage settings conf file: | ||
|
||
mkdir -p ~/.config/containers/ | ||
touch ~/.config/containers/storage.conf | ||
|
||
# Add the following lines to the newly | ||
# created ~/.config/containers/storage.conf: | ||
# | ||
[storage] | ||
driver = "overlay" | ||
graphroot = "/home/$USER/.local/share/containers/storage" | ||
runroot = "/run/user/$(id -u)/containers" | ||
|
||
4. Restart the service (if applicable): | ||
|
||
service podman restart |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
# { "builder": {"Entitlements": {"security-insecure": true }} } | ||
# ``` | ||
# ``` | ||
# DOCKER_BUILDKIT=1 docker build --allow security.insecure -t IMAGE_NAME /path/to/pgpm | ||
# DOCKER_BUILDKIT=1 docker build --allow security.insecure -t IMAGE_NAME . | ||
# ``` | ||
|
||
# This Dockerfile is used to build a Debian image, which includes pbuilder and | ||
|
@@ -21,11 +21,12 @@ MAINTAINER PGPM Debian Maintainer [email protected] | |
VOLUME /proc | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
RUN apt update | ||
RUN apt install -y build-essential pbuilder fakeroot fakechroot | ||
RUN apt install -y build-essential pbuilder fakeroot fakechroot vim ripgrep | ||
RUN echo 'MIRRORSITE=http://deb.debian.org/debian' > /etc/pbuilderrc | ||
RUN echo 'AUTO_DEBSIGN=${AUTO_DEBSIGN:-no}' > /root/.pbuilderrc | ||
RUN echo 'HOOKDIR=/var/cache/pbuilder/hooks' >> /root/.pbuilderrc | ||
RUN --security=insecure pbuilder create | ||
|
||
COPY pbuilder_install_script.sh /root/pbuilder_install_script.sh | ||
RUN --security=insecure pbuilder execute --save-after-exec /root/pbuilder_install_script.sh | ||
COPY scripts/faketar /usr/bin/ | ||
RUN chmod +x /usr/bin/faketar | ||
RUN sed -E -i "s/local TAR=tar/local TAR=faketar/" /usr/lib/pbuilder/pbuilder-modules | ||
RUN sed -E -i "s/if [!] tar -c --use-compress-program/if ! faketar -c --use-compress-program/" /usr/lib/pbuilder/pbuilder-modules | ||
RUN --security=insecure fakeroot pbuilder create |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
ARGS="$@" | ||
echo "faketar ${ARGS[@]}" | ||
|
||
if [[ " ${ARGS[*]} " =~ [[:space:]]-x[[:space:]] ]]; then # compress | ||
# Replacing this command: | ||
# tar -x -p -f "$BASETGZ" | ||
src="$4" | ||
echo "Copying $src/* to $(pwd)" | ||
cp -pur $src/* ./ | ||
elif [[ " ${ARGS[*]} " =~ [[:space:]]-c[[:space:]] ]]; then # extract | ||
# Replacing this command: | ||
# tar -c --use-compress-program "$COMPRESSPROG" -f "${BASETGZ}.tmp" ./* | ||
target="$5" | ||
src="." | ||
mkdir $target | ||
echo "Moving $src/* to $target/" | ||
mv $src/* $target/ | ||
# Remove existing directory into which we move the contents. | ||
# Otherwise, pbuilder (when it calls `mv`) will move $target inside it, | ||
# instead of copying $target/* into it. | ||
if [[ -d "${target%".tmp"}" ]]; then | ||
rm -rf "${target%".tmp"}" | ||
fi | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Run this script with: | ||
# fakeroot pbuilder execute --save-after-exec path/to/pbuilder_install_script.sh | ||
|
||
|
||
# This helps us avoid almost all instances of a very annoying: | ||
# | ||
# ERROR: ld.so: object 'libfakeroot-sysv.so' from LD_PRELOAD cannot be preloaded... | ||
# | ||
# which isn't critical, but is polluting the output and makes debugging or | ||
# simply reading the output more difficult. | ||
export LD_PRELOAD="$(find / -name libfakeroot-sysv.so 2>/dev/null)" | ||
|
||
# These packages are universally required by pbuilder, so we pre-install them | ||
# inside our chroot. | ||
apt update | ||
DEBIAN_FRONTEND=noninteractive apt -y install \ | ||
build-essential curl lsb-release ca-certificates automake autopoint \ | ||
autotools-dev bsdextrautils debhelper dh-autoreconf dh-strip-nondeterminism \ | ||
dwz file gettext gettext-base groff-base intltool-debian libarchive-zip-perl \ | ||
libdebhelper-perl libelf1t64 libfile-stripnondeterminism-perl libmagic-mgc \ | ||
libmagic1t64 libpipeline1 libtool libuchardet0 man-db po-debconf | ||
|
||
### PostgreSQL installation | ||
# | ||
install -d /usr/share/postgresql-common/pgdg | ||
curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc | ||
|
||
# Create the repository configuration file: | ||
sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' | ||
|
||
# Add archive repos containing all postgres versions deleted from | ||
# apt.postgresql.org. For example, when version 17.4 came out, version 17.3 | ||
# was moved to the archive-apt source. We want all of them, because we don't know | ||
# ahead of time which version is going to be required by the user. | ||
apt_sources_fn="/etc/apt/sources.list.d/pgdg.list" | ||
cat $apt_sources_fn | grep 's|https://apt|https://apt-archive' >> $apt_sources_fn | ||
|
||
# Update the package lists: | ||
apt update | ||
|
||
PG_VERSION=<%= @package.postgres_version %> | ||
PG_MAJOR_VERSION=<%= @package.postgres_version(:major) %> | ||
|
||
# Let's check if the version we're trying to install actually exists. | ||
pkg="$(apt-cache madison postgresql-$PG_MAJOR_VERSION | grep " | $PG_VERSION" | head -n1)" | ||
if [[ "$pkg" == "" ]]; then | ||
# If it doesn't we exit with status 1 and an explanation of an error. This will | ||
# trigger the caller (spec.rb) to also exit with status one and, thus, will | ||
# not build a local image -- because user-requested version of postgresql | ||
# cannot be found in the repository. | ||
>&2 echo "ERROR:" | ||
>&2 echo " Couldn't find postgresql-$PG_MAJOR_VERSION package with version $PG_VERSION." | ||
exit 1 | ||
else | ||
pkg_version="$(echo "$pkg" | cut -d "|" -f 2 | xargs)" | ||
apt -y install postgresql-$PG_MAJOR_VERSION=$pkg_version \ | ||
postgresql-server-dev-$PG_MAJOR_VERSION=$pkg_version \ | ||
postgresql-common | ||
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need vim and ripgrep in this image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually decided that yes, because I ended up installing those two every single time I needed to debug an issue. I think those two tools are generally useful, so my suggestions is to keep them. Their relative size is negligible.