Skip to content
This repository has been archived by the owner on Apr 16, 2023. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/0.5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Wasabideveloper committed Sep 15, 2015
2 parents 0c07b56 + 146c147 commit cc61d22
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 43 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To run this project locally, you need docker and docker-compose installed
(https://docs.docker.com/installation/ubuntulinux/ and https://docs.docker.com/compose/install/).


### Initialization/Docker container bootstrapping
### Initialization

```shell
# For development:
Expand All @@ -38,7 +38,12 @@ ln -s compose-development.yml docker-compose.yml
ln -s compose-production.yml docker-compose.yml
```

To setup all the containers and their dependencies, run
### Docker container bootstrapping

Take a look at the scripts ```setup.development.sh``` and ```setup.production.sh``.
These scripts will setup the container forest, run migrations and create a superuser (interactive).

To setup all the containers and their dependencies by hand, run

```shell
docker-compose build
Expand All @@ -52,7 +57,7 @@ docker-compose up -d databasedev;
docker-compose run webappdev /bin/bash -c './manage.py migrate && ./manage.py createsuperuser'

# For production:
docker-compose up -d databaseprod;
docker-compose up -d database;
docker-compose run webapp /bin/bash -c './manage.py migrate && ./manage.py createsuperuser'
```

Expand Down
4 changes: 3 additions & 1 deletion compose-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ celery:
extends:
file: compose-common.yml
service: base
command: honcho start -f Procfile.celery
volumes:
- /var/run/docker.sock:/var/run/docker.sock
volumes_from:
- shareddata
command: honcho start -f Procfile.celery
links:
- rabbitmq:rabbit
- database
Expand Down
73 changes: 46 additions & 27 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,66 @@

To deploy to production server:

1. Clone the repository master branch without history:
1. Stop the running containers
```shell
docker exec osmaxx-starter /usr/local/bin/docker-compose stop
```

2. Rename the old source and clone the repository master branch without history:

```shell
git clone --depth 1 -b master https://github.com/geometalab/osmaxx.git osmaxx && cd osmaxx
git submodule init && git submodule update
```
Repository details see [Project repository](git-repository.md).
2. Link production configuration for docker-compose, Details see [Docker container bootstrapping](../README.md#initializationdocker-container-bootstrapping).
3. Add target specific environment variables to compose-production.yml
3. Link production configuration for docker-compose, Details see [Docker container bootstrapping](../README.md#initializationdocker-container-bootstrapping).
4. Add target specific environment variables to compose-production.yml
* If you are using an nginx proxy (jwilder/nginx-proxy), you need to set the environment variable
`VIRTUAL_HOST=osmaxx.yourdomain.tld`
4. Build the containers. Use docker-compose container instead of native installation:
5. Build the containers. Use docker-compose container instead of native installation:

a. Create the docker-compose container:
```shell
docker create \
a. Create the docker-compose container if not already exists:
```shell
# "up" && "--no-recreate": default arguments used by the systemd service starter
docker create \
--name osmaxx-starter
-v "/path/to/source/repo:/app" \
-v "/var/run/docker.sock:/var/run/docker.sock" \
-e "COMPOSE_PROJECT_NAME=osmaxx" \
"dduportal/docker-compose:1.2.0"
```

b. Build osmaxx containers:

```shell
docker start osmaxx-starter build --no-cache
```

5. Run migrations and add create super user, Details see [Docker container bootstrapping](../README.md#initializationdocker-container-bootstrapping).
"dduportal/docker-compose:1.3.1" up --no-recreate
```

b. Pull images & build osmaxx containers:
```shell
# pull newest images
# "--rm" removes the temporary used compose-container
docker run -v "/path/to/source/repo:/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" --rm "dduportal/docker-compose:1.3.1" pull

# build own containers
docker run -v "/path/to/source/repo:/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" --rm "dduportal/docker-compose:1.3.1" build
```

6. Run migrations and add create super user, Details see [Docker container bootstrapping](../README.md#initializationdocker-container-bootstrapping).
For docker-compose container run:

```shell
docker exec -ti osmaxx-starter /usr/local/bin/docker-compose \
run webapp /bin/bash -c "python3 manage.py migrate && python3 manage.py createsuperuser"
# database needs to be running before the webapp container
docker run -v "/path/to/source/repo:/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" --rm "dduportal/docker-compose:1.3.1" up -d database

# apply migrations
# "-it" is needed to get an interactive terminal
# "run --rm" removes the temporary used webapp container
docker run -v "/path/to/source/repo:/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" -it --rm "dduportal/docker-compose:1.3.1" run --rm webapp /bin/bash -c "python3 manage.py migrate && python3 manage.py createsuperuser"

# stop running containers
docker run -v "/path/to/source/repo:/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" --rm "dduportal/docker-compose:1.3.1" stop
```
6. Load data container content from old container if there is one, Details see [Useful Docker commands](project-development-environment.md#useful-docker-commands).
7. Load database container content from old container if there is one, Details see [Useful Docker commands](project-development-environment.md#useful-docker-commands).
8. Add a system startup script running `docker-compose up`
7. Load data container content from old container if there is one, Details see [Useful Docker commands](project-development-environment.md#useful-docker-commands).
8. Load database container content from old container if there is one, Details see [Useful Docker commands](project-development-environment.md#useful-docker-commands).
9. Add a system startup script running `docker-compose up`
E.g. /etc/systemd/system/osmaxx.service:

```shell

[Unit]
Description=Start osmaxx application

Expand All @@ -59,13 +76,15 @@ To deploy to production server:
WantedBy=multi-user.target
```
**important**: osmax-starter container needs to be created before!

9. Enable startup service

"/usr/bin/docker start -a osmaxx-starter" will use the default arguments configured on create.

1. Enable startup service
```shell
sudo systemctl enable docker-osmaxx.service
```
10. Start the containers

11. Start the containers
```shell
sudo systemctl start docker-osmaxx.service
```
9 changes: 4 additions & 5 deletions docs/git-repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,14 @@ git flow release start '1.4.0'
### Finish release

```shell
git flow release finish '1.4.0'

git checkout master
git pull origin master
git checkout develop
git push github develop --tags

git checkout master
git push github develop --tags
git flow release finish '1.4.0'

git checkout develop
git push origin develop:develop master:master '1.4.0'
```

Go to Github repository /releases and add description of the release.
16 changes: 9 additions & 7 deletions osmaxx-py/excerptconverter/converter_helper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.contrib import messages
from django.core.mail import send_mail
#from django.core.mail import send_mail
from django.utils.translation import ugettext_lazy as _

import stored_messages
Expand Down Expand Up @@ -35,12 +35,14 @@ def inform_user(self, message_type, message_text, email=True):

if email:
if hasattr(self.user, 'email'):
send_mail(
'[OSMAXX] '+message_text,
message_text,
'[email protected]',
[self.user.email]
)
pass
# TODO: fix it
# send_mail(
# '[OSMAXX] '+message_text,
# message_text,
# '[email protected]',
# [self.user.email]
# )
else:
self.inform_user(
messages.WARNING,
Expand Down
18 changes: 18 additions & 0 deletions setup.development.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# Setup a docker compose container used to start the development application
# Setup application & database

# stop containers & cleanup
docker-compose stop
docker-compose rm -f

# pull & build
docker-compose pull
docker-compose build

# migrate
docker-compose up -d databasedev
sleep 3
docker-compose run --rm webappdev /bin/bash -c './manage.py migrate && ./manage.py createsuperuser'

25 changes: 25 additions & 0 deletions setup.production.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Setup a docker compose container used to start the production application
# Setup application & database

DOCKER_COMPOSE_TAG="1.3.1"

# create container
docker create --name osmaxx-starter -v "$(pwd):/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" "dduportal/docker-compose:$DOCKER_COMPOSE_TAG" up --no-recreate

# stop containers & cleanup
docker run -v "$(pwd):/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" --rm "dduportal/docker-compose:$DOCKER_COMPOSE_TAG" stop
# TODO: data containers should not be removed!
docker run -v "$(pwd):/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" --rm "dduportal/docker-compose:$DOCKER_COMPOSE_TAG" rm -f

# pull & build
docker run -v "$(pwd):/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" --rm "dduportal/docker-compose:$DOCKER_COMPOSE_TAG" pull
docker run -v "$(pwd):/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" --rm "dduportal/docker-compose:$DOCKER_COMPOSE_TAG" build

# migrate
docker run -v "$(pwd):/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" --rm "dduportal/docker-compose:$DOCKER_COMPOSE_TAG" up -d database
sleep 3
docker run -v "$(pwd):/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" -it --rm "dduportal/docker-compose:$DOCKER_COMPOSE_TAG" \
run --rm webapp /bin/bash -c "python3 manage.py migrate && python3 manage.py createsuperuser"
docker run -v "$(pwd):/app" -v "/var/run/docker.sock:/var/run/docker.sock" -e "COMPOSE_PROJECT_NAME=osmaxx" --rm "dduportal/docker-compose:$DOCKER_COMPOSE_TAG" stop

0 comments on commit cc61d22

Please sign in to comment.