Skip to content
Merged
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
41 changes: 41 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.PHONY: shell, test, dev, start, build, migrate, shell_plus

PROJECT_NAME=django_atomic_transactions
DOCKER_COMPOSE=docker-compose -p ${PROJECT_NAME} -f environment/docker-compose.yml
LOCAL_USER="--user=$(shell id -u):$(shell id -g)"
DOCKER_COMPOSE_RUN_WEB=${DOCKER_COMPOSE} run --rm ${LOCAL_USER}

default: build

build:
${DOCKER_COMPOSE} build

stop:
${DOCKER_COMPOSE} stop

rm:
${DOCKER_COMPOSE} rm

start:
${DOCKER_COMPOSE} up web

dev:
${DOCKER_COMPOSE_RUN_WEB} --service-ports web dev

web:
${DOCKER_COMPOSE_RUN_WEB} --service-ports web web

test: build
${DOCKER_COMPOSE_RUN_WEB} web test

shell:
${DOCKER_COMPOSE_RUN_WEB} web ash

shell_plus:
${DOCKER_COMPOSE_RUN_WEB} web python manage.py shell_plus

migrate: build
${DOCKER_COMPOSE_RUN_WEB} web migrate

loaddata: migrate
${DOCKER_COMPOSE_RUN_WEB} web loaddata
110 changes: 102 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,111 @@
# Django atomic transactions
This porject simulate a virtual wallet to use Django atomic transactions.
This project simulate a virtual wallet to use Django atomic transactions.

## How to use it
## Requirements

* Create a virtualenv, example:
* docker engine >= 19.03.
* docker-compose >= 1.27.

## Tested on

* Ubuntu 18.04 (Bionic).
* docker engine == 20.10.9.
* docker-compose == 1.28.4.

## Relational models image

[Graph model image](docs/images/graph-models.png)

## Build project

## How to run project this project?

### Using make command (recommended)

If you can run a `Makefile` command, you can use a "fast init" with: `make loaddata`.

### Build

Build docker image:

```shell
make build
```

#### Migrate

Apply django migrations:

```shell
make migrate
```

#### Runserver

Run django runserver command:

```shell
make dev
```

#### Uvicorn

Run uvicorn server:

```shell
virtualenv env --python=python3.9
make web
```

From here example assume that your environment name is env.
If you use another one, please, change `clear-run.sh` and `run.sh`
#### Load sample data

Apply `initial_data.json` fixture:

```shell
make loaddata
```

### Using docker-compose

#### Step 1: Build

```shell
docker-compose -p django_atomic_transactions -f environment/docker-compose.yml build
```

#### Step 2: Migrate

Apply django migrations:

```shell
docker-compose -p django_atomic_transactions -f environment/docker-compose.yml run --rm --service-ports web migrate
```

#### Step 3: Run service

* **Runserver**

Run django runserver command:

```shell
docker-compose -p django_atomic_transactions -f environment/docker-compose.yml run --rm --service-ports web dev
```

* **Uvicorn**

Run uvicorn server:

```shell
docker-compose -p django_atomic_transactions -f environment/docker-compose.yml run --rm --service-ports web web
```

#### Step 4: Load sample data

Apply `initial_data.json` fixture:

```shell
docker-compose -p django_atomic_transactions -f environment/docker-compose.yml run --rm --service-ports web loaddata
```

* Execute `clear-run.sh`. **CAUTION** it removes database and migrations then it.
## TODO

* Execute `run.sh` the next time.
* Finish Dockerfile production stage.
Loading