Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up dev environment and update database dependencies #56

Merged
merged 4 commits into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note for posterity: Something weird was happening with docker-entrypoint.sh where it couldn't actually read in command overrides as arguments when specifying a new command via the CLI. I never really figured it out, but refactoring things such that docker-entrypoint.sh is used in the command rather than the entrypoint fixed the problem, and more closely matches the way I work in development anyway (I don't want to run migrations literally every time I'm running code on the app image).


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:
Loading