Repository navigation
Expand file tree
/
Copy pathDockerfile.dev
More file actions
117 lines (100 loc) · 4.43 KB
/
Copy pathDockerfile.dev
File metadata and controls
117 lines (100 loc) · 4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
FROM ubuntu:22.04
LABEL maintainer="chrisdo@vulcan.com"
LABEL description="Local development Dockerfile for CDIP Admin Portal"
# Install basic tools first
RUN apt-get update && \
apt-get -y upgrade && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y \
curl \
wget \
gnupg \
lsb-release \
software-properties-common \
git \
vim \
cargo \
rustc \
&& apt-get autoremove
# Add PostgreSQL official repository for PostgreSQL 12
RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg && \
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list
# Install postgresql-client-12 and other base packages
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y \
libpq-dev \
python3-pip \
python3-openssl \
libssl-dev \
libffi-dev \
locales locales-all \
postgresql-client-12 \
build-essential \
pkg-config \
&& apt-get autoremove
# Install Python 3.11
RUN add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
python3.11 \
python3.11-dev \
python3.11-venv \
python3.11-distutils && \
apt-get autoremove
# Install pip for Python 3.11
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11
# Create symlinks for python3.11 as python3 and pip
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 1 && \
update-alternatives --install /usr/bin/pip3 pip3 /usr/local/bin/pip3.11 1
# Use ubuntugis/ppa for jammy (Ubuntu 22.04). apt-key is deprecated; place a
# dearmored key in /etc/apt/keyrings and reference it via signed-by= so the
# build doesn't break on newer base images that disable apt-key.
RUN mkdir -p /etc/apt/keyrings && \
curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x089EBE08314DF160" | gpg --dearmor -o /etc/apt/keyrings/ubuntugis-archive-keyring.gpg && \
echo "deb [signed-by=/etc/apt/keyrings/ubuntugis-archive-keyring.gpg] http://ppa.launchpad.net/ubuntugis/ppa/ubuntu jammy main" > /etc/apt/sources.list.d/ubuntugis.list
RUN apt-get update && \
apt-get -y install gdal-bin libgdal-dev
# Combine the include-path exports with the pip install in a single RUN so
# the env vars actually apply when building the GDAL python package; in
# separate layers they would not persist.
RUN export CPLUS_INCLUDE_PATH=/usr/include/gdal && \
export C_INCLUDE_PATH=/usr/include/gdal && \
python3.11 -m pip install GDAL==$(gdal-config --version)
# Set working directory
WORKDIR /workspace
# Copy requirements files
COPY dependencies/requirements.txt /workspace/requirements.txt
COPY dependencies/requirements-dev.txt /workspace/requirements-dev.txt
# Upgrade pip and install wheel for better package support
# Pin setuptools<71 to keep pkg_resources available for older packages like cryptography==2.9.2
RUN python3.11 -m pip install -U "pip" "wheel" "setuptools<71"
# Install Python dependencies.
#
# cryptography==2.9.2 (pinned in the tracked requirements) is incompatible with
# Python 3.11. To avoid this dev image, work around the pin without mutating
# the tracked requirements files: copy them to /tmp, drop the cryptography
# pin from the copies, install a 3.11-compatible cryptography first, then
# install everything else from the temp files. /workspace keeps the original
# pins so the image build doesn't disagree with what CI/prod read.
#
# This is a dev-only override; the right long-term fix is bumping
# cryptography in the tracked requirements (out of scope for this PR).
RUN cp /workspace/requirements.txt /tmp/requirements.txt && \
cp /workspace/requirements-dev.txt /tmp/requirements-dev.txt && \
sed -i '/^cryptography==/d' /tmp/requirements.txt /tmp/requirements-dev.txt && \
python3.11 -m pip install "cryptography==42.0.8" --no-cache-dir && \
python3.11 -m pip install -r /tmp/requirements.txt --no-cache-dir && \
python3.11 -m pip install -r /tmp/requirements-dev.txt --no-cache-dir
# Set environment variables
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
ENV LANGUAGE=C.UTF-8
ENV DJANGO_SETTINGS_MODULE=cdip_admin.settings
ENV PYTHONUNBUFFERED=1
# Set working directory to app
WORKDIR /var/www/app
# Expose port for Django dev server
EXPOSE 8888
# Default command (can be overridden in docker-compose)
CMD ["python3.11", "manage.py", "runserver", "0.0.0.0:8888"]