postgresql client - installation on php:5-apache - postgresql

I work on some old project (Laravel 4.2, php5.6, postgresql) and I wanna to set it up on docker - here is my dockerfile:
FROM php:5-apache
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
RUN apt-get update
RUN apt-get install -y \
git \
nano \
libpng-dev \
libmcrypt-dev \
postgresql-dev \
zlib1g-dev \
zip \
unzip &&\
a2enmod rewrite
RUN docker-php-ext-install pdo &&\
docker-php-ext-install pdo_mysql &&\
docker-php-ext-install pdo_pgsql &&\
docker-php-ext-install zip &&\
docker-php-ext-install gd &&\
docker-php-ext-install pcntl &&\
docker-php-ext-install mcrypt
# COPY php.ini /usr/local/etc/php/php.ini
I get following error:
E: Unable to locate package postgresql-dev
When I change postgresql-dev to postgresql (and change image to FROM php:5-apache-jessie with different combinations: RUN dpkg --configure -a && RUN apt-get -f install && apt-get update && apt-get upgrade -y && apt-get --purge remove postgresql\* I get errors like:
E: Sub-process /usr/bin/dpkg returned an error code (1)
E: Unable to locate package postgresql*
E: Couldn't find any package by glob 'postgresql*'
E: Couldn't find any package by regex 'postgresql*'
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
Question: How to install postgres php client drivers properly?

In dockerfile change postgresql-dev \ to
libpq-dev \

Related

The repository 'http://apt.postgresql.org/pub/repos/apt stretch-pgdg Release' does not have a Release file?

I have an error when I am building my Docker containers. It seems that there are problems with Postgres Stretch for Debian. I saw that Debian strech was removed and no longer supported.
I found similar problem here: The repository 'http://apt.postgresql.org/pub/repos/apt stretch-pgdg Release' does not have a Release file but i didn't managed to solve my problem.
Here is an error:
W: The repository 'http://apt.postgresql.org/pub/repos/apt stretch-pgdg Release' does not have a Release file.
E: Failed to fetch http://apt.postgresql.org/pub/repos/apt/dists/stretch-pgdg/11/binary-amd64/Packages 404 Not Found [IP: 147.75.85.69 80]
E: Some index files failed to download. They have been ignored, or old ones used instead.
ERROR: Service 'db' failed to build: The command '/bin/sh -c apt-get update && apt-get install dos2unix && apt-get clean' returned a non-zero code: 100
And here's part of my Dockerfile that I'm trying to run:
FROM debian:jessie
MAINTAINER Open Knowledge
# Install required system packages
RUN apt-get -q -y update \
&& DEBIAN_FRONTEND=noninteractive apt-get -q -y upgrade \
&& apt-get -q -y install \
curl \
python-dev \
python-pip \
python-virtualenv \
python-wheel \
libpq-dev \
libxml2-dev \
libxslt-dev \
libgeos-dev \
libssl-dev \
libxslt-dev \
libgeos-dev \
libssl-dev \
libffi-dev \
postgresql-client \
build-essential \
git-core \
vim \
wget \
&& apt-get -q clean \
&& apt-get install -y dos2unix
Do you maybe know what I should add or remove in my Dockerfile file to solve this problem?
Thanks in advance
Debian stretch is no longer supported
You could use this deb package instead:
deb https://apt-archive.postgresql.org/pub/repos/apt stretch-pgdg main

AWS Lambda - Swift Operation not permitted

I am trying to compile Swift code via AWS Lambda.
Therefore I am using an Ubuntu 18.04 Image as base.
The Swift Version is 5.0.1.
When the image is executed locally, it works fine.
When I try to execute it in AWS Lambda, I get the following error:
/usr/bin/ld.gold: fatal error: /tmp/project/src/a.out: Operation not
permitted\nclang-7: error: linker command failed with exit code 1 (use
-v to see invocation)
I think that the problem is caused by the read-only aws lambda container, that only allows to write into the /tmp/ folder.
Do you know how to fix this error? It seems that swift needs permissions for folders, it doesnt have permission for?
Dockerfile
FROM ubuntu:18.04
# install clang
RUN apt-get update
RUN apt-get install -y clang
# install wget
RUN apt-get install -y wget
# install swift dependencies
RUN apt-get install -y libcurl3 libpython2.7 libpython2.7-dev
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y --no-install-recommends \
binutils \
git \
libc6-dev \
libcurl4 \
libedit2 \
libgcc-5-dev \
libpython2.7 \
libsqlite3-0 \
libstdc++-5-dev \
libxml2 \
pkg-config \
tzdata \
zlib1g-dev \
libbsd-dev
RUN apt-get install -y libicu-dev
# install swift 5.0.1
RUN wget https://swift.org/builds/swift-5.0.1-release/ubuntu1804/swift-5.0.1-RELEASE/swift-5.0.1-RELEASE-ubuntu18.04.tar.gz RUN tar xzf swift-5.0.1-RELEASE-ubuntu18.04.tar.gz RUN mv swift-5.0.1-RELEASE-ubuntu18.04 /usr/lib/swift RUN echo "export PATH=/usr/lib/swift/usr/bin:$PATH" >> ~/.bashrc
RUN . ~/.bashrc
RUN chmod -R o+r /usr/lib/swift
This is the command executed in the AWS-Lambda handler function:
swiftc hello_world.swift -o a.out
hello_world.swift
print("Hello World!")
Your output must be set in tmp folder
swiftc hello_world.swift -o /tmp/a.out

There is no cubedata.h and contrib directory in Postgresql

I has 128-dimensional vectors of float (face recognition issue). To store these vectors I use datatype cube in Postgresql.
This type has limit by default - 100 dim.
In the psql (PostgreSQL) 10.5 (Ubuntu 10.6-0ubuntu0.18.04.1) this limit don't work: I can store my vector without any problems.
But yeasterday one of my machine was updated to PostgreSQL 10.6 and now I receive an error when try to add new cube-vector into my database. Error about too long vector.
To resolve this problem I have to change this limit in the file cubedata.h which is in contrib directory. But I have no this file and such directory at all!
I try install
sudo apt-get install postgresql-contrib
but, I get the message about the newest postgresql-contrib version is already installed.
After I tried to manually download cubedata.h file into the directory of Postgresql (/usr/share/postgresql/10/extension/), but it doesn't help.
My be someone encountered with such problem?
In Ubuntu 18.04.1 cubedata.h included in the postgres-server-dev-10 package from the PostgreSQL official repository. But prebuilt cube.so included in the postgresql-10 package with default limit.
To increase the limit you should recompile cube.so from source. Below the example of code for the Ubuntu.
Add repository:
PG_VER=10.6
source /etc/os-release
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
echo "deb http://apt.postgresql.org/pub/repos/apt/ ${VERSION_CODENAME}-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt-get update
sudo apt-get install -y postgresql-${PG_VER%.*}
Compile cube extension from source:
PG_VER=10.6
sudo apt-get install -y unzip gcc make zlib1g-dev libreadline-dev postgresql-server-dev-${PG_VER%.*} bison flex
wget https://ftp.postgresql.org/pub/source/v${PG_VER}/postgresql-${PG_VER}.tar.bz2 --quiet -O postgresql.tar.bz2
tar xvf postgresql.tar.bz2
cd postgresql-${PG_VER}
./configure
cd contrib/cube
sed -i 's/#define CUBE_MAX_DIM (100)/#define CUBE_MAX_DIM (128)/' cubedata.h
make USE_PGXS=1
sudo make USE_PGXS=1 install
Check result after restart server:
sudo -u postgres psql dbname -c 'CREATE EXTENSION cube'
sudo -u postgres psql dbname -c 'SELECT cube_dim(cube(array(select generate_series(1, 128)))) as dim'

Docker- docker file to create postgresql Image from postgresql-9.6.1.tar.gz tarball?

How to build postgresql-9.6 image from postgresql-9.6.1.tar.gz using dockerfile?
I tried to create below dockerfile to install postgresql-9.6 on ubuntu. But I am unable to make it a complete image?
FROM ubuntu:16.04
RUN apt-get update && \
apt-get install software-properties-common -y && \
apt-get install wget && \
add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main" && \
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
apt-get update && \
apt-get install -y postgresql-9.6 postgresql-client-9.6
EXPOSE 5432
So as an alternative I want to create image from tarball
The official Postgres Dockerfile does a build from source on Debian which should be largely portable to Ubuntu.
It will be easier to just use the postgres:9.6 or postgres:9.6.1 image as a seperate container to your application, rather than trying to manage a build heavy, monolithic container yourself.

Installation of debian file failing in Grafana

I've got a custom built grafana docker image that I build using
go run build.go build package
This all works fine, and I get a deb image from the process (grafana_4.3.0-1490275845pre1_amd64.deb) as well as a .tar.gz file and an rpm package as well.
When using the dockerfile (essentially copied from grafana/grafana-docker):
FROM debian:jessie
COPY ./grafana.deb /tmp/grafana.deb
RUN apt-get update && \
apt-get -y --no-install-recommends install libfontconfig curl ca-certificates && \
apt-get clean && \
dpkg -i --debug=3773 /tmp/grafana.deb && \
rm /tmp/grafana.deb && \
I get the following error:
dpkg (subprocess): unable to execute installed post-installation script (/var/lib/dpkg/info/grafana.postinst): No such file or directory
dpkg: error processing package grafana (--install):
subprocess installed post-installation script returned error exit status 2
D000001: ensure_diversions: same, skipping
D000002: fork/exec /var/lib/dpkg/info/systemd.postinst ( triggered /etc/init.d )
D000001: ensure_diversions: same, skipping
Errors were encountered while processing:
grafana
Setting up grafana (4.3.0-1490275845pre1) ...
Processing triggers for systemd (215-17+deb8u6) ...
The command '/bin/sh -c apt-get update && apt-get -y --no-install-recommends install libfontconfig curl ca-certificates && apt-get clean && dpkg -i -- debug=3773 --force-all /tmp/grafana.deb && rm /tmp/grafana.deb && curl -L https://github.com/tianon/gosu/releases/download/1.7/gosu-amd64 > /usr/sbin/gosu && chmod +x /usr/sbin/gosu && apt-get remove -y curl && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 1
The obvious issue is (/var/lib/dpkg/info/grafana.postinst): No such file or directory but not knowing anything about dpkg I don't really know where to start trying to debug it. As far as I'm aware, I've not altered the deployment scripts so I'm at a loss to know where the issue has arisen.
As I was developing Grafana on a shared Windows folder, with Grafana running in a Docker container on VirtualBox, it seems that (despite not editing the files) SourceTree or something else edited the source to add Windows new lines which messed up the packaging step. I just used dos2unix to remove newlines and everything started working as expected.
The particular error message was related to newlines in the postinst file, which I debugged manually with bash on the VM.