Skip to content

Commit 11150aa

Browse files
committed
Merge pull request #5 from infosiftr/update-script
Add a new script to make it trivial and less error-prone to perform a mass version-bump
2 parents 6abeb85 + 6b7b3bd commit 11150aa

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

Dockerfile.template

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# vim:set ft=dockerfile:
2+
FROM debian:wheezy
3+
4+
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
5+
RUN groupadd -r postgres && useradd -r -g postgres postgres
6+
7+
RUN apt-get update && apt-get install -y curl
8+
9+
RUN curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \
10+
&& chmod +x /usr/local/bin/gosu
11+
12+
ENV PG_MAJOR %%PG_MAJOR%%
13+
ENV PG_VERSION %%PG_VERSION%%
14+
15+
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list \
16+
&& curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \
17+
| apt-key add - ED6D65271AACF0FF15D123036FB2A1C265FFB764
18+
19+
RUN apt-get update \
20+
&& apt-get install -y postgresql-common \
21+
&& sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \
22+
&& apt-get install -y \
23+
postgresql-$PG_MAJOR=$PG_VERSION \
24+
postgresql-contrib-$PG_MAJOR=$PG_VERSION
25+
26+
ENV PATH /usr/lib/postgresql/$PG_MAJOR/bin:$PATH
27+
ENV PGDATA /var/lib/postgresql/data
28+
VOLUME /var/lib/postgresql/data
29+
30+
ADD ./docker-entrypoint.sh /
31+
32+
ENTRYPOINT ["/docker-entrypoint.sh"]
33+
34+
EXPOSE 5432
35+
CMD ["postgres"]

update.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -e
3+
4+
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
5+
6+
versions=( "$@" )
7+
if [ ${#versions[@]} -eq 0 ]; then
8+
versions=( */ )
9+
fi
10+
versions=( "${versions[@]%/}" )
11+
12+
packagesUrl='http://apt.postgresql.org/pub/repos/apt/dists/wheezy-pgdg/main/binary-amd64/Packages'
13+
packages="$(echo "$packagesUrl" | sed -r 's/[^a-zA-Z.-]+/-/g')"
14+
curl -sSL "${packagesUrl}.bz2" | bunzip2 > "$packages"
15+
16+
for version in "${versions[@]}"; do
17+
fullVersion="$(grep -m1 -A10 "^Package: postgresql-$version\$" "$packages" | grep -m1 '^Version: ' | cut -d' ' -f2)"
18+
(
19+
set -x
20+
cp Dockerfile.template "$version/Dockerfile"
21+
sed -i 's/%%PG_MAJOR%%/'$version'/g; s/%%PG_VERSION%%/'$fullVersion'/g' "$version/Dockerfile"
22+
)
23+
done
24+
25+
rm "$packages"

0 commit comments

Comments
 (0)