Skip to content

Commit f034203

Browse files
committed
Change worker Docker image to Debian with PyTorch
1 parent c640be1 commit f034203

File tree

1 file changed

+66
-80
lines changed

1 file changed

+66
-80
lines changed

.docker/worker.dockerfile

Lines changed: 66 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,36 @@
1-
# PHP 8.1.13
2-
#FROM php:8.1-alpine
3-
FROM php@sha256:f9e31f22bdd89c1334a03db5c8800a5f3b1e1fe042d470adccf58a29672c6202
1+
# PHP 8.1.27
2+
# FROM php:8.1
3+
FROM php@sha256:9b5dfb7deef3e48d67b2599e4d3967bb3ece19fd5ba09cb8e7ee10f5facf36e0
44
MAINTAINER Martin Zurowietz <[email protected]>
55
LABEL org.opencontainers.image.source https://github.com/biigle/core
66

7-
ARG OPENCV_VERSION=4.6.0-r3
8-
RUN apk add --no-cache \
9-
eigen \
7+
RUN LC_ALL=C.UTF-8 apt-get update \
8+
&& apt-get install -y --no-install-recommends \
109
ffmpeg \
11-
lapack \
12-
openblas \
13-
py3-numpy \
1410
python3 \
15-
py3-opencv="$OPENCV_VERSION"
11+
python3-numpy \
12+
python3-opencv \
13+
python3-scipy \
14+
python3-sklearn \
15+
python3-matplotlib \
16+
python3-shapely \
17+
&& apt-get -y autoremove \
18+
&& apt-get clean \
19+
&& rm -r /var/lib/apt/lists/*
1620

1721
RUN ln -s "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
1822
ADD ".docker/all-php.ini" "$PHP_INI_DIR/conf.d/all.ini"
1923

20-
RUN apk add --no-cache \
21-
libxml2 \
22-
libzip \
23-
openssl \
24-
postgresql \
25-
&& apk add --no-cache --virtual .build-deps \
24+
RUN LC_ALL=C.UTF-8 apt-get update \
25+
&& apt-get install -y --no-install-recommends \
2626
libxml2-dev \
2727
libzip-dev \
28-
postgresql-dev \
29-
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
28+
libpq-dev \
29+
&& apt-get install -y --no-install-recommends \
30+
libxml2 \
31+
libzip4 \
32+
postgresql-client \
33+
&& docker-php-ext-configure pgsql -with-pgsql=/usr/bin/pgsql \
3034
&& docker-php-ext-install -j$(nproc) \
3135
exif \
3236
pcntl \
@@ -35,15 +39,29 @@ RUN apk add --no-cache \
3539
pgsql \
3640
soap \
3741
zip \
38-
&& apk del --purge .build-deps
42+
&& apt-get purge -y \
43+
libxml2-dev \
44+
libzip-dev \
45+
libpq-dev \
46+
&& apt-get -y autoremove \
47+
&& apt-get clean \
48+
&& rm -r /var/lib/apt/lists/*
3949

4050
# Configure proxy if there is any. See: https://stackoverflow.com/a/2266500/1796523
4151
RUN [ -z "$HTTP_PROXY" ] || pear config-set http_proxy $HTTP_PROXY
42-
RUN apk add --no-cache yaml \
43-
&& apk add --no-cache --virtual .build-deps g++ make autoconf yaml-dev \
52+
53+
RUN LC_ALL=C.UTF-8 apt-get update \
54+
&& apt-get install -y --no-install-recommends \
55+
libyaml-dev \
56+
&& apt-get install -y --no-install-recommends \
57+
libyaml-0-2 \
4458
&& pecl install yaml \
45-
&& docker-php-ext-enable yaml \
46-
&& apk del --purge .build-deps
59+
&& printf "\n" | docker-php-ext-enable yaml \
60+
&& apt-get purge -y \
61+
libyaml-dev \
62+
&& apt-get -y autoremove \
63+
&& apt-get clean \
64+
&& rm -r /var/lib/apt/lists/*
4765

4866
ARG PHPREDIS_VERSION=5.3.7
4967
RUN curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/${PHPREDIS_VERSION}.tar.gz \
@@ -53,70 +71,38 @@ RUN curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/${
5371
&& mv phpredis-${PHPREDIS_VERSION} /usr/src/php/ext/redis \
5472
&& docker-php-ext-install -j$(nproc) redis
5573

56-
ENV PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}"
57-
# Install vips from source because the apk package does not have dzsave support! Install
58-
# libvips and the vips PHP extension in one go so the *-dev dependencies are reused.
59-
ARG LIBVIPS_VERSION=8.12.2
60-
ARG PHP_VIPS_EXT_VERSION=1.0.13
61-
RUN apk add --no-cache --virtual .build-deps \
62-
autoconf \
63-
automake \
64-
build-base \
65-
expat-dev \
66-
glib-dev \
67-
libgsf-dev \
68-
libjpeg-turbo-dev \
69-
libpng-dev \
70-
tiff-dev \
71-
&& apk add --no-cache \
72-
expat \
73-
glib \
74-
libgsf \
75-
libjpeg-turbo \
76-
libpng \
77-
tiff \
78-
&& cd /tmp \
79-
&& curl -L https://github.com/libvips/libvips/releases/download/v${LIBVIPS_VERSION}/vips-${LIBVIPS_VERSION}.tar.gz -o vips-${LIBVIPS_VERSION}.tar.gz \
80-
&& tar -xzf vips-${LIBVIPS_VERSION}.tar.gz \
81-
&& cd vips-${LIBVIPS_VERSION} \
82-
&& ./configure \
83-
--without-python \
84-
--enable-debug=no \
85-
--disable-dependency-tracking \
86-
--disable-static \
87-
&& make -j $(nproc) \
88-
&& make -s install-strip \
89-
&& cd /tmp \
90-
&& curl -L https://github.com/libvips/php-vips-ext/raw/master/vips-${PHP_VIPS_EXT_VERSION}.tgz -o vips-${PHP_VIPS_EXT_VERSION}.tgz \
91-
&& echo '' | pecl install vips-${PHP_VIPS_EXT_VERSION}.tgz \
74+
# ENV PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}"
75+
76+
RUN LC_ALL=C.UTF-8 apt-get update \
77+
&& apt-get install -y --no-install-recommends \
78+
libvips-dev \
79+
&& apt-get install -y --no-install-recommends \
80+
libvips42 \
81+
&& pecl install vips \
9282
&& docker-php-ext-enable vips \
93-
&& rm -r /tmp/* \
94-
&& apk del --purge .build-deps \
95-
&& rm -rf /var/cache/apk/*
83+
&& apt-get purge -y \
84+
libvips-dev \
85+
&& apt-get -y autoremove \
86+
&& apt-get clean \
87+
&& rm -r /var/lib/apt/lists/*
9688

9789
# Unset proxy configuration again.
9890
RUN [ -z "$HTTP_PROXY" ] || pear config-set http_proxy ""
9991

100-
# Other Python dependencies are added with the OpenCV build above.
101-
RUN apk add --no-cache py3-scipy py3-scikit-learn py3-matplotlib py3-shapely
102-
103-
# Set this library path so the Python modules are linked correctly.
104-
# See: https://github.com/python-pillow/Pillow/issues/1763#issuecomment-204252397
105-
ENV LIBRARY_PATH=/lib:/usr/lib
106-
# Install Python dependencies. Note that these also depend on some image processing libs
107-
# that were installed along with vips.
108-
RUN apk add --no-cache --virtual .build-deps \
109-
python3-dev \
110-
py3-pip \
111-
py3-wheel \
112-
build-base \
113-
libjpeg-turbo-dev \
114-
libpng-dev \
115-
&& pip3 install --no-cache-dir \
92+
RUN LC_ALL=C.UTF-8 apt-get update \
93+
&& apt-get install -y --no-install-recommends \
94+
python3-pip \
95+
&& pip3 install --no-cache-dir --break-system-packages \
11696
PyExcelerate==0.6.7 \
11797
Pillow==10.0.1 \
118-
&& apk del --purge .build-deps \
119-
&& rm -rf /var/cache/apk/*
98+
&& pip3 install --no-cache-dir --break-system-packages --index-url https://download.pytorch.org/whl/cpu \
99+
torch==2.0.* \
100+
torchvision==0.15.* \
101+
&& apt-get purge -y \
102+
python3-pip \
103+
&& apt-get -y autoremove \
104+
&& apt-get clean \
105+
&& rm -r /var/lib/apt/lists/*
120106

121107
WORKDIR /var/www
122108

0 commit comments

Comments
 (0)