Skip to content
Open
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
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* text eol=lf
*.png binary
*.pdf binary
*.html binary
33 changes: 33 additions & 0 deletions DOCKERFILE.api.onestep
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM python:3.6.5-stretch
MAINTAINER Brian H. Grant <brian@hackoregon.org> & "M. Edward (Ed) Borasky <znmeb@znmeb.net>
ENV PYTHONUNBUFFERED 1

# add required Debian packages
# https://docs.djangoproject.com/en/2.0/ref/contrib/gis/install/geolibs/
RUN apt-get update \
&& apt-get install -qqy --no-install-recommends \
binutils \
gdal-bin \
libproj-dev \
postgresql-client-9.6 \
&& apt-get clean

# create and populate /code
RUN mkdir -p /code/bin
COPY /bin/* /code/bin/
WORKDIR /code

# install the requirements
COPY /requirements/* /code/
RUN pip install -r development.txt

# install GeoDjango
RUN pip install -r geodjango.txt

# create the project and api
COPY gunicorn_config.py /code/
ARG PROJECT_NAME
RUN /bin/bash -c "django-admin.py startproject $PROJECT_NAME . ; python manage.py startapp api"

# replace newly created settings with the example settings
RUN sed "s;<EXAMPLE_PROJECT_NAME>;$PROJECT_NAME;g" bin/example-settings.py > $PROJECT_NAME/settings.py
44 changes: 44 additions & 0 deletions README-onestep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Running the One-Step Development Environment Creator

## Create a new repository
1. Log into GitHub
2. Press the `+` button at the upper left and select "Import repository".
3. Import from this repository with a new name.

## Configuring the run
1. Open a terminal.
2. Clone the repository you created above and `cd` into it.
3. Copy your database backup into `Backups`. If the backup contains database ownership, you'll need to set `DEVELOPMENT_DATABASE_OWNER` in `.env` to the database owner.
* If you want to run the sample `dead_songs` project, copy `dead_songs.sql` into `Backups`.
4. Copy `env.sample` to `.env` and edit `.env`:
* If you want tp run the sample `dead_songs` project, you don't need to change anything.
* Change PROJECT_NAME
* Change DEVELOPMENT_POSTGRES_NAME
* Change DEVELOPMENT_DATABASE_OWNER
* Change the passwords and secret keys

## Running the creation script
1. Type `bin/onestep-create.sh`. This will
* remove the sample project files,
* build the database and API Docker images,
* bring up the Docker network.

When the network is up, you'll see something like

```
api_development_1 | April 29, 2018 - 08:52:18
api_development_1 | Django version 2.0.1, using settings 'dead_songs.settings'
api_development_1 | Starting development server at http://0.0.0.0:8000/
api_development_1 | Quit the server with CONTROL-C.
```
2. Browsing to the running containers: On Linux, Docker for Mac or Docker for Windows, the IP address is `localhost`. On Docker Toolbox, which uses Docker Machine, do `docker-machine ls` to determing `<machine-name>` and then `docker-machine <machine-name> ip`.

You can browse to `http://<ip-address>:8000` to verify the server is live. You should see a Django default page.

![](screenshots/2018-04-29 16_31_37-Django.png)

You can access the database from the host using `pgAdmin` or `psql`. The username is `postgres`, password is the one you set for `postgres` in `.env`, host is `<ip-address>` and the port is the one you set in `.env`, usually 5439.
3. After verifying that the server is there, press `CTRL-C`. This will shut down the database and API services.
4. The script will copy the generated code for your project to the repository.
5. Check your remote - `git remote -v`. Make sure you'll be pushing to the new repository, not the template!
6. `git add .; git commit; git push`.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,10 @@ This current implementation builds on the [transportation-system-backend](https:

### Major Contributors

M. Edward (Ed) Borasky ([znmeb](https://github.com/znmeb)),
Brian Grant ([bhgrant8](https://github.com/bhgrant8), [BrianHGrant](https://github.com/BrianHGrant)),
Adi ([kiniadit](https://github.com/kiniadit)),
Mike Lonergan ([mikethecanuck](https://github.com/mikethecanuck)),
Alec Peters ([adpeters](https://github.com/adpeters)),
Nathan Miller ([nam20485](https://github.com/nam20485)).
* M. Edward (Ed) Borasky ([znmeb](https://github.com/znmeb)),
* Brian Grant ([bhgrant8](https://github.com/bhgrant8), [BrianHGrant](https://github.com/BrianHGrant)),
* Adi ([kiniadit](https://github.com/kiniadit)),
* Mike Lonergan ([mikethecanuck](https://github.com/mikethecanuck)),
* Alec Peters ([adpeters](https://github.com/adpeters)),
* Nathan Miller ([nam20485](https://github.com/nam20485)).
* Moss Drake ([mxmoss](https://github.com/mxmoss)).
37 changes: 37 additions & 0 deletions bin/onestep-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#! /bin/bash

set -euo pipefail

# Grab environment variables
. ./.env

# Remove sample project
echo "Removing the sample project..."
bin/remove-sample.sh

echo "Creating new Django Rest Framework Project Scaffold..."
echo "This will take some time."
echo "It will start a server when it is done."
echo "Type 'CTRL-C' after it starts the server."
sleep 15
docker-compose -f onestep-docker-compose.yml up --build

CONTAINER_NAME=`docker-compose -f onestep-docker-compose.yml ps | grep api | sed 's; .*$;;'`
echo "Container name is ${CONTAINER_NAME}"
echo "Copying code from the container"
docker cp ${CONTAINER_NAME}:/code/manage.py .
docker cp ${CONTAINER_NAME}:/code/api .
docker cp ${CONTAINER_NAME}:/code/staticfiles .
docker cp ${CONTAINER_NAME}:/code/$PROJECT_NAME .

# fix ownership
echo "Fixing ownership on Linux"
if [ `uname -s` = "Linux" ]
then
ls --color=auto -Altr
echo "sudo chown -R `id -u $USER`:`id -g $USER` ."
sudo chown -R `id -u $USER`:`id -g $USER` .
ls --color=auto -Altr
fi

echo "Finished"
5 changes: 0 additions & 5 deletions bin/remove-sample.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ if [ -d ./api ]; then
rm -rf api
fi

if [ -f ./Backups/dead_songs.sql ]; then
echo "removing sanmple db backup"
rm ./Backups/dead_songs.sql
fi

if [ "$(docker ps -a -q -f ancestor=db_development --format=\"{{.ID}}\")" ]; then
echo "removing containers"
docker-compose -f development-docker-compose.yml down
Expand Down
File renamed without changes.
44 changes: 44 additions & 0 deletions disaster_resilience.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
PROJECT_NAME=disaster_resilience
DEBUG=True

# the database superuser name - this is the default
DEVELOPMENT_POSTGRES_USER=postgres

# the database name the API will connect to - "dbname" in most PostgreSQL command-line tools
DEVELOPMENT_POSTGRES_NAME=disaster

# the database owner - automatic restore needs this
DEVELOPMENT_DATABASE_OWNER=postgres

# *service* name (*not* image name) of the database in the Docker network
DEVELOPMENT_POSTGRES_HOST=db_development

# port the database is listening on in the Docker network
DEVELOPMENT_POSTGRES_PORT=5432

# password for the PostgreSQL database superuser in the database container
DEVELOPMENT_POSTGRES_PASSWORD=sit-down-c0mic

# the password for the teams
DEVELOPMENT_TEAM_PASSWORD=d0wn!0ff!a!duck

# Django secret key in the API container
DEVELOPMENT_DJANGO_SECRET_KEY=r0ck.ar0und.the.c10ck

# the database superuser name - this is the default
PRODUCTION_POSTGRES_USER=postgres

# the database name the API will connect to - "dbname" in most PostgreSQL command-line tools
PRODUCTION_POSTGRES_NAME=disaster

# *service* name (*not* image name) of the database in the Docker network
PRODUCTION_POSTGRES_HOST=aws_ip

# port the database is listening on in the Docker network
PRODUCTION_POSTGRES_PORT=5432

# password for the PostgreSQL database superuser in the database container
PRODUCTION_POSTGRES_PASSWORD=sit-down-c0mic

# Django secret key in the API container
PRODUCTION_DJANGO_SECRET_KEY=r0ck.ar0und.the.c10ck
1 change: 0 additions & 1 deletion jessie/pgdg.list.jessie

This file was deleted.

34 changes: 34 additions & 0 deletions onestep-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '3.4'
services:
db_development:
build:
context: .
dockerfile: DOCKERFILE.db.development
image: db_development
ports:
- 5439:5432
environment:
- POSTGRES_PASSWORD=${DEVELOPMENT_POSTGRES_PASSWORD}
- DATABASE_OWNER=${DEVELOPMENT_DATABASE_OWNER}
- TEAM_PASSWORD=${DEVELOPMENT_TEAM_PASSWORD}
api_development:
build:
context: .
dockerfile: DOCKERFILE.api.onestep
args:
- PROJECT_NAME
image: api_development
command: ./bin/development-docker-entrypoint.sh
ports:
- "8000:8000"
depends_on:
- db_development
environment:
- PROJECT_NAME
- DEBUG=True
- POSTGRES_USER=${DEVELOPMENT_POSTGRES_USER}
- POSTGRES_NAME=${DEVELOPMENT_POSTGRES_NAME}
- POSTGRES_HOST=${DEVELOPMENT_POSTGRES_HOST}
- POSTGRES_PORT=${DEVELOPMENT_POSTGRES_PORT}
- POSTGRES_PASSWORD=${DEVELOPMENT_POSTGRES_PASSWORD}
- DJANGO_SECRET_KEY=${DEVELOPMENT_DJANGO_SECRET_KEY}
44 changes: 44 additions & 0 deletions passenger_census.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
PROJECT_NAME=transportation_systems_passenger_census
DEBUG=True

# the database superuser name - this is the default
DEVELOPMENT_POSTGRES_USER=postgres

# the database name the API will connect to - "dbname" in most PostgreSQL command-line tools
DEVELOPMENT_POSTGRES_NAME=transportation-systems-passenger-census

# the database owner - automatic restore needs this
DEVELOPMENT_DATABASE_OWNER=transportation-systems

# *service* name (*not* image name) of the database in the Docker network
DEVELOPMENT_POSTGRES_HOST=db_development

# port the database is listening on in the Docker network
DEVELOPMENT_POSTGRES_PORT=5432

# password for the PostgreSQL database superuser in the database container
DEVELOPMENT_POSTGRES_PASSWORD=sit-down-c0mic

# the password for the teams
DEVELOPMENT_TEAM_PASSWORD=d0wn!0ff!a!duck

# Django secret key in the API container
DEVELOPMENT_DJANGO_SECRET_KEY=r0ck.ar0und.the.c10ck

# the database superuser name - this is the default
PRODUCTION_POSTGRES_USER=postgres

# the database name the API will connect to - "dbname" in most PostgreSQL command-line tools
PRODUCTION_POSTGRES_NAME=transportation-systems-passenger-census

# *service* name (*not* image name) of the database in the Docker network
PRODUCTION_POSTGRES_HOST=aws_ip

# port the database is listening on in the Docker network
PRODUCTION_POSTGRES_PORT=5432

# password for the PostgreSQL database superuser in the database container
PRODUCTION_POSTGRES_PASSWORD=sit-down-c0mic

# Django secret key in the API container
PRODUCTION_DJANGO_SECRET_KEY=r0ck.ar0und.the.c10ck
Binary file added screenshots/2018-04-29 16_31_37-Django.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.