|
1 | | -FROM docker.io/library/python:3.9-alpine |
| 1 | +FROM docker.io/drycc/base:bullseye |
2 | 2 |
|
3 | 3 | COPY requirements.txt /app/requirements.txt |
4 | 4 | COPY dev_requirements.txt /app/dev_requirements.txt |
5 | 5 |
|
6 | | -ENV PGDATA /var/lib/postgresql/12 |
| 6 | +ENV PGDATA="/var/lib/postgresql/14/data" \ |
| 7 | + PYTHON_VERSION="3.10.2" \ |
| 8 | + POSTGRES_VERSION="14.2" \ |
| 9 | + GOSU_VERSION="1.14" |
7 | 10 |
|
8 | | -ENV PATH="/app/.venv/bin:${PATH}" |
9 | | - |
10 | | -RUN echo https://dl-cdn.alpinelinux.org/alpine/edge/testing >>/etc/apk/repositories \ |
11 | | - && apk add --update --virtual .build-deps \ |
12 | | - postgresql-dev \ |
13 | | - gcc \ |
14 | | - libffi-dev \ |
15 | | - musl-dev \ |
16 | | - openldap-dev \ |
17 | | - openssl-dev \ |
18 | | - cargo \ |
19 | | - rust \ |
20 | | - && ln /usr/lib/libldap.so /usr/lib/libldap_r.so \ |
| 11 | +RUN buildDeps='gcc rustc cargo libffi-dev musl-dev libldap2-dev libsasl2-dev'; \ |
| 12 | + install-packages ldap-utils mercurial ca-certificates openssl git $buildDeps \ |
| 13 | + && install-stack python $PYTHON_VERSION \ |
| 14 | + && install-stack postgresql $POSTGRES_VERSION \ |
| 15 | + && install-stack gosu $GOSU_VERSION && . init-stack \ |
21 | 16 | && python3 -m venv /app/.venv \ |
22 | 17 | && source /app/.venv/bin/activate \ |
23 | 18 | && pip3 install --disable-pip-version-check --no-cache-dir -r /app/requirements.txt \ |
24 | 19 | && pip3 install --disable-pip-version-check --no-cache-dir -r /app/dev_requirements.txt \ |
25 | | - && find /app/.venv /usr/local -type f -executable ! -path '*/cryptography*' -exec scanelf --needed --nobanner --format '%n#p' '{}' ';' \ |
26 | | - | tr ',' '\n' \ |
27 | | - | sort -u \ |
28 | | - | awk 'system("[[ -e /app/.venv/lib/" $1 " || -e /usr/local/lib/" $1 " ]]") == 0 { next } { print "so:" $1 }' \ |
29 | | - | xargs -rt apk add --no-cache --virtual .python-rundeps \ |
30 | | - && apk add --update --virtual .passport-rundeps \ |
31 | | - git \ |
32 | | - mercurial \ |
33 | | - ca-certificates \ |
34 | | - su-exec \ |
35 | | - bash \ |
36 | | - shadow \ |
37 | | - postgresql \ |
38 | | - openssl \ |
| 20 | + # cleanup |
| 21 | + && scanelp /app/.venv/lib > runtime.txt \ |
| 22 | + && apt-get purge -y --auto-remove $buildDeps \ |
| 23 | + && install-packages $(< runtime.txt) \ |
| 24 | + && apt-get autoremove -y \ |
| 25 | + && apt-get clean -y \ |
| 26 | + && rm -rf \ |
| 27 | + /usr/share/doc \ |
| 28 | + /usr/share/man \ |
| 29 | + /usr/share/info \ |
| 30 | + /usr/share/locale \ |
| 31 | + /var/lib/apt/lists/* \ |
| 32 | + /var/log/* \ |
| 33 | + /var/cache/debconf/* \ |
| 34 | + /etc/systemd \ |
| 35 | + /lib/lsb \ |
| 36 | + /lib/udev \ |
| 37 | + /usr/lib/`echo $(uname -m)`-linux-gnu/gconv/IBM* \ |
| 38 | + /usr/lib/`echo $(uname -m)`-linux-gnu/gconv/EBC* \ |
| 39 | + && mkdir -p /usr/share/man/man{1..8} \ |
39 | 40 | && mkdir -p /run/postgresql $PGDATA \ |
| 41 | + && groupadd postgres && useradd -g postgres postgres \ |
40 | 42 | && chown -R postgres:postgres /run/postgresql $PGDATA \ |
41 | | - && apk del .build-deps \ |
42 | | - && su-exec postgres initdb -D $PGDATA |
| 43 | + && gosu postgres initdb -D $PGDATA |
43 | 44 |
|
44 | 45 | COPY . /app |
45 | | - |
46 | | -ENV PATH /app/.venv/bin:/app/bin:$PATH |
47 | 46 | WORKDIR /app |
48 | 47 | CMD ["/app/bin/boot"] |
49 | 48 | EXPOSE 8000 |
0 commit comments