|
1 |
| -# The official python:2.7 image no longer receives automatic rebuilds (it's |
2 |
| -# a year old as of October, 2021), so use the latest LTS release of Ubuntu |
3 |
| -# that includes Python 2.7 instead. |
4 |
| -FROM ubuntu:20.04 |
5 |
| - |
6 |
| -# Install packages needed to run your application (not build deps). |
7 |
| -RUN set -x \ |
8 |
| - && RUN_DEPS=" \ |
9 |
| - ca-certificates \ |
10 |
| - git \ |
11 |
| - libpq5 \ |
12 |
| - make \ |
13 |
| - postgresql-client \ |
14 |
| - python2.7 \ |
15 |
| - " \ |
16 |
| - && apt-get update && apt-get install -y --no-install-recommends $RUN_DEPS \ |
| 1 | +# pull official base image |
| 2 | +FROM python:3.8-slim-bullseye |
| 3 | + |
| 4 | +# set work directory |
| 5 | +WORKDIR /code |
| 6 | + |
| 7 | +# set environment varibles |
| 8 | +ENV PYTHONDONTWRITEBYTECODE 1 |
| 9 | +ENV PYTHONUNBUFFERED 1 |
| 10 | + |
| 11 | +# getting postgres from PGDG (https://wiki.postgresql.org/wiki/Apt) |
| 12 | +# gnupg is required to run apt.postgresql.org.sh |
| 13 | +RUN apt-get update \ |
| 14 | + && apt-get install --assume-yes --no-install-recommends \ |
| 15 | + git \ |
| 16 | + gnupg \ |
| 17 | + postgresql-common \ |
| 18 | + && /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y\ |
| 19 | + && apt-get install --assume-yes --no-install-recommends postgresql-client-14\ |
| 20 | + && apt-get purge --assume-yes --auto-remove gnupg\ |
17 | 21 | && rm -rf /var/lib/apt/lists/*
|
18 | 22 |
|
19 |
| -# Copy requirements |
20 |
| -ADD requirements.txt /requirements.txt |
21 |
| -ADD DjangoPlugin /DjangoPlugin |
22 |
| - |
23 |
| -# Install build deps, then run `pip install`, then remove unneeded build deps all in a single step. |
24 |
| -# Correct the path to your production requirements file, if needed. |
25 |
| -# For installing a python2.7-compatible pip: https://stackoverflow.com/a/54335642/166053 |
26 |
| -# Since we are using the system Python, also isolate the code in its own virtualenv. |
27 |
| -RUN set -x \ |
28 |
| - && BUILD_DEPS=" \ |
29 |
| - build-essential \ |
30 |
| - libpq-dev \ |
31 |
| - python2.7-dev \ |
32 |
| - wget \ |
33 |
| - " \ |
34 |
| - && apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \ |
35 |
| - && wget -q -O /tmp/get-pip.py https://bootstrap.pypa.io/pip/2.7/get-pip.py \ |
36 |
| - && python2.7 /tmp/get-pip.py \ |
37 |
| - && rm /tmp/get-pip.py \ |
38 |
| - && python2.7 -m pip install virtualenv \ |
39 |
| - && virtualenv /venv \ |
40 |
| - && /venv/bin/python -m pip install --no-cache-dir -r /requirements.txt \ |
41 |
| - \ |
42 |
| - && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \ |
| 23 | +# install deb packages |
| 24 | +RUN apt-get update \ |
| 25 | + && apt-get install --assume-yes --no-install-recommends \ |
| 26 | + make \ |
43 | 27 | && rm -rf /var/lib/apt/lists/*
|
44 | 28 |
|
45 |
| -# Copy application code |
46 |
| -RUN mkdir /code/ |
47 |
| -WORKDIR /code/ |
48 |
| -ADD . /code/ |
| 29 | +# install python dependencies |
| 30 | +COPY ./requirements.txt ./requirements.txt |
| 31 | +COPY ./DjangoPlugin ./DjangoPlugin |
| 32 | + |
| 33 | +RUN apt-get update \ |
| 34 | + && apt-get install --assume-yes --no-install-recommends \ |
| 35 | + g++ \ |
| 36 | + gcc \ |
| 37 | + libc6-dev \ |
| 38 | + libpq-dev \ |
| 39 | + && python3 -m pip install --no-cache-dir -r requirements.txt \ |
| 40 | + && apt-get purge --assume-yes --auto-remove \ |
| 41 | + gcc \ |
| 42 | + libc6-dev \ |
| 43 | + libpq-dev \ |
| 44 | + && rm -rf /var/lib/apt/lists/* |
| 45 | + |
| 46 | +COPY ./docker-entrypoint.sh ./docker-entrypoint.sh |
| 47 | +COPY ./Makefile ./Makefile |
| 48 | +COPY ./scss ./scss |
| 49 | +COPY ./trac-env ./trac-env |
| 50 | +RUN make compile-scss |
| 51 | +RUN rm -r ./scss |
49 | 52 |
|
50 |
| -RUN PATH=/venv/bin:${PATH} make compile-scss |
51 | 53 |
|
52 | 54 | VOLUME /code/trac-env/files/
|
53 | 55 |
|
54 |
| -# gunicorn or tracd will listen on this port |
55 | 56 | EXPOSE 9000
|
56 |
| - |
57 | 57 | ENV DJANGO_SETTINGS_MODULE=tracdjangoplugin.settings TRAC_ENV=/code/trac-env/
|
58 | 58 |
|
59 |
| -ENTRYPOINT ["/code/docker-entrypoint.sh"] |
| 59 | +ENTRYPOINT ["./docker-entrypoint.sh"] |
60 | 60 |
|
61 | 61 | # Start gunicorn
|
62 |
| -CMD ["/venv/bin/gunicorn", "tracdjangoplugin.wsgi:application", "--bind", "0.0.0.0:9000", "--workers", "8", "--max-requests", "1000"] |
| 62 | +CMD ["gunicorn", "tracdjangoplugin.wsgi:application", "--bind", "0.0.0.0:9000", "--workers", "8", "--max-requests", "1000"] |
0 commit comments