-
Notifications
You must be signed in to change notification settings - Fork 12
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
Added docker multistage build #25
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
FROM ubuntu:18.04 | ||
|
||
LABEL MAINTAINER [email protected] | ||
|
||
ARG PG_VERSION=11 | ||
ARG PG_UNIT_VERSION=7.1 | ||
ARG PG_CONFIG=/usr/lib/postgresql/$PG_VERSION/bin/pg_config | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
build-essential \ | ||
lsb-release \ | ||
flex \ | ||
bison \ | ||
curl && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list && \ | ||
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y \ | ||
postgresql-server-dev-$PG_VERSION && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /opt/postgresql-unit | ||
|
||
RUN curl -fsSL https://github.com/df7cb/postgresql-unit/archive/$PG_UNIT_VERSION.tar.gz | \ | ||
tar --strip-components 1 -xzC /opt/postgresql-unit/ | ||
|
||
RUN make | ||
RUN make install | ||
|
||
FROM postgres:11 | ||
|
||
COPY --from=0 /opt/postgresql-unit/unit.so /usr/lib/postgresql/$PG_MAJOR/lib/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does it run There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
COPY --from=0 /opt/postgresql-unit/unit_prefixes.data \ | ||
/opt/postgresql-unit/unit_units.data \ | ||
/opt/postgresql-unit/unit.control \ | ||
/opt/postgresql-unit/unit--*.sql \ | ||
/usr/share/postgresql/$PG_MAJOR/extension/ | ||
|
||
COPY ./initdb-unit.sh /docker-entrypoint-initdb.d/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
# Perform all actions as $POSTGRES_USER | ||
export PGUSER="$POSTGRES_USER" | ||
|
||
# Create the 'template_unit' template db | ||
"${psql[@]}" <<- 'EOSQL' | ||
CREATE DATABASE template_unit; | ||
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template_unit'; | ||
EOSQL | ||
|
||
# Load Unit into both template_database and $POSTGRES_DB | ||
for DB in template_unit "$POSTGRES_DB"; do | ||
echo "Loading Unit extensions into $DB" | ||
"${psql[@]}" --dbname="$DB" <<-'EOSQL' | ||
CREATE EXTENSION IF NOT EXISTS unit; | ||
EOSQL | ||
done |
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.
Hi,
why isn't this using the files from the very git repository you want to have this merged into? Pulling a (versioned) tarball from github instead doesn't seem right.
Alternatively, couldn't you just "apt-get install postgresql-$PG_VERSION-unit" instead?
Christoph
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.
D'oh! My mistake...
I didn't check the postgresql repos for your unit extension, just the ubuntu repos :(
Through the docker build, you get the flexibility to test different releases of your extension with different distros and psql versions, but the fact, that the extension is available in the psql apt repo ist making this pull request nearly obsolete...
Nevertheless a Docker Hub Image would be nice and is easily possible with this Dockerfile.