Skip to content

Commit

Permalink
Change postgresql to 8.4.
Browse files Browse the repository at this point in the history
  • Loading branch information
rasovica committed Aug 23, 2017
1 parent cc3698c commit 95fa409
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 53 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "docker/database"]
path = docker/database
url = https://github.com/Banno/docker-postgresql-8.4/
branch = postgres-8.4
12 changes: 5 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ services:
build:
context: docker/database/
dockerfile: Dockerfile
volumes:
- ./scripts:/scripts
- /var/lib/postgresql/9.6/main
entrypoint: scripts/docker-run
environment:
POSTGRESQL_USER: wlansi_cms
POSTGRESQL_PASS: mainpage
POSTGRESQL_DB: wlansi
expose:
- 5432
command: "/usr/lib/postgresql/9.6/bin/postgres -D /var/lib/postgresql/9.6/main -c config_file=/etc/postgresql/9.6/main/postgresql.conf"
user: postgres
- 5432
52 changes: 16 additions & 36 deletions docker/database/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,45 +1,25 @@
FROM ubuntu
FROM ubuntu:14.04

# Add the PostgreSQL PGP key to verify their Debian packages.
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
RUN apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8
RUN apt-get update && apt-get install -y wget

# Add PostgreSQL's repository. It contains the most recent stable release
# of PostgreSQL, ``9.6``.
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list
ADD pgdg.list /etc/apt/sources.list.d/pgdg.list

This comment has been minimized.

Copy link
@rokx

rokx Jan 1, 2019

Why is this file not in repository? Also init-postgresql

RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -

# Install ``python-software-properties``, ``software-properties-common`` and PostgreSQL 9.6
# There are some warnings (in red) that show up during the build. You can hide
# them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y python-software-properties software-properties-common postgresql-9.6 postgresql-client-9.6 postgresql-contrib-9.6 postgresql-9.6-ip4r
RUN apt-get -qq update && LC_ALL=en_US.UTF-8 DEBIAN_FRONTEND=noninteractive apt-get install -y -q postgresql-8.4 libpq-dev

# Note: The official Debian and Ubuntu images automatically ``apt-get clean``
# after each ``apt-get``
# /etc/ssl/private can't be accessed from within container for some reason
# (@andrewgodwin says it's something AUFS related)
RUN mkdir /etc/ssl/private-copy; mv /etc/ssl/private/* /etc/ssl/private-copy/; rm -r /etc/ssl/private; mv /etc/ssl/private-copy /etc/ssl/private; chmod -R 0700 /etc/ssl/private; chown -R postgres /etc/ssl/private

# Run the rest of the commands as the ``postgres`` user created by the ``postgres-9.6`` package when it was ``apt-get installed``
USER postgres
## Add over config files
ADD postgresql.conf /etc/postgresql/8.4/main/postgresql.conf
ADD pg_hba.conf /etc/postgresql/8.4/main/pg_hba.conf
RUN chown postgres:postgres /etc/postgresql/8.4/main/*.conf
ADD init-postgresql /usr/local/bin/init-postgresql
RUN chmod +x /usr/local/bin/init-postgresql

# Create a PostgreSQL role named ``docker`` with ``docker`` as the password and
# then create a database `docker` owned by the ``docker`` role.
# Note: here we use ``&&\`` to run commands one after the other - the ``\``
# allows the RUN command to span multiple lines.
RUN /etc/init.d/postgresql start &&\
psql --command "CREATE USER wlansi_cms WITH SUPERUSER PASSWORD 'mainpage';" &&\
psql -d template1 -c 'create extension ip4r;' &&\
createdb -O wlansi_cms wlansi

# Adjust PostgreSQL configuration so that remote connections to the
# database are possible.
RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.6/main/pg_hba.conf

# And add ``listen_addresses`` to ``/etc/postgresql/9.6/main/postgresql.conf``
RUN echo "listen_addresses='*'" >> /etc/postgresql/9.6/main/postgresql.conf

# Expose the PostgreSQL port
VOLUME ["/var/lib/postgresql"]
EXPOSE 5432

# Add VOLUMEs to allow backup of config, logs and databases
VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"]
CMD ["/usr/local/bin/init-postgresql"]

# Set the default command to run when starting the container
CMD ["/usr/lib/postgresql/9.6/bin/postgres", "-D", "/var/lib/postgresql/9.6/main", "-c", "config_file=/etc/postgresql/9.6/main/postgresql.conf"]
17 changes: 9 additions & 8 deletions mainpage/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@
# DEBUG=False and a view raises an exception, Django will e-mail these
# people with the full exception information. Each member of the tuple
# should be a tuple of (Full name, e-mail address).
ADMINS = (
)
ADMINS = ()

MANAGERS = ADMINS

DB_PASSWORD = os.environ.get('DB_PASSWORD', 'mainpage')

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': database_file, # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'wlansi',
'USER': 'wlansi_cms',
'PASSWORD': DB_PASSWORD,
'HOST': 'db',
'PORT': '',
},
}

Expand Down
2 changes: 0 additions & 2 deletions mainpage/settings_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
'PASSWORD': DB_PASSWORD,
'HOST': 'db',
'PORT': '',
'OPTIONS': {
'options': '-c search_path=public'
},
},
}
Expand Down

0 comments on commit 95fa409

Please sign in to comment.