Skip to content

Commit

Permalink
add docker-compose file (#4)
Browse files Browse the repository at this point in the history
* docker-compose file

* added .env.example

* updated README
  • Loading branch information
tiftran committed Mar 12, 2022
1 parent f898199 commit 7996f98
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
DEBUG=true
SECRET_KEY=keyboard-mash
DATABASE_URL=postgres://postgres:postgres@db/consvc_shepherd
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ reducing the need for deployments of the services that use it.
To use consvc-shepherd, you'll need a Python 3.10 development environment.

You'll need to specify some minimal configuration. Create a file `.env` and put
in it at least:
in it at least, if using the docker workflow, you may want to use `.env.example`
and rename it to `env`:

```shell
DEBUG=true
Expand Down Expand Up @@ -47,3 +48,15 @@ $ ./manage.py runserver
This will start a development server that reloads on changes to the files. You
can access the configuration part of the site at
[localhost:8000/admin][http://localhost:8000/admin].

### Docker set up

Start with building and get it up with:
```
docker compose build
docker compose up
```
To create a user, shell into the container and run
```
./manage.py createsuperuser
```
45 changes: 45 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: "3"

services:
db:
restart: always
image: postgres:14.0
volumes:
- db_volume:/var/lib/postgresql
environment:
POSTGRES_DB: consvc_shepherd
POSTGRES_HOST_AUTH_METHOD: trust
ports:
- "5432:5432"
networks:
- private_nw

app:
tty: true
env_file:
- .env
build:
context: ./
dockerfile: ./Dockerfile
command: bash -c "python /app/manage.py migrate && python /app/manage.py runserver 0:8000"
links:
- db
networks:
- public_nw
- private_nw
volumes:
- .:/app
ports:
- "8000:8000"
depends_on:
- db

volumes:
db_volume:
node_modules_volume:
ssl_volume:

networks:
private_nw:
internal: true
public_nw:
3 changes: 2 additions & 1 deletion requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ flake8
mypy
django-environ
django-storages[google]
django-countries
django-countries
psycopg2
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ protobuf==3.19.4
# google-api-core
# google-cloud-storage
# googleapis-common-protos
psycopg2==2.9.3
# via -r requirements.in
pyasn1==0.4.8
# via
# pyasn1-modules
Expand Down

0 comments on commit 7996f98

Please sign in to comment.