From d74b69598c835fe15eac39a26b5c61058f99c3db Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Fri, 15 Aug 2014 17:59:41 -0600 Subject: [PATCH] Add proper UTF-8 locale (thus enabling UTF-8 defaults) and update a few minor idioms that take the image from ~244.1 MB down to ~213.6 MB --- 8.4/Dockerfile | 21 ++++++++++++++------- 9.0/Dockerfile | 21 ++++++++++++++------- 9.1/Dockerfile | 21 ++++++++++++++------- 9.2/Dockerfile | 21 ++++++++++++++------- 9.3/Dockerfile | 21 ++++++++++++++------- 9.4/Dockerfile | 21 ++++++++++++++------- Dockerfile.template | 21 ++++++++++++++------- 7 files changed, 98 insertions(+), 49 deletions(-) diff --git a/8.4/Dockerfile b/8.4/Dockerfile index 2d419c2442..208562c72f 100644 --- a/8.4/Dockerfile +++ b/8.4/Dockerfile @@ -4,24 +4,31 @@ FROM debian:wheezy # add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added RUN groupadd -r postgres && useradd -r -g postgres postgres -RUN apt-get update && apt-get install -y curl +# grab gosu for easy step-down from root +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \ + && curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove curl -RUN curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ - && chmod +x /usr/local/bin/gosu +# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default +RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG en_US.utf8 + +RUN apt-key adv --keyserver pgp.mit.edu --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 ENV PG_MAJOR 8.4 ENV PG_VERSION 8.4.22-1.pgdg70+1 -RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list \ - && curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \ - | apt-key add - ED6D65271AACF0FF15D123036FB2A1C265FFB764 +RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list RUN apt-get update \ && apt-get install -y postgresql-common \ && sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \ && apt-get install -y \ postgresql-$PG_MAJOR=$PG_VERSION \ - postgresql-contrib-$PG_MAJOR=$PG_VERSION + postgresql-contrib-$PG_MAJOR=$PG_VERSION \ + && rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql diff --git a/9.0/Dockerfile b/9.0/Dockerfile index b4efa30107..9658c1145f 100644 --- a/9.0/Dockerfile +++ b/9.0/Dockerfile @@ -4,24 +4,31 @@ FROM debian:wheezy # add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added RUN groupadd -r postgres && useradd -r -g postgres postgres -RUN apt-get update && apt-get install -y curl +# grab gosu for easy step-down from root +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \ + && curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove curl -RUN curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ - && chmod +x /usr/local/bin/gosu +# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default +RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG en_US.utf8 + +RUN apt-key adv --keyserver pgp.mit.edu --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 ENV PG_MAJOR 9.0 ENV PG_VERSION 9.0.18-1.pgdg70+1 -RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list \ - && curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \ - | apt-key add - ED6D65271AACF0FF15D123036FB2A1C265FFB764 +RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list RUN apt-get update \ && apt-get install -y postgresql-common \ && sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \ && apt-get install -y \ postgresql-$PG_MAJOR=$PG_VERSION \ - postgresql-contrib-$PG_MAJOR=$PG_VERSION + postgresql-contrib-$PG_MAJOR=$PG_VERSION \ + && rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql diff --git a/9.1/Dockerfile b/9.1/Dockerfile index d58f8be5f8..de4dba7736 100644 --- a/9.1/Dockerfile +++ b/9.1/Dockerfile @@ -4,24 +4,31 @@ FROM debian:wheezy # add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added RUN groupadd -r postgres && useradd -r -g postgres postgres -RUN apt-get update && apt-get install -y curl +# grab gosu for easy step-down from root +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \ + && curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove curl -RUN curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ - && chmod +x /usr/local/bin/gosu +# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default +RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG en_US.utf8 + +RUN apt-key adv --keyserver pgp.mit.edu --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 ENV PG_MAJOR 9.1 ENV PG_VERSION 9.1.14-1.pgdg70+1 -RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list \ - && curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \ - | apt-key add - ED6D65271AACF0FF15D123036FB2A1C265FFB764 +RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list RUN apt-get update \ && apt-get install -y postgresql-common \ && sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \ && apt-get install -y \ postgresql-$PG_MAJOR=$PG_VERSION \ - postgresql-contrib-$PG_MAJOR=$PG_VERSION + postgresql-contrib-$PG_MAJOR=$PG_VERSION \ + && rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql diff --git a/9.2/Dockerfile b/9.2/Dockerfile index 6a91f83788..abbe75602d 100644 --- a/9.2/Dockerfile +++ b/9.2/Dockerfile @@ -4,24 +4,31 @@ FROM debian:wheezy # add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added RUN groupadd -r postgres && useradd -r -g postgres postgres -RUN apt-get update && apt-get install -y curl +# grab gosu for easy step-down from root +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \ + && curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove curl -RUN curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ - && chmod +x /usr/local/bin/gosu +# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default +RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG en_US.utf8 + +RUN apt-key adv --keyserver pgp.mit.edu --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 ENV PG_MAJOR 9.2 ENV PG_VERSION 9.2.9-1.pgdg70+1 -RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list \ - && curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \ - | apt-key add - ED6D65271AACF0FF15D123036FB2A1C265FFB764 +RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list RUN apt-get update \ && apt-get install -y postgresql-common \ && sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \ && apt-get install -y \ postgresql-$PG_MAJOR=$PG_VERSION \ - postgresql-contrib-$PG_MAJOR=$PG_VERSION + postgresql-contrib-$PG_MAJOR=$PG_VERSION \ + && rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql diff --git a/9.3/Dockerfile b/9.3/Dockerfile index 4f52e969e4..a9ff116e03 100644 --- a/9.3/Dockerfile +++ b/9.3/Dockerfile @@ -4,24 +4,31 @@ FROM debian:wheezy # add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added RUN groupadd -r postgres && useradd -r -g postgres postgres -RUN apt-get update && apt-get install -y curl +# grab gosu for easy step-down from root +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \ + && curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove curl -RUN curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ - && chmod +x /usr/local/bin/gosu +# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default +RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG en_US.utf8 + +RUN apt-key adv --keyserver pgp.mit.edu --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 ENV PG_MAJOR 9.3 ENV PG_VERSION 9.3.5-1.pgdg70+1 -RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list \ - && curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \ - | apt-key add - ED6D65271AACF0FF15D123036FB2A1C265FFB764 +RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list RUN apt-get update \ && apt-get install -y postgresql-common \ && sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \ && apt-get install -y \ postgresql-$PG_MAJOR=$PG_VERSION \ - postgresql-contrib-$PG_MAJOR=$PG_VERSION + postgresql-contrib-$PG_MAJOR=$PG_VERSION \ + && rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql diff --git a/9.4/Dockerfile b/9.4/Dockerfile index 152229e671..a82357a142 100644 --- a/9.4/Dockerfile +++ b/9.4/Dockerfile @@ -4,24 +4,31 @@ FROM debian:wheezy # add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added RUN groupadd -r postgres && useradd -r -g postgres postgres -RUN apt-get update && apt-get install -y curl +# grab gosu for easy step-down from root +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \ + && curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove curl -RUN curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ - && chmod +x /usr/local/bin/gosu +# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default +RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG en_US.utf8 + +RUN apt-key adv --keyserver pgp.mit.edu --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 ENV PG_MAJOR 9.4 ENV PG_VERSION 9.4~beta2-1.pgdg70+1 -RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list \ - && curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \ - | apt-key add - ED6D65271AACF0FF15D123036FB2A1C265FFB764 +RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list RUN apt-get update \ && apt-get install -y postgresql-common \ && sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \ && apt-get install -y \ postgresql-$PG_MAJOR=$PG_VERSION \ - postgresql-contrib-$PG_MAJOR=$PG_VERSION + postgresql-contrib-$PG_MAJOR=$PG_VERSION \ + && rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql diff --git a/Dockerfile.template b/Dockerfile.template index 3da1d6e1af..0cd09ee548 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -4,24 +4,31 @@ FROM debian:wheezy # add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added RUN groupadd -r postgres && useradd -r -g postgres postgres -RUN apt-get update && apt-get install -y curl +# grab gosu for easy step-down from root +RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \ + && curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove curl -RUN curl -o /usr/local/bin/gosu -SL 'https://github.com/tianon/gosu/releases/download/1.1/gosu' \ - && chmod +x /usr/local/bin/gosu +# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default +RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 +ENV LANG en_US.utf8 + +RUN apt-key adv --keyserver pgp.mit.edu --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 ENV PG_MAJOR %%PG_MAJOR%% ENV PG_VERSION %%PG_VERSION%% -RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list \ - && curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \ - | apt-key add - ED6D65271AACF0FF15D123036FB2A1C265FFB764 +RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list RUN apt-get update \ && apt-get install -y postgresql-common \ && sed -ri 's/#(create_main_cluster) .*$/\1 = false/' /etc/postgresql-common/createcluster.conf \ && apt-get install -y \ postgresql-$PG_MAJOR=$PG_VERSION \ - postgresql-contrib-$PG_MAJOR=$PG_VERSION + postgresql-contrib-$PG_MAJOR=$PG_VERSION \ + && rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql