Skip to content

Commit

Permalink
Clean up dev environment and update database dependencies (#56)
Browse files Browse the repository at this point in the history
* Consolidate data Dockerfiles and upgrade dependencies in db/Dockerfile

* Clean up docker compose and its instructions

* Get app running without unnecessary docker-compose.db.yml file

* Update mellowroute fixture with latest dump from prod DB
  • Loading branch information
jeancochrane authored Jun 15, 2024
1 parent fa5d72d commit cce3ef0
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 66 deletions.
28 changes: 0 additions & 28 deletions Dockerfile

This file was deleted.

7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ Development requires Docker and Docker Compose.
Build containers:

```
docker-compose -f docker-compose.yml -f docker-compose.db.yml build
docker compose build
```

Run migrations:

```
docker-compose run --rm app ./manage.py migrate
docker compose run --rm app ./manage.py migrate
```

Import the data (note that the full data import can take quite a bit of memory,
so make sure to adjust your Docker preferences to allow Docker at least 6GB of
RAM):

```
docker-compose -f docker-compose.yml -f docker-compose.db.yml run --rm make
docker compose run --rm -w /app postgres make db/import/chicago.table
docker compose run --rm -w /app app make db/import/mellowroute.fixture
```

Start the app service:
Expand Down
10 changes: 5 additions & 5 deletions app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get update && apt-get install -y --no-install-recommends nodejs gdal-bin

# Inside the container, create an app directory and switch into it
RUN mkdir /app
WORKDIR /app
RUN mkdir -p /app/app
WORKDIR /app/app

# Install Python requirements
COPY ./requirements.txt /app/requirements.txt
COPY ./requirements.txt /app/app/requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# Install Node requirements
COPY ./package.json /app/package.json
COPY ./package.json /app/app/package.json
RUN npm install

COPY . /app
COPY . /app/app

# Add a bogus env var for the Django secret key in order to allow us to run
# the 'collectstatic' management command
Expand Down
2 changes: 1 addition & 1 deletion app/mbm/fixtures/mellowroute.json

Large diffs are not rendered by default.

25 changes: 17 additions & 8 deletions db/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
FROM mdillon/postgis:11
FROM postgis/postgis:16-3.4

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential gcc make cmake gdal-bin postgresql-server-dev-11 \
libboost-dev libboost-graph-dev \
wget ca-certificates
build-essential gcc make cmake gdal-bin postgresql-server-dev-16 \
expat libexpat1-dev libboost-dev libboost-graph-dev libboost-program-options-dev libpqxx-dev \
osmctools wget ca-certificates

RUN wget -O pgrouting-3.1.0.tar.gz https://github.com/pgRouting/pgrouting/archive/v3.1.0.tar.gz && \
tar xvfz pgrouting-3.1.0.tar.gz && \
cd pgrouting-3.1.0 && \
RUN wget -O pgrouting-3.6.2.tar.gz https://github.com/pgRouting/pgrouting/archive/v3.6.2.tar.gz && \
tar xvfz pgrouting-3.6.2.tar.gz && \
cd pgrouting-3.6.2 && \
mkdir build && \
cd build && \
cmake .. && \
make && \
make install && \
cd / && rm -Rf pgrouting-3.1.0*
cd / && rm -Rf pgrouting-3.6.2*

RUN wget -O osm2pgrouting-2.3.8.tar.gz https://github.com/pgRouting/osm2pgrouting/archive/v2.3.8.tar.gz && \
tar xvfz osm2pgrouting-2.3.8.tar.gz && \
cd osm2pgrouting-2.3.8 && \
cmake -H. -Bbuild && \
cd build && \
make && \
make install && \
cd / && rm -Rf osm2pgrouting-2.3.8*
16 changes: 0 additions & 16 deletions docker-compose.db.yml

This file was deleted.

11 changes: 6 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ services:
postgres:
condition: service_healthy
volumes:
- ./app:/app
- mellow-bike-map-node-modules:/app/node_modules
- .:/app
- mellow-bike-map-node-modules:/app/app/node_modules
environment:
DJANGO_SECRET_KEY: reallysupersecret
DJANGO_MANAGEPY_MIGRATE: "on"
entrypoint: /app/docker-entrypoint.sh
command: python manage.py runserver 0.0.0.0:8000
command: /app/app/docker-entrypoint.sh python manage.py runserver 0.0.0.0:8000

postgres:
container_name: mellow-bike-map-postgres
Expand All @@ -34,11 +33,13 @@ services:
POSTGRES_DB: mbm
POSTGRES_PASSWORD: postgres
volumes:
- mellow-bike-map-db-data:/var/lib/postgresql/data
- mellow-bike-map-db-data-postgis-16:/var/lib/postgresql/data
- ./db/create-extensions.sql:/docker-entrypoint-initdb.d/create-extensions.sql
- ./:/app
ports:
- 32001:5432

volumes:
mellow-bike-map-db-data:
mellow-bike-map-db-data-postgis-16:
mellow-bike-map-node-modules:

0 comments on commit cce3ef0

Please sign in to comment.