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

Support using Docker for development #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,31 @@ Compile the translation files:
python manage.py compilemessages
```

#### Docker

You can also use Docker in development. Start server in `http://localhost:8000` by running:

```shell
docker-compose up
```

To run Django commands:

```shell
docker-compose run app python manage.py <command>
```

### Production

The project is containerized using Docker Compose. You will still need to set some
variables in your environment; see the first few lines in `aplans/settings.py`.

Use this command to apply the production configuration `docker-compose.production.yml`:

```shell
docker-compose -f docker-compose.yml -f docker-compose.production.yml up
```

## Contributing

### Python requirements
Expand Down
12 changes: 12 additions & 0 deletions docker-compose.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Development configuration file
#
# This file is automatically merged with docker-compose.yml
# when 'docker-compose up' is run.

version: '3.2'
services:
app:
volumes:
- .:/code
environment:
- DATABASE_URL=postgres://aplans@db/aplans
15 changes: 15 additions & 0 deletions docker-compose.production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Production configuration file
#
# To apply this configuration, run:
# docker-compose -f docker-compose.yml -f docker-compose.production.yml up

version: '3.2'
services:
db:
restart: always

app:
build:
cache_from:
- ${DOCKER_CACHE_IMAGE:-aplans_app}
restart: always
4 changes: 0 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ services:
build:
context: .
dockerfile: ./docker/db/Dockerfile
restart: always
environment:
- POSTGRES_USER=aplans
volumes:
Expand All @@ -16,9 +15,6 @@ services:
build:
context: .
dockerfile: docker/app/Dockerfile
cache_from:
- ${DOCKER_CACHE_IMAGE:-aplans_app}
restart: always
volumes:
- aplans_media:/srv/media
environment:
Expand Down
2 changes: 1 addition & 1 deletion docker/app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ RUN ./manage.py compilemessages
COPY ./docker/app/docker-entrypoint.sh /
COPY ./docker/app/wait-for-it.sh /

ENTRYPOINT ["/bin/bash", "/docker-entrypoint.sh"]
CMD ["/bin/bash", "/docker-entrypoint.sh"]