kopia lustrzana https://github.com/OpenDroneMap/WebODM
				
				
				
			Slimmer docker builds
							rodzic
							
								
									18f0ada16e
								
							
						
					
					
						commit
						4f48222527
					
				
							
								
								
									
										56
									
								
								Dockerfile
								
								
								
								
							
							
						
						
									
										56
									
								
								Dockerfile
								
								
								
								
							| 
						 | 
				
			
			@ -6,43 +6,29 @@ ENV PYTHONPATH $PYTHONPATH:/webodm
 | 
			
		|||
ENV PROJ_LIB=/usr/share/proj
 | 
			
		||||
 | 
			
		||||
# Prepare directory
 | 
			
		||||
RUN mkdir /webodm
 | 
			
		||||
ADD . /webodm/
 | 
			
		||||
WORKDIR /webodm
 | 
			
		||||
 | 
			
		||||
# Install Node.js
 | 
			
		||||
RUN apt-get -qq update && apt-get -qq install -y --no-install-recommends wget curl
 | 
			
		||||
RUN wget --no-check-certificate https://deb.nodesource.com/setup_12.x -O /tmp/node.sh && bash /tmp/node.sh
 | 
			
		||||
RUN apt-get -qq update && apt-get -qq install -y nodejs
 | 
			
		||||
 | 
			
		||||
# Install Python3, GDAL, nginx, letsencrypt, psql
 | 
			
		||||
RUN apt-get -qq update && apt-get -qq install -y --no-install-recommends python3 python3-pip python3-setuptools python3-wheel git g++ python3-dev python2.7-dev libpq-dev binutils libproj-dev gdal-bin libgdal-dev python3-gdal nginx certbot grass-core gettext-base cron postgresql-client-13 gettext tzdata
 | 
			
		||||
RUN update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 && update-alternatives --install /usr/bin/python python /usr/bin/python3.9 2
 | 
			
		||||
 | 
			
		||||
# Install pip reqs
 | 
			
		||||
ADD requirements.txt /webodm/
 | 
			
		||||
RUN pip install -U pip && pip install -r requirements.txt "boto3==1.14.14"
 | 
			
		||||
 | 
			
		||||
ADD . /webodm/
 | 
			
		||||
 | 
			
		||||
# Setup cron
 | 
			
		||||
RUN ln -s /webodm/nginx/crontab /var/spool/cron/crontabs/root && chmod 0644 /webodm/nginx/crontab && service cron start && chmod +x /webodm/nginx/letsencrypt-autogen.sh
 | 
			
		||||
 | 
			
		||||
#RUN git submodule update --init
 | 
			
		||||
 | 
			
		||||
WORKDIR /webodm/nodeodm/external/NodeODM
 | 
			
		||||
RUN npm install --quiet
 | 
			
		||||
 | 
			
		||||
WORKDIR /webodm
 | 
			
		||||
RUN npm install --quiet -g webpack@4.16.5 && npm install --quiet -g webpack-cli@4.2.0 && npm install --quiet && webpack --mode production
 | 
			
		||||
RUN echo "UTC" > /etc/timezone
 | 
			
		||||
RUN python manage.py collectstatic --noinput
 | 
			
		||||
RUN python manage.py rebuildplugins
 | 
			
		||||
RUN python manage.py translate build --safe
 | 
			
		||||
 | 
			
		||||
# Cleanup
 | 
			
		||||
RUN apt-get remove -y g++ python3-dev libpq-dev && apt-get autoremove -y
 | 
			
		||||
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 
 | 
			
		||||
 | 
			
		||||
RUN rm /webodm/webodm/secret_key.py
 | 
			
		||||
RUN apt-get -qq update && apt-get -qq install -y --no-install-recommends wget curl && \
 | 
			
		||||
    wget --no-check-certificate https://deb.nodesource.com/setup_12.x -O /tmp/node.sh && bash /tmp/node.sh && \
 | 
			
		||||
    apt-get -qq update && apt-get -qq install -y nodejs && \
 | 
			
		||||
    # Install Python3, GDAL, nginx, letsencrypt, psql
 | 
			
		||||
    apt-get -qq update && apt-get -qq install -y --no-install-recommends python3 python3-pip python3-setuptools python3-wheel git g++ python3-dev python2.7-dev libpq-dev binutils libproj-dev gdal-bin libgdal-dev python3-gdal nginx certbot grass-core gettext-base cron postgresql-client-13 gettext tzdata && \
 | 
			
		||||
    update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 && update-alternatives --install /usr/bin/python python /usr/bin/python3.9 2 && \
 | 
			
		||||
    # Install pip reqs
 | 
			
		||||
    pip install -U pip && pip install -r requirements.txt "boto3==1.14.14" && \
 | 
			
		||||
    # Setup cron
 | 
			
		||||
    ln -s /webodm/nginx/crontab /var/spool/cron/crontabs/root && chmod 0644 /webodm/nginx/crontab && service cron start && chmod +x /webodm/nginx/letsencrypt-autogen.sh && \
 | 
			
		||||
    cd /webodm/nodeodm/external/NodeODM && npm install --quiet && cd /webodm && \
 | 
			
		||||
    npm install --quiet -g webpack@4.16.5 && npm install --quiet -g webpack-cli@4.2.0 && npm install --quiet && webpack --mode production && \
 | 
			
		||||
    echo "UTC" > /etc/timezone && \
 | 
			
		||||
    python manage.py collectstatic --noinput && \
 | 
			
		||||
    python manage.py rebuildplugins && \
 | 
			
		||||
    python manage.py translate build --safe && \
 | 
			
		||||
    # Cleanup
 | 
			
		||||
    apt-get remove -y g++ python3-dev libpq-dev && apt-get autoremove -y && \
 | 
			
		||||
    apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
 | 
			
		||||
    rm /webodm/webodm/secret_key.py
 | 
			
		||||
 | 
			
		||||
VOLUME /webodm/app/media
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,19 +3,31 @@ MAINTAINER Piero Toffanin <pt@masseranolabs.com>
 | 
			
		|||
 | 
			
		||||
ENV POSTGRES_PASSWORD postgres
 | 
			
		||||
ENV POSTGRES_HOST_AUTH_METHOD trust
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
# Setup system
 | 
			
		||||
RUN apt-get update
 | 
			
		||||
RUN set -eux; \
 | 
			
		||||
RUN apt-get update; \
 | 
			
		||||
    set -eux; \
 | 
			
		||||
	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; \
 | 
			
		||||
	chown -R postgres:postgres /var/lib/postgresql
 | 
			
		||||
 | 
			
		||||
# grab gosu for easy step-down from root
 | 
			
		||||
# https://github.com/tianon/gosu/releases
 | 
			
		||||
ENV GOSU_VERSION 1.12
 | 
			
		||||
RUN set -eux; \
 | 
			
		||||
	chown -R postgres:postgres /var/lib/postgresql; \
 | 
			
		||||
    # grab gosu for easy step-down from root
 | 
			
		||||
    # https://github.com/tianon/gosu/releases
 | 
			
		||||
	apt-get update; \
 | 
			
		||||
	apt-get install -y --no-install-recommends wget; \
 | 
			
		||||
	rm -rf /var/lib/apt/lists/*; \
 | 
			
		||||
| 
						 | 
				
			
			@ -23,82 +35,49 @@ RUN set -eux; \
 | 
			
		|||
	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; \
 | 
			
		||||
	gosu nobody true
 | 
			
		||||
 | 
			
		||||
# make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
 | 
			
		||||
RUN set -eux; \
 | 
			
		||||
	gosu nobody true; \
 | 
			
		||||
    # make the "en_US.UTF-8" locale so postgres will be utf-8 enabled by default
 | 
			
		||||
	apt-get update; \
 | 
			
		||||
	apt-get install -y --no-install-recommends locales; \
 | 
			
		||||
	localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
 | 
			
		||||
ENV LANG en_US.utf8
 | 
			
		||||
 | 
			
		||||
RUN mkdir /docker-entrypoint-initdb.d
 | 
			
		||||
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
# Build Postgres from source
 | 
			
		||||
RUN set -ex; \
 | 
			
		||||
	localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8; \
 | 
			
		||||
    # Build Postgres from source
 | 
			
		||||
	mkdir /staging; \
 | 
			
		||||
	apt-get update; \
 | 
			
		||||
	apt-get install -y --no-install-recommends wget gcc build-essential libproj-dev libgeos-dev libxml2-dev zlib1g-dev libreadline-dev; \ 
 | 
			
		||||
	cd /staging; \
 | 
			
		||||
	wget --no-check-certificate -q https://github.com/OpenDroneMap/WebODM/releases/download/v1.9.2/postgresql-$PG_VERSION.tar.gz
 | 
			
		||||
 | 
			
		||||
RUN set -ex; \
 | 
			
		||||
	wget --no-check-certificate -q https://github.com/OpenDroneMap/WebODM/releases/download/v1.9.2/postgresql-$PG_VERSION.tar.gz; \
 | 
			
		||||
	cd /staging; \
 | 
			
		||||
	tar -zxf postgresql-$PG_VERSION.tar.gz; \
 | 
			
		||||
	cd postgresql-$PG_VERSION; \
 | 
			
		||||
	./configure; \
 | 
			
		||||
	make -j$(nproc); \
 | 
			
		||||
	make install; \
 | 
			
		||||
	postgres --version
 | 
			
		||||
 | 
			
		||||
RUN set -eux; \
 | 
			
		||||
	postgres --version; \
 | 
			
		||||
	sed -ri "s!^#?(listen_addresses)\s*=\s*\S+.*!\1 = '*'!" /usr/local/pgsql/share/postgresql.conf.sample; \
 | 
			
		||||
	grep -F "listen_addresses = '*'" /usr/local/pgsql/share/postgresql.conf.sample
 | 
			
		||||
 | 
			
		||||
RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod 2777 /var/run/postgresql
 | 
			
		||||
 | 
			
		||||
ENV PGDATA /var/lib/postgresql/data
 | 
			
		||||
# this 777 will be replaced by 700 at runtime (allows semi-arbitrary "--user" values)
 | 
			
		||||
RUN mkdir -p "$PGDATA" && chown -R postgres:postgres "$PGDATA" && chmod 777 "$PGDATA"
 | 
			
		||||
VOLUME /var/lib/postgresql/data
 | 
			
		||||
 | 
			
		||||
# Build PostGIS from source
 | 
			
		||||
RUN set -ex; \
 | 
			
		||||
	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
 | 
			
		||||
	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; \
 | 
			
		||||
	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; \
 | 
			
		||||
	sed -i 's/#error.*/#define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H 1/' /usr/include/proj_api.h
 | 
			
		||||
 | 
			
		||||
RUN set -ex; \
 | 
			
		||||
	sed -i 's/#error.*/#define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H 1/' /usr/include/proj_api.h; \
 | 
			
		||||
	cd /staging/postgis-$POSTGIS_VERSION; \
 | 
			
		||||
	./configure --with-pgconfig=/usr/local/pgsql/bin/pg_config; \
 | 
			
		||||
	make; \
 | 
			
		||||
	make install; \
 | 
			
		||||
	sed -i '1d' /usr/local/pgsql/share/extension/postgis--$POSTGIS_VERSION.sql
 | 
			
		||||
 | 
			
		||||
RUN set -ex; \
 | 
			
		||||
	sed -i '1d' /usr/local/pgsql/share/extension/postgis--$POSTGIS_VERSION.sql; \
 | 
			
		||||
	apt-get remove -y gcc build-essential wget; \
 | 
			
		||||
	apt-get autoremove -y; \
 | 
			
		||||
	apt-get clean; \
 | 
			
		||||
	rm -fr /var/lib/apt/lists/* /staging /usr/include;
 | 
			
		||||
 | 
			
		||||
COPY docker-entrypoint.sh /usr/local/bin/
 | 
			
		||||
RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat
 | 
			
		||||
VOLUME /var/lib/postgresql/data
 | 
			
		||||
ENTRYPOINT ["docker-entrypoint.sh"]
 | 
			
		||||
 | 
			
		||||
STOPSIGNAL SIGINT
 | 
			
		||||
 | 
			
		||||
COPY init.sql /docker-entrypoint-initdb.d/init-db.sql
 | 
			
		||||
RUN chmod 644 /docker-entrypoint-initdb.d/init-db.sql
 | 
			
		||||
 | 
			
		||||
EXPOSE 5432
 | 
			
		||||
CMD ["postgres"]
 | 
			
		||||
		Ładowanie…
	
		Reference in New Issue