1- # Use an official Python 3.11 runtime as a parent image
2- FROM python:3.11.4
1+ FROM python:3.11.4 AS tippecanoe
2+ RUN apt-get update && apt-get -y install \
3+ make \
4+ gcc \
5+ g++ \
6+ libsqlite3-dev \
7+ zlib1g-dev
8+ # TODO: Pin Tippecanoe to a specific version
9+ RUN curl -L https://github.com/felt/tippecanoe/tarball/master -o tippecanoe.tar.gz \
10+ && mkdir tippecanoe && tar -xzf tippecanoe.tar.gz -C tippecanoe --strip-components=1 \
11+ && tar -xzf tippecanoe.tar.gz \
12+ && cd tippecanoe \
13+ && make \
14+ && make install
15+
16+ FROM python:3.11.4 AS dependencies
17+ RUN curl -LsSf https://astral.sh/uv/0.7.12/install.sh | sh
18+ ENV UV_COMPILE_BYTECODE=1 UV_LINK_MODE=copy UV_PYTHON_DOWNLOADS=0 PATH="/root/.local/bin/:$PATH"
19+ WORKDIR /app
20+ COPY uv.lock pyproject.toml ./
21+ # TODO: in the future, remove development dependencies from final container
22+ RUN uv sync --locked
23+
324
4- # Set the working directory in the container
5- WORKDIR /usr/src/app
25+ FROM python:3.11.4
626
727# Install system dependencies for GDAL and Tippecanoe
28+ # TODO: Figure out which Tippecanoe dependencies we can remove since we've moved this to a
29+ # separate stage
830RUN apt-get update && apt-get install -y \
931 libgdal-dev \
1032 gcc \
@@ -15,38 +37,17 @@ RUN apt-get update && apt-get install -y \
1537 lsb-release \
1638 && rm -rf /var/lib/apt/lists/*
1739
18- # install postgres client 16 for psql and pg_dump executables for backups.
19- # should match the version used in the other docker file for the postgres install
20- RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
21- RUN curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
22- RUN apt update
23- RUN apt install -y postgresql-client-16
24-
25- # Set GDAL environment variables
26- ENV GDAL_VERSION=3.6.2
27- ENV GDAL_CONFIG=/usr/bin/gdal-config
28-
29- # Install Pipenv
30- RUN pip install pipenv
31-
32- # Copy the Pipfile and Pipfile.lock from the src directory
33- COPY src/Pipfile src/Pipfile.lock ./
40+ COPY --from=tippecanoe /usr/local/bin/tippecanoe /usr/local/bin/tippecanoe
41+ COPY --from=dependencies /app /app
3442
35- # update pipfile
36- RUN pipenv lock
43+ ENV GDAL_VERSION=3.6.2 \
44+ GDAL_CONFIG=/usr/bin/gdal-config \
45+ # place .venv binaries copied from dependencies stage to front of PATH.
46+ # This includes python, pip, and individual package binaries
47+ PATH="/app/.venv/bin:$PATH"
3748
38- # Install the dependencies from Pipfile
39- RUN pipenv install --deploy --ignore-pipfile
40-
41- # Clone and build Tippecanoe
42- RUN git clone https://github.com/felt/tippecanoe.git \
43- && cd tippecanoe \
44- && make \
45- && make install
49+ WORKDIR /app
50+ COPY src ./src
4651
47- # Copy the src directory
48- COPY src/ .
4952
50- # Use Pipenv to run the script
51- # Adjust the path to your main Python script if needed
52- CMD ["pipenv" , "run" , "python" , "./script.py" ]
53+ CMD ["python" , "-m" , "src.main" ]
0 commit comments