xref: /unit/pkg/docker/Dockerfile.jsc11 (revision 1639)
1*1639Sthresh@nginx.comFROM debian:buster-slim
2*1639Sthresh@nginx.com
3*1639Sthresh@nginx.comLABEL maintainer="NGINX Docker Maintainers <docker-maint@nginx.com>"
4*1639Sthresh@nginx.com
5*1639Sthresh@nginx.comENV UNIT_VERSION          1.19.0-1~buster
6*1639Sthresh@nginx.com
7*1639Sthresh@nginx.comRUN set -x \
8*1639Sthresh@nginx.com	&& apt-get update \
9*1639Sthresh@nginx.com	&& apt-get install --no-install-recommends --no-install-suggests -y gnupg1 apt-transport-https ca-certificates \
10*1639Sthresh@nginx.com	&& \
11*1639Sthresh@nginx.com	NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; \
12*1639Sthresh@nginx.com	found=''; \
13*1639Sthresh@nginx.com	for server in \
14*1639Sthresh@nginx.com		ha.pool.sks-keyservers.net \
15*1639Sthresh@nginx.com		hkp://keyserver.ubuntu.com:80 \
16*1639Sthresh@nginx.com		hkp://p80.pool.sks-keyservers.net:80 \
17*1639Sthresh@nginx.com		pgp.mit.edu \
18*1639Sthresh@nginx.com	; do \
19*1639Sthresh@nginx.com		echo "Fetching GPG key $NGINX_GPGKEY from $server"; \
20*1639Sthresh@nginx.com		apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \
21*1639Sthresh@nginx.com	done; \
22*1639Sthresh@nginx.com	test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; \
23*1639Sthresh@nginx.com	apt-get remove --purge --auto-remove -y gnupg1 && rm -rf /var/lib/apt/lists/* \
24*1639Sthresh@nginx.com# work-around debian bug 863199
25*1639Sthresh@nginx.com	&& mkdir -p /usr/share/man/man1 \
26*1639Sthresh@nginx.com	&& dpkgArch="$(dpkg --print-architecture)" \
27*1639Sthresh@nginx.com	&& unitPackages="unit=${UNIT_VERSION} unit-jsc11=${UNIT_VERSION}" \
28*1639Sthresh@nginx.com	&& case "$dpkgArch" in \
29*1639Sthresh@nginx.com		amd64|i386) \
30*1639Sthresh@nginx.com# arches officialy built by upstream
31*1639Sthresh@nginx.com			echo "deb https://packages.nginx.org/unit/debian/ buster unit" >> /etc/apt/sources.list.d/unit.list \
32*1639Sthresh@nginx.com			&& apt-get update \
33*1639Sthresh@nginx.com			;; \
34*1639Sthresh@nginx.com		*) \
35*1639Sthresh@nginx.com# we're on an architecture upstream doesn't officially build for
36*1639Sthresh@nginx.com# let's build binaries from the published source packages
37*1639Sthresh@nginx.com			echo "deb-src https://packages.nginx.org/unit/debian/ buster unit" >> /etc/apt/sources.list.d/unit.list \
38*1639Sthresh@nginx.com			\
39*1639Sthresh@nginx.com# new directory for storing sources and .deb files
40*1639Sthresh@nginx.com			&& tempDir="$(mktemp -d)" \
41*1639Sthresh@nginx.com			&& chmod 777 "$tempDir" \
42*1639Sthresh@nginx.com# (777 to ensure APT's "_apt" user can access it too)
43*1639Sthresh@nginx.com			\
44*1639Sthresh@nginx.com# save list of currently-installed packages so build dependencies can be cleanly removed later
45*1639Sthresh@nginx.com			&& savedAptMark="$(apt-mark showmanual)" \
46*1639Sthresh@nginx.com			\
47*1639Sthresh@nginx.com# build .deb files from upstream's source packages (which are verified by apt-get)
48*1639Sthresh@nginx.com			&& apt-get update \
49*1639Sthresh@nginx.com			&& apt-get build-dep -y $unitPackages \
50*1639Sthresh@nginx.com			&& ( \
51*1639Sthresh@nginx.com				cd "$tempDir" \
52*1639Sthresh@nginx.com				&& DEB_BUILD_OPTIONS="nocheck parallel=$(nproc)" \
53*1639Sthresh@nginx.com					apt-get source --compile $unitPackages \
54*1639Sthresh@nginx.com			) \
55*1639Sthresh@nginx.com# we don't remove APT lists here because they get re-downloaded and removed later
56*1639Sthresh@nginx.com			\
57*1639Sthresh@nginx.com# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
58*1639Sthresh@nginx.com# (which is done after we install the built packages so we don't have to redownload any overlapping dependencies)
59*1639Sthresh@nginx.com			&& apt-mark showmanual | xargs apt-mark auto > /dev/null \
60*1639Sthresh@nginx.com			&& { [ -z "$savedAptMark" ] || apt-mark manual $savedAptMark; } \
61*1639Sthresh@nginx.com			\
62*1639Sthresh@nginx.com# create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be)
63*1639Sthresh@nginx.com			&& ls -lAFh "$tempDir" \
64*1639Sthresh@nginx.com			&& ( cd "$tempDir" && dpkg-scanpackages . > Packages ) \
65*1639Sthresh@nginx.com			&& grep '^Package: ' "$tempDir/Packages" \
66*1639Sthresh@nginx.com			&& echo "deb [ trusted=yes ] file://$tempDir ./" > /etc/apt/sources.list.d/temp.list \
67*1639Sthresh@nginx.com# work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes")
68*1639Sthresh@nginx.com#   Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
69*1639Sthresh@nginx.com#   ...
70*1639Sthresh@nginx.com#   E: Failed to fetch store:/var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages  Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied)
71*1639Sthresh@nginx.com			&& apt-get -o Acquire::GzipIndexes=false update \
72*1639Sthresh@nginx.com			;; \
73*1639Sthresh@nginx.com	esac \
74*1639Sthresh@nginx.com	\
75*1639Sthresh@nginx.com	&& apt-get install --no-install-recommends --no-install-suggests -y \
76*1639Sthresh@nginx.com						$unitPackages \
77*1639Sthresh@nginx.com                        curl \
78*1639Sthresh@nginx.com	&& apt-get remove --purge --auto-remove -y apt-transport-https && rm -rf /var/lib/apt/lists/* /etc/apt/sources.list.d/unit.list \
79*1639Sthresh@nginx.com	\
80*1639Sthresh@nginx.com# if we have leftovers from building, let's purge them (including extra, unnecessary build deps)
81*1639Sthresh@nginx.com	&& if [ -n "$tempDir" ]; then \
82*1639Sthresh@nginx.com		apt-get purge -y --auto-remove \
83*1639Sthresh@nginx.com		&& rm -rf "$tempDir" /etc/apt/sources.list.d/temp.list; \
84*1639Sthresh@nginx.com	fi
85*1639Sthresh@nginx.com
86*1639Sthresh@nginx.com# forward log to docker log collector
87*1639Sthresh@nginx.comRUN ln -sf /dev/stdout /var/log/unit.log
88*1639Sthresh@nginx.com
89*1639Sthresh@nginx.comSTOPSIGNAL SIGTERM
90*1639Sthresh@nginx.com
91*1639Sthresh@nginx.comCOPY docker-entrypoint.sh /usr/local/bin/
92*1639Sthresh@nginx.comRUN mkdir /docker-entrypoint.d/
93*1639Sthresh@nginx.comENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
94*1639Sthresh@nginx.com
95*1639Sthresh@nginx.comCMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock"]
96