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
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,19 @@ compilemessages:
cd apps && poetry run python ../manage.py compilemessages

docker-build:
docker build -t guide:latest --build-arg POETRY_INSTALL_ARGS="" -f Dockerfile .
docker compose build

docker-run:
docker run --name guide_latest -p ${PORT}:${PORT} --env-file .env guide:latest sh -c 'poetry run python manage.py runserver 0.0.0.0:${PORT}'
docker compose up --remove-orphans

docker-start:
docker compose up --remove-orphans -d

docker-stop:
docker compose down

docker-exec:
docker exec -it guide_latest /bin/bash
docker compose exec web /bin/bash

docker-init:
docker exec -it guide_latest /bin/bash -c "make backend"
docker compose exec web make backend
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,20 @@ Or both, in a single command:

### Setting up development with Docker

1. Create a `.env` file in the project root containing these variables, you can adjust the values to your preferences:
1. Optianally, create a `.env` file in the project root containing these variables, you can adjust the values to your preferences:
```
ALLOWED_HOSTS=localhost
PORT=8000
SECRET_KEY=some-random-secret
DJANGO_SETTINGS_MODULE=apps.guide.settings.dev
```
2. Build the image by running the `make docker-build` command.
3. Run the container with `make docker-run`.
4. Run the init script in the container: `make docker-init`
5. You should now have access to the project in your browser at `http://localhost:8000`
2. Build and start the development container by running the `make docker-run` command.
This starts the server in the foreground. To run it in the background, use `make docker-start` instead.
3. In another terminal, run the init script in the container: `make docker-init`
4. You should now have access to the project in your browser at `http://localhost:8000`
5. To stop the container, run `make docker-stop`

Code changes are picked up automatically. Only rebuild when dependencies change:`make docker-build`

# Gitpod

Expand Down
25 changes: 25 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
services:
web:
build:
context: .
args:
POETRY_INSTALL_ARGS: ''
ports:
- '${PORT:-8000}:${PORT:-8000}'
environment:
DJANGO_SETTINGS_MODULE: apps.guide.settings.dev
env_file:
- path: .env
required: false
volumes:
- .:/app
- staticfiles:/app/static
command:
- poetry
- run
- python
- manage.py
- runserver
- '0.0.0.0:${PORT:-8000}'
volumes:
staticfiles:
Loading