OpenDroneMap-WebODM/db/Dockerfile

83 wiersze
3.5 KiB
Docker
Czysty Zwykły widok Historia

2021-09-01 17:55:18 +00:00
FROM ubuntu:20.04
2016-09-11 23:52:31 +00:00
MAINTAINER Piero Toffanin <pt@masseranolabs.com>
2020-02-29 20:11:52 +00:00
ENV POSTGRES_PASSWORD postgres
2021-09-01 20:35:54 +00:00
ENV POSTGRES_HOST_AUTH_METHOD trust
2021-09-02 18:47:09 +00:00
ENV GOSU_VERSION 1.12
ENV PG_MAJOR 9.5
ENV PG_VERSION 9.5.25
ENV POSTGIS_VERSION 2.3.2
ENV PATH $PATH:/usr/local/pgsql/bin
ENV DEBIAN_FRONTEND=noninteractive
ENV LANG en_US.utf8
ENV PGDATA /var/lib/postgresql/data
RUN mkdir /docker-entrypoint-initdb.d
COPY init.sql /docker-entrypoint-initdb.d/init-db.sql
RUN chmod 644 /docker-entrypoint-initdb.d/init-db.sql
COPY docker-entrypoint.sh /usr/local/bin/
RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat
2021-09-01 17:55:18 +00:00
# Setup system
2021-09-02 18:47:09 +00:00
RUN apt-get update; \
set -eux; \
2021-09-01 17:55:18 +00:00
groupadd -r postgres --gid=999; \
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
mkdir -p /var/lib/postgresql; \
2021-09-02 18:47:09 +00:00
chown -R postgres:postgres /var/lib/postgresql; \
# grab gosu for easy step-down from root
# https://github.com/tianon/gosu/releases
2021-09-01 17:55:18 +00:00
apt-get update; \
apt-get install -y --no-install-recommends wget; \
rm -rf /var/lib/apt/lists/*; \
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')"; \
wget --no-check-certificate -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
chmod +x /usr/local/bin/gosu; \
gosu --version; \
2021-09-02 18:47:09 +00:00
gosu nobody true; \
# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
2021-09-01 17:55:18 +00:00
apt-get update; \
apt-get install -y --no-install-recommends locales; \
2021-09-02 18:47:09 +00:00
localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8; \
# Build Postgres from source
2021-09-01 17:55:18 +00:00
mkdir /staging; \
apt-get update; \
2021-09-01 20:35:54 +00:00
apt-get install -y --no-install-recommends wget gcc build-essential libproj-dev libgeos-dev libxml2-dev zlib1g-dev libreadline-dev; \
2021-09-01 17:55:18 +00:00
cd /staging; \
2021-09-02 18:47:09 +00:00
wget --no-check-certificate -q https://github.com/OpenDroneMap/WebODM/releases/download/v1.9.2/postgresql-$PG_VERSION.tar.gz; \
2021-09-01 17:55:18 +00:00
cd /staging; \
tar -zxf postgresql-$PG_VERSION.tar.gz; \
cd postgresql-$PG_VERSION; \
2021-09-01 20:35:54 +00:00
./configure; \
2021-09-01 17:55:18 +00:00
make -j$(nproc); \
make install; \
2021-09-02 18:47:09 +00:00
postgres --version; \
2021-09-01 17:55:18 +00:00
sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/local/pgsql/share/postgresql.conf.sample; \
2021-09-02 18:47:09 +00:00
grep -F "listen_addresses = '*'" /usr/local/pgsql/share/postgresql.conf.sample; \
mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod 2777 /var/run/postgresql; \
# this 777 will be replaced by 700 at runtime (allows semi-arbitrary "--user" values)
mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA"; \
# Build PostGIS from source
2021-09-01 17:55:18 +00:00
apt-get update; \
apt-get install -y --no-install-recommends libgdal-dev libjson-c-dev; \
cd /staging; \
wget --no-check-certificate -q https://github.com/OpenDroneMap/WebODM/releases/download/v1.9.2/postgis-$POSTGIS_VERSION.tar.gz; \
2021-09-01 17:55:18 +00:00
wget --no-check-certificate -q -O /usr/include/json-c/json_object_private.h https://raw.githubusercontent.com/json-c/json-c/json-c-0.13/json_object_private.h; \
tar -zxf postgis-$POSTGIS_VERSION.tar.gz; \
2021-09-02 18:47:09 +00:00
sed -i 's/#error.*/#define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H 1/' /usr/include/proj_api.h; \
2021-09-01 17:55:18 +00:00
cd /staging/postgis-$POSTGIS_VERSION; \
./configure --with-pgconfig=/usr/local/pgsql/bin/pg_config; \
make; \
2021-09-01 20:35:54 +00:00
make install; \
2021-09-02 18:47:09 +00:00
sed -i '1d' /usr/local/pgsql/share/extension/postgis--$POSTGIS_VERSION.sql; \
2021-09-01 17:55:18 +00:00
apt-get remove -y gcc build-essential wget; \
2021-09-01 21:01:01 +00:00
apt-get autoremove -y; \
2021-09-01 17:55:18 +00:00
apt-get clean; \
2021-09-01 21:01:01 +00:00
rm -fr /var/lib/apt/lists/* /staging /usr/include;
2021-09-01 17:55:18 +00:00
2021-09-02 18:47:09 +00:00
VOLUME /var/lib/postgresql/data
2021-09-01 17:55:18 +00:00
ENTRYPOINT ["docker-entrypoint.sh"]
STOPSIGNAL SIGINT
EXPOSE 5432
CMD ["postgres"]